Advertisement
tommig

Pressure sensor

Nov 12th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. int update_PRSN(UPDATE_FUNC_ARGS) {
  2. int r, rx, ry, rt;
  3. for (rx=-2; rx<3; rx++)
  4. for (ry=-2; ry<3; ry++)
  5. if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
  6. {
  7. r = pmap[y+ry][x+rx];
  8. if (!r)
  9. continue;
  10. rt = parts[r>>8].type;
  11. if (parts_avg(i,r>>8,PT_INSL) != PT_INSL)
  12. {
  13. if (parts[i].temp>=256.0+273.15)
  14. parts[i].temp=256.0+273.15;
  15. if (parts[i].temp<= -256.0+273.15)
  16. parts[i].temp = -256.0+273.15;
  17.  
  18. if (pv[y/CELL][x/CELL]+273.14 > parts[i].temp)
  19. {
  20. if ((ptypes[rt].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && abs(rx)+abs(ry) < 4)
  21. {
  22. parts[r>>8].life = 4;
  23. parts[r>>8].ctype = rt;
  24. part_change_type(r>>8,x+rx,y+ry,PT_SPRK);
  25. }
  26. }
  27. }
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement