From 42cfb74c2bb82eb185962a17f848e47265a16316 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Wed, 24 Aug 2011 23:35:52 +0800 Subject: [PATCH] Remove blocking walls from pmap 2.5% speed increase on a screen full of water --- src/console.c | 2 +- src/elements/O2.c | 2 +- src/elements/acid.c | 2 +- src/elements/amtr.c | 2 +- src/elements/anar.c | 2 +- src/elements/aray.c | 6 ++--- src/elements/bcln.c | 4 +-- src/elements/bcol.c | 4 +-- src/elements/bmtl.c | 2 +- src/elements/bomb.c | 4 +-- src/elements/boyl.c | 2 +- src/elements/btry.c | 2 +- src/elements/c5.c | 2 +- src/elements/clne.c | 4 +-- src/elements/clst.c | 2 +- src/elements/coal.c | 4 +-- src/elements/deut.c | 6 ++--- src/elements/dlay.c | 2 +- src/elements/dstw.c | 2 +- src/elements/firw.c | 4 +-- src/elements/fog.c | 2 +- src/elements/frzw.c | 2 +- src/elements/frzz.c | 2 +- src/elements/fsep.c | 2 +- src/elements/fuse.c | 2 +- src/elements/gbmb.c | 2 +- src/elements/glow.c | 2 +- src/elements/gpmp.c | 2 +- src/elements/h2.c | 2 +- src/elements/hswc.c | 2 +- src/elements/ice.c | 2 +- src/elements/iron.c | 2 +- src/elements/lcry.c | 2 +- src/elements/legacy.c | 12 ++++----- src/elements/merc.c | 6 ++--- src/elements/neut.c | 2 +- src/elements/pbcn.c | 6 ++--- src/elements/pcln.c | 6 ++--- src/elements/phot.c | 2 +- src/elements/pipe.c | 8 +++--- src/elements/plnt.c | 6 ++--- src/elements/prti.c | 4 --- src/elements/prto.c | 2 +- src/elements/pump.c | 2 +- src/elements/pyro.c | 4 +-- src/elements/qrtz.c | 6 ++--- src/elements/rime.c | 2 +- src/elements/shld.c | 8 +----- src/elements/sing.c | 2 +- src/elements/sltw.c | 2 +- src/elements/soap.c | 6 ++--- src/elements/spng.c | 10 +++----- src/elements/sprk.c | 4 +-- src/elements/stkm.c | 11 +++------ src/elements/swch.c | 2 +- src/elements/thdr.c | 2 +- src/elements/thrm.c | 2 +- src/elements/vine.c | 2 -- src/elements/warp.c | 2 +- src/elements/watr.c | 2 +- src/elements/wifi.c | 2 +- src/elements/wire.c | 2 +- src/elements/wtrv.c | 2 +- src/elements/yest.c | 2 +- src/graphics.c | 6 ++--- src/luaconsole.c | 10 ++++---- src/main.c | 8 +++--- src/powder.c | 57 ++++++++++++++++++------------------------- 68 files changed, 132 insertions(+), 166 deletions(-) diff --git a/src/console.c b/src/console.c index da33d98c5..c9714a173 100644 --- a/src/console.c +++ b/src/console.c @@ -56,7 +56,7 @@ int console_parse_partref(char *txt, int *which, char *err) if (strchr(txt,',') && console_parse_coords(txt, &nx, &ny, err)) { i = pmap[ny][nx]; - if (!i || (i>>8)>=NPART) + if (!i) i = -1; else i = i>>8; diff --git a/src/elements/O2.c b/src/elements/O2.c index a0087666d..b71870ee1 100644 --- a/src/elements/O2.c +++ b/src/elements/O2.c @@ -8,7 +8,7 @@ int update_O2(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_FIRE) diff --git a/src/elements/acid.c b/src/elements/acid.c index 24bb3217c..d6e31be73 100644 --- a/src/elements/acid.c +++ b/src/elements/acid.c @@ -7,7 +7,7 @@ int update_ACID(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_ACID) { diff --git a/src/elements/amtr.c b/src/elements/amtr.c index 49a96182c..42002c8be 100644 --- a/src/elements/amtr.c +++ b/src/elements/amtr.c @@ -7,7 +7,7 @@ int update_AMTR(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_AMTR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_NONE && (r&0xFF)!=PT_PHOT && (r&0xFF)!=PT_VOID && (r&0xFF)!=PT_BHOL && (r&0xFF)!=PT_NBHL && (r&0xFF)!=PT_PRTI && (r&0xFF)!=PT_PRTO) { diff --git a/src/elements/anar.c b/src/elements/anar.c index 4a30cc20d..bab112cb7 100644 --- a/src/elements/anar.c +++ b/src/elements/anar.c @@ -10,7 +10,7 @@ int update_ANAR(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_HFLM) { diff --git a/src/elements/aray.c b/src/elements/aray.c index 9604fba80..539b5a64d 100644 --- a/src/elements/aray.c +++ b/src/elements/aray.c @@ -9,7 +9,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPRK) { int destroy = (parts[r>>8].ctype==PT_PSCN)?1:0; @@ -19,7 +19,6 @@ int update_ARAY(UPDATE_FUNC_ARGS) { break; } r = pmap[y+nyi+nyy][x+nxi+nxx]; - if (!((r>>8)>=NPART)) { if (!r) { int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); if (nr!=-1) { @@ -49,7 +48,7 @@ int update_ARAY(UPDATE_FUNC_ARGS) { if (nyy!=0 || nxx!=0) { create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); } - //if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) {//don't need to check r&0xFF>8)>=NPART //Not sure why you changed checking "ctype" to "type" + //if (!(nostop && (ptypes[r&0xFF].properties&PROP_CONDUCTS))) { if (!(nostop && parts[r>>8].ctype >= 0 && parts[r>>8].ctype < PT_NUM && (ptypes[parts[r>>8].ctype].properties&PROP_CONDUCTS))) { docontinue = 0; } else { @@ -67,7 +66,6 @@ int update_ARAY(UPDATE_FUNC_ARGS) { docontinue = 0; } } - } } } //parts[i].life = 4; diff --git a/src/elements/bcln.c b/src/elements/bcln.c index 062c85ff5..29a45a784 100644 --- a/src/elements/bcln.c +++ b/src/elements/bcln.c @@ -17,9 +17,9 @@ int update_BCLN(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART) + if (!r) r = pmap[y+ry][x+rx]; - if (!r || (r>>8)>=NPART) + if (!r) continue; if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && diff --git a/src/elements/bcol.c b/src/elements/bcol.c index bc8713c93..aac3ffec0 100644 --- a/src/elements/bcol.c +++ b/src/elements/bcol.c @@ -15,7 +15,7 @@ int update_BCOL(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) { @@ -42,7 +42,7 @@ int update_BCOL(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion { diff --git a/src/elements/bmtl.c b/src/elements/bmtl.c index a29ac7dea..04d9f3acd 100644 --- a/src/elements/bmtl.c +++ b/src/elements/bmtl.c @@ -9,7 +9,7 @@ int update_BMTL(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; rt = parts[r>>8].type; if ((rt==PT_METL || rt==PT_IRON) && 1>(rand()/(RAND_MAX/100))) diff --git a/src/elements/bomb.c b/src/elements/bomb.c index de10fccf0..31f01abad 100644 --- a/src/elements/bomb.c +++ b/src/elements/bomb.c @@ -8,7 +8,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_BOMB) { kill_part(i); @@ -21,7 +21,7 @@ int update_BOMB(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) { int rad = 8; diff --git a/src/elements/boyl.c b/src/elements/boyl.c index 68e1bf641..ec8eec58a 100644 --- a/src/elements/boyl.c +++ b/src/elements/boyl.c @@ -26,7 +26,7 @@ int update_BOYL(UPDATE_FUNC_ARGS) { x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR && 1>rand()%30) { diff --git a/src/elements/btry.c b/src/elements/btry.c index c3a96c7c3..4716c6a93 100644 --- a/src/elements/btry.c +++ b/src/elements/btry.c @@ -7,7 +7,7 @@ int update_BTRY(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; rt = parts[r>>8].type; if (parts_avg(i,r>>8,PT_INSL) != PT_INSL) diff --git a/src/elements/c5.c b/src/elements/c5.c index 000c2be4e..93fd63cd8 100644 --- a/src/elements/c5.c +++ b/src/elements/c5.c @@ -7,7 +7,7 @@ int update_C5(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)!=PT_C5 && parts[r>>8].temp<100)||(r&0xFF)==PT_HFLM) { diff --git a/src/elements/clne.c b/src/elements/clne.c index 41f27e3bc..a7d22fd75 100644 --- a/src/elements/clne.c +++ b/src/elements/clne.c @@ -9,9 +9,9 @@ int update_CLNE(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART) + if (!r) r = pmap[y+ry][x+rx]; - if (!r || (r>>8)>=NPART) + if (!r) continue; if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && diff --git a/src/elements/clst.c b/src/elements/clst.c index 78c827fa0..8666582e6 100644 --- a/src/elements/clst.c +++ b/src/elements/clst.c @@ -8,7 +8,7 @@ int update_CLST(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR && 1>(rand()%1500)) { diff --git a/src/elements/coal.c b/src/elements/coal.c index e11189091..14c3138c2 100644 --- a/src/elements/coal.c +++ b/src/elements/coal.c @@ -22,7 +22,7 @@ int update_COAL(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM) && 1>(rand()%500)) { @@ -49,7 +49,7 @@ int update_COAL(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion { diff --git a/src/elements/deut.c b/src/elements/deut.c index 2d7a1f245..749bf2875 100644 --- a/src/elements/deut.c +++ b/src/elements/deut.c @@ -12,7 +12,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r || (parts[i].life >=maxlife)) + if (!r || (parts[i].life >=maxlife)) continue; if ((r&0xFF)==PT_DEUT&&33>=rand()/(RAND_MAX/100)+1) { @@ -30,7 +30,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || (parts[i].life<=maxlife)) + if (parts[i].life<=maxlife) continue; if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL|| bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS)) @@ -51,7 +51,7 @@ int update_DEUT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion { diff --git a/src/elements/dlay.c b/src/elements/dlay.c index 2a248ca62..c91b69bc1 100644 --- a/src/elements/dlay.c +++ b/src/elements/dlay.c @@ -17,7 +17,7 @@ int update_DLAY(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[r>>8].ctype==PT_PSCN) { diff --git a/src/elements/dstw.c b/src/elements/dstw.c index 390896d41..e00d7b37e 100644 --- a/src/elements/dstw.c +++ b/src/elements/dstw.c @@ -7,7 +7,7 @@ int update_DSTW(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SALT && 1>(rand()%250)) { diff --git a/src/elements/firw.c b/src/elements/firw.c index c41400e9c..9c8f54691 100644 --- a/src/elements/firw.c +++ b/src/elements/firw.c @@ -8,7 +8,7 @@ int update_FIRW(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; rt = parts[r>>8].type; if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) @@ -44,7 +44,7 @@ int update_FIRW(UPDATE_FUNC_ARGS) { tmul = rand()%7; create_part(-1, x+rx, y+ry, PT_FIRW); r = pmap[y+ry][x+rx]; - if ((r>>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_FIRW) { parts[r>>8].vx = (rand()%3-1)*tmul; diff --git a/src/elements/fog.c b/src/elements/fog.c index ff139161c..135db12ca 100644 --- a/src/elements/fog.c +++ b/src/elements/fog.c @@ -7,7 +7,7 @@ int update_FOG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? { diff --git a/src/elements/frzw.c b/src/elements/frzw.c index 313535783..066bc64b9 100644 --- a/src/elements/frzw.c +++ b/src/elements/frzw.c @@ -7,7 +7,7 @@ int update_FRZW(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR&&5>rand()%70) { diff --git a/src/elements/frzz.c b/src/elements/frzz.c index f995d5f99..fbd083dfd 100644 --- a/src/elements/frzz.c +++ b/src/elements/frzz.c @@ -7,7 +7,7 @@ int update_FRZZ(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR&&5>rand()%100) { diff --git a/src/elements/fsep.c b/src/elements/fsep.c index 6b3b3760d..7968240c3 100644 --- a/src/elements/fsep.c +++ b/src/elements/fsep.c @@ -21,7 +21,7 @@ int update_FSEP(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && 1>(rand()%15)) { diff --git a/src/elements/fuse.c b/src/elements/fuse.c index ad0a4133f..450308a21 100644 --- a/src/elements/fuse.c +++ b/src/elements/fuse.c @@ -28,7 +28,7 @@ int update_FUSE(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPRK || ((parts[i].temp>=(273.15+700.0f)) && 1>(rand()%20))) { diff --git a/src/elements/gbmb.c b/src/elements/gbmb.c index d1d45b956..d60631256 100644 --- a/src/elements/gbmb.c +++ b/src/elements/gbmb.c @@ -7,7 +7,7 @@ int update_GBMB(UPDATE_FUNC_ARGS) { for (ry=-2; ry<3; ry++) { r = pmap[y+ry][x+rx]; - if(!r || (r>>8)>=NPART) + if(!r) continue; if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && diff --git a/src/elements/glow.c b/src/elements/glow.c index ecbb0057f..984ba7e5e 100644 --- a/src/elements/glow.c +++ b/src/elements/glow.c @@ -7,7 +7,7 @@ int update_GLOW(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR&&5>(rand()%2000)) { diff --git a/src/elements/gpmp.c b/src/elements/gpmp.c index 2f0f8393e..1766b3baa 100644 --- a/src/elements/gpmp.c +++ b/src/elements/gpmp.c @@ -19,7 +19,7 @@ int update_GPMP(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_GPMP) { diff --git a/src/elements/h2.c b/src/elements/h2.c index 04f3d0154..c60110883 100644 --- a/src/elements/h2.c +++ b/src/elements/h2.c @@ -9,7 +9,7 @@ int update_H2(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; rt = (r&0xFF); - if ((r>>8)>=NPART || !r) + if (!r) continue; if (pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure { diff --git a/src/elements/hswc.c b/src/elements/hswc.c index 6e1b2dfa7..350cc0768 100644 --- a/src/elements/hswc.c +++ b/src/elements/hswc.c @@ -11,7 +11,7 @@ int update_HSWC(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_HSWC) { diff --git a/src/elements/ice.c b/src/elements/ice.c index 96bb22b80..92b645015 100644 --- a/src/elements/ice.c +++ b/src/elements/ice.c @@ -11,7 +11,7 @@ int update_ICEI(UPDATE_FUNC_ARGS) { //currently used for snow as well if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && 1>(rand()%1000)) { diff --git a/src/elements/iron.c b/src/elements/iron.c index 0be1e1f99..451783d72 100644 --- a/src/elements/iron.c +++ b/src/elements/iron.c @@ -7,7 +7,7 @@ int update_IRON(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((((r&0xFF) == PT_SALT && 15>(rand()/(RAND_MAX/700))) || ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/2000))) || diff --git a/src/elements/lcry.c b/src/elements/lcry.c index 7b1a64ea8..e03a3a452 100644 --- a/src/elements/lcry.c +++ b/src/elements/lcry.c @@ -11,7 +11,7 @@ int update_LCRY(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_LCRY) { diff --git a/src/elements/legacy.c b/src/elements/legacy.c index 0fd3d6b66..8674e4be5 100644 --- a/src/elements/legacy.c +++ b/src/elements/legacy.c @@ -12,7 +12,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000)) { @@ -34,7 +34,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) { @@ -49,7 +49,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) { @@ -65,7 +65,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) { @@ -79,7 +79,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) { @@ -94,7 +94,7 @@ int update_legacy_all(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) { diff --git a/src/elements/merc.c b/src/elements/merc.c index 89cd79c42..98fdb57d3 100644 --- a/src/elements/merc.c +++ b/src/elements/merc.c @@ -12,7 +12,7 @@ int update_MERC(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r || (parts[i].tmp >=maxtmp)) + if (!r || (parts[i].tmp >=maxtmp)) continue; if ((r&0xFF)==PT_MERC&&33>=rand()/(RAND_MAX/100)+1) { @@ -30,7 +30,7 @@ int update_MERC(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || (parts[i].tmp<=maxtmp)) + if (parts[i].tmp<=maxtmp) continue; if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL|| bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS)) @@ -51,7 +51,7 @@ int update_MERC(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[r>>8].tmp)&&parts[i].tmp>0)//diffusion { diff --git a/src/elements/neut.c b/src/elements/neut.c index 85a0be25e..0677af84c 100644 --- a/src/elements/neut.c +++ b/src/elements/neut.c @@ -50,7 +50,7 @@ int update_NEUT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) { diff --git a/src/elements/pbcn.c b/src/elements/pbcn.c index 3f40628be..634a4112e 100644 --- a/src/elements/pbcn.c +++ b/src/elements/pbcn.c @@ -23,9 +23,9 @@ int update_PBCN(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART) + if (!r) r = pmap[y+ry][x+rx]; - if (!r || (r>>8)>=NPART) + if (!r) continue; if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK && @@ -46,7 +46,7 @@ int update_PBCN(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_PBCN) { diff --git a/src/elements/pcln.c b/src/elements/pcln.c index 45cfc7996..e9c8d5be5 100644 --- a/src/elements/pcln.c +++ b/src/elements/pcln.c @@ -9,7 +9,7 @@ int update_PCLN(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPRK) { @@ -32,9 +32,9 @@ int update_PCLN(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART) + if (!r) r = pmap[y+ry][x+rx]; - if (!r || (r>>8)>=NPART) + if (!r) continue; if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_SPRK && diff --git a/src/elements/phot.c b/src/elements/phot.c index 12e7da54d..98d421dc0 100644 --- a/src/elements/phot.c +++ b/src/elements/phot.c @@ -14,7 +14,7 @@ int update_PHOT(UPDATE_FUNC_ARGS) { for (ry=-1; ry<2; ry++) if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_ISOZ && 5>(rand()%2000)) { diff --git a/src/elements/pipe.c b/src/elements/pipe.c index 0d664821d..af008dcda 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -25,7 +25,7 @@ void pushParticle(int i, int count, int original) if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART || !r) + if (!r) continue; else if ((r&0xFF)==PT_PIPE && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0) { @@ -47,7 +47,7 @@ void pushParticle(int i, int count, int original) { int coords = 7 - (parts[i].tmp>>10); r = pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; - if ((r>>8)>=NPART || !r) + if (!r) { } else if ((r&0xFF)==PT_PIPE && parts[r>>8].ctype!=notctype && (parts[r>>8].tmp&0xFF)==0) @@ -85,7 +85,7 @@ int update_PIPE(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_PIPE&&parts[r>>8].ctype==1) { @@ -130,8 +130,6 @@ int update_PIPE(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>=0 && x+rx>8)>=NPART) - return 0; if (surround_space && !r && (parts[i].tmp&0xFF)!=0) //creating at end { np = create_part(-1,x+rx,y+ry,parts[i].tmp&0xFF); diff --git a/src/elements/plnt.c b/src/elements/plnt.c index 5baec2f67..97b09e2e2 100644 --- a/src/elements/plnt.c +++ b/src/elements/plnt.c @@ -7,7 +7,7 @@ int update_PLNT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_WATR && 1>(rand()%250)) { @@ -31,7 +31,7 @@ int update_PLNT(UPDATE_FUNC_ARGS) { int nny = rand()%3 -1; if (x+rx+nnx>=0 && y+ry+nny>0 && x+rx+nnx>8)>=NPART||pmap[y+ry+nny][x+rx+nnx]) + if (pmap[y+ry+nny][x+rx+nnx]) continue; np = create_part(-1,x+rx+nnx,y+ry+nny,PT_VINE); if (np<0) continue; @@ -46,8 +46,6 @@ int update_PLNT(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if (!r) create_part(-1,x+rx,y+ry,PT_O2); } diff --git a/src/elements/prti.c b/src/elements/prti.c index 703841276..57830abfd 100644 --- a/src/elements/prti.c +++ b/src/elements/prti.c @@ -24,13 +24,9 @@ int update_PRTI(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) fe = 1; - if ((r>>8)>=NPART) - continue; if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (ptypes[r&0xFF].falldown== 0 && ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK)) { r = photons[y+ry][x+rx]; - if ((r>>8)>=NPART) - continue; if (!r || (r&0xFF)==PT_PRTI || (r&0xFF)==PT_PRTO || (ptypes[r&0xFF].falldown== 0 && ptypes[r&0xFF].state != ST_GAS && (r&0xFF)!=PT_SPRK)) continue; } diff --git a/src/elements/prto.c b/src/elements/prto.c index 880de2021..e86891a89 100644 --- a/src/elements/prto.c +++ b/src/elements/prto.c @@ -21,7 +21,7 @@ int update_PRTO(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) fe = 1; - if ((r>>8)>=NPART || r) + if (r) continue; if (!r) { diff --git a/src/elements/pump.c b/src/elements/pump.c index fa28b4c5a..2e11ae05b 100644 --- a/src/elements/pump.c +++ b/src/elements/pump.c @@ -26,7 +26,7 @@ int update_PUMP(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_PUMP) { diff --git a/src/elements/pyro.c b/src/elements/pyro.c index bd6ab2639..465d075b2 100644 --- a/src/elements/pyro.c +++ b/src/elements/pyro.c @@ -28,7 +28,7 @@ int update_PYRO(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) continue; @@ -58,7 +58,7 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (bmap[(y+ry)/CELL][(x+rx)/CELL] && bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) continue; diff --git a/src/elements/qrtz.c b/src/elements/qrtz.c index cf22925d6..c8017b0ee 100644 --- a/src/elements/qrtz.c +++ b/src/elements/qrtz.c @@ -19,7 +19,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; else if ((r&0xFF)==PT_SLTW && (1>rand()%2500)) { @@ -37,7 +37,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)-1) @@ -69,7 +69,7 @@ int update_QRTZ(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==t && (parts[i].ctype>parts[r>>8].ctype) && parts[r>>8].ctype>=0 )//diffusion { diff --git a/src/elements/rime.c b/src/elements/rime.c index e0337e5ed..1c994b804 100644 --- a/src/elements/rime.c +++ b/src/elements/rime.c @@ -9,7 +9,7 @@ int update_RIME(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPRK) { diff --git a/src/elements/shld.c b/src/elements/shld.c index 81b9f1bd9..ece353c85 100644 --- a/src/elements/shld.c +++ b/src/elements/shld.c @@ -7,7 +7,7 @@ int update_SHLD1(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) { @@ -42,8 +42,6 @@ int update_SHLD2(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if (!r && parts[i].life>0) create_part(-1,x+rx,y+ry,PT_SHLD1); if (!r) @@ -82,8 +80,6 @@ int update_SHLD3(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if (!r) { if (1>rand()%2500) @@ -132,8 +128,6 @@ int update_SHLD4(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if (!r) { if (1>rand()%5500) diff --git a/src/elements/sing.c b/src/elements/sing.c index f75b5b006..1f463bf4e 100644 --- a/src/elements/sing.c +++ b/src/elements/sing.c @@ -64,7 +64,7 @@ int update_SING(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1) { diff --git a/src/elements/sltw.c b/src/elements/sltw.c index ed62e40b6..619cdaffe 100644 --- a/src/elements/sltw.c +++ b/src/elements/sltw.c @@ -7,7 +7,7 @@ int update_SLTW(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SALT && 1>(rand()%10000)) kill_part(r>>8); diff --git a/src/elements/soap.c b/src/elements/soap.c index e130e3521..6cf25cda7 100644 --- a/src/elements/soap.c +++ b/src/elements/soap.c @@ -56,7 +56,7 @@ int update_SOAP(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((parts[r>>8].type == PT_SOAP) && ((parts[r>>8].ctype&1) == 1) @@ -92,7 +92,7 @@ int update_SOAP(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) && !bmap[(y+ry)/CELL][(x+rx)/CELL]) + if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; if (parts[i].temp>0) @@ -181,7 +181,7 @@ int update_SOAP(UPDATE_FUNC_ARGS) if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF) == PT_OIL) diff --git a/src/elements/spng.c b/src/elements/spng.c index 5ace1d6b5..eba3f69ca 100644 --- a/src/elements/spng.c +++ b/src/elements/spng.c @@ -9,7 +9,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r || parts[i].temp>374.0f) + if (!r) continue; if ((r&0xFF)==PT_WATR&&33>=rand()/(RAND_MAX/100)+1) { @@ -24,8 +24,6 @@ int update_SPNG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_EWALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL|| bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWAIR||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWGAS)) continue; @@ -42,7 +40,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[r>>8].life)&&parts[i].life>0)//diffusion { @@ -70,7 +68,7 @@ int update_SPNG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_FIRE) { @@ -92,8 +90,6 @@ int update_SPNG(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - continue; if ((bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALLELEC||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWLIQUID||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_DESTROYALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_WALL||bmap[(y+ry)/CELL][(x+rx)/CELL]==WL_ALLOWSOLID)) continue; if ((!r)&&parts[i].life>=1)//if nothing then create steam diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 0f3d8e9f2..bae66e877 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -58,7 +58,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF) == PT_DSTW && 30>(rand()/(RAND_MAX/1000))) || ((r&0xFF) == PT_SLTW && 30>(rand()/(RAND_MAX/1000))) || @@ -76,7 +76,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; rt = parts[r>>8].type; conduct_sprk = 1; diff --git a/src/elements/stkm.c b/src/elements/stkm.c index 6873ef510..41d2871f0 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -188,10 +188,10 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) + if (!r) r = photons[y+ry][x+rx]; - if ((!r || (r>>8)>=NPART) && !bmap[(y+ry)/CELL][(x+rx)/CELL]) + if (!r && !bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; if (ptypes[r&0xFF].falldown!=0 || (r&0xFF) == PT_NEUT || (r&0xFF) == PT_PHOT) @@ -230,8 +230,6 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { { ry -= 2*(rand()%2)+1; r = pmap[ry][rx]; - if (!((r>>8)>=NPART)) - { if (ptypes[r&0xFF].state == ST_SOLID) { create_part(-1, rx, ry, PT_SPRK); @@ -267,7 +265,6 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS) { } } - } } //Simulation of joints @@ -371,9 +368,9 @@ void STKM_interact(float* playerp, int i, int x, int y) if (x<0 || y<0 || x>=XRES || y>=YRES || !parts[i].type) return; r = pmap[y][x]; - if (r && (r>>8)>8)=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (parts_avg(i,r>>8,PT_INSL)!=PT_INSL) { rt = r&0xFF; diff --git a/src/elements/thdr.c b/src/elements/thdr.c index fb90d1db1..5179e1fee 100644 --- a/src/elements/thdr.c +++ b/src/elements/thdr.c @@ -7,7 +7,7 @@ int update_THDR(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((ptypes[r&0xFF].properties&PROP_CONDUCTS) && parts[r>>8].life==0 && !((r&0xFF)==PT_WATR||(r&0xFF)==PT_SLTW) && parts[r>>8].ctype!=PT_SPRK) { diff --git a/src/elements/thrm.c b/src/elements/thrm.c index 838b4666f..c296a8a86 100644 --- a/src/elements/thrm.c +++ b/src/elements/thrm.c @@ -7,7 +7,7 @@ int update_THRM(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_LAVA)) // TODO: could this go in update_PYRO? { diff --git a/src/elements/vine.c b/src/elements/vine.c index 28b97d51d..180d95c2a 100644 --- a/src/elements/vine.c +++ b/src/elements/vine.c @@ -5,8 +5,6 @@ int update_VINE(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART) - return 0; if (1>rand()%15) part_change_type(i,x,y,PT_PLNT); else if (!r) diff --git a/src/elements/warp.c b/src/elements/warp.c index 755433f36..a3e49ece4 100644 --- a/src/elements/warp.c +++ b/src/elements/warp.c @@ -9,7 +9,7 @@ int update_WARP(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)!=PT_WARP&&(r&0xFF)!=PT_STKM&&(r&0xFF)!=PT_STKM2&&(r&0xFF)!=PT_DMND&&(r&0xFF)!=PT_CLNE&&(r&0xFF)!=PT_BCLN&&(r&0xFF)!=PT_PCLN&&(10>=rand()%200)) { diff --git a/src/elements/watr.c b/src/elements/watr.c index 92c906d27..ac8d8e3b4 100644 --- a/src/elements/watr.c +++ b/src/elements/watr.c @@ -7,7 +7,7 @@ int update_WATR(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_SALT && 1>(rand()%250)) { diff --git a/src/elements/wifi.c b/src/elements/wifi.c index a511e4b42..3e87fefa9 100644 --- a/src/elements/wifi.c +++ b/src/elements/wifi.c @@ -10,7 +10,7 @@ int update_WIFI(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (wireless[parts[i].tmp][0]) { diff --git a/src/elements/wire.c b/src/elements/wire.c index f56e4696f..d4225a550 100644 --- a/src/elements/wire.c +++ b/src/elements/wire.c @@ -27,7 +27,7 @@ int update_WIRE(UPDATE_FUNC_ARGS) { if(x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if((r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN){parts[i].ctype=1; parts[r>>8].life=0; return 0;} else if((r&0xFF)==PT_NSCN && parts[i].tmp==1){create_part(-1, x+rx, y+ry, PT_SPRK);} diff --git a/src/elements/wtrv.c b/src/elements/wtrv.c index a4facdecf..2e8ca3a80 100644 --- a/src/elements/wtrv.c +++ b/src/elements/wtrv.c @@ -7,7 +7,7 @@ int update_WTRV(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !legacy_enable && parts[i].temp>(273.15f+12.0f) && 1>(rand()%500)) { diff --git a/src/elements/yest.c b/src/elements/yest.c index d3f64cdbb..3246de2fb 100644 --- a/src/elements/yest.c +++ b/src/elements/yest.c @@ -7,7 +7,7 @@ int update_YEST(UPDATE_FUNC_ARGS) { if (x+rx>=0 && y+ry>0 && x+rx>8)>=NPART || !r) + if (!r) continue; if ((r&0xFF)==PT_DYST && 1>(rand()%30) && !legacy_enable) { diff --git a/src/graphics.c b/src/graphics.c index 1016adb65..538c888ef 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3885,7 +3885,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c if (rx==0 && ry==0) { rp = pmap[y][x]; - if ((rp>>8)>=NPART || !rp) + if (!rp) return; if (click == 4) parts[rp>>8].dcolour = 0; @@ -3898,7 +3898,7 @@ void create_decorations(int x, int y, int rx, int ry, int r, int g, int b, int c if(y+j>=0 && x+i>=0 && x+i>8)>=NPART || !rp) + if (!rp) continue; if (click == 4) parts[rp>>8].dcolour = 0; @@ -4028,7 +4028,7 @@ void render_signs(pixel *vid_buf) } if (strcmp(signs[i].text, "{t}")==0) { - if ((pmap[signs[i].y][signs[i].x]>>8)>0 && (pmap[signs[i].y][signs[i].x]>>8)>8].temp-273.15); //...tempirature else sprintf(buff, "Temp: 0.00"); //...tempirature diff --git a/src/luaconsole.c b/src/luaconsole.c index adf462077..bac4182d8 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -504,7 +504,7 @@ int luatpt_set_property(lua_State* l) for (nx = x; nx>8) >= NPART || (partsel && partsel != parts[r>>8].type)) + if (!r || (partsel && partsel != parts[r>>8].type)) { r = photons[ny][nx]; if (!r || (partsel && partsel != parts[r>>8].type)) @@ -523,9 +523,9 @@ int luatpt_set_property(lua_State* l) if (i>=XRES || y>=YRES) return luaL_error(l, "Coordinates out of range (%d,%d)", i, y); r = pmap[y][i]; - if (!r || (r>>8)>=NPART || (partsel && partsel != parts[r>>8].type)) + if (!r || (partsel && partsel != parts[r>>8].type)) r = photons[y][i]; - if (!r || (r>>8)>=NPART || (partsel && partsel != parts[r>>8].type)) + if (!r || (partsel && partsel != parts[r>>8].type)) return 0; i = r>>8; } @@ -553,9 +553,9 @@ int luatpt_get_property(lua_State* l) y = luaL_optint(l, 3, -1); if(y!=-1 && y < YRES && y >= 0 && i < XRES && i >= 0){ r = pmap[y][i]; - if (!r || (r>>8)>=NPART) + if (!r) r = photons[y][i]; - if (!r || (r>>8)>=NPART) + if (!r) { if (strcmp(prop,"type")==0){ lua_pushinteger(l, 0); diff --git a/src/main.c b/src/main.c index 7caa7e9bb..88474bcb4 100644 --- a/src/main.c +++ b/src/main.c @@ -718,7 +718,7 @@ int parse_save(void *save, int size, int replace, int x0, int y0, unsigned char gol[x][y]=0; if (j) { - if (pmap[y][x] && (pmap[y][x]>>8)>8; memset(parts+k, 0, sizeof(particle)); @@ -2571,7 +2571,7 @@ int main(int argc, char *argv[]) } else { cr = pmap[y/sdl_scale][x/sdl_scale]; } - if (!((cr>>8)>=NPART || !cr)) + if (cr) { if ((cr&0xFF)==PT_LIFE && parts[cr>>8].ctype>=0 && parts[cr>>8].ctype>8)>=NPART || !cr) + if (!cr) cr = photons[y][x]; - if (!((cr>>8)>=NPART || !cr)) + if (cr) { c = sl = cr&0xFF; if (c==PT_LIFE) diff --git a/src/powder.c b/src/powder.c index 870e793e4..df88f9d79 100644 --- a/src/powder.c +++ b/src/powder.c @@ -150,7 +150,7 @@ int eval_move(int pt, int nx, int ny, unsigned *rr) return 0; r = pmap[ny][nx]; - if (r && (r>>8)>8].type; if (rr) *rr = r; @@ -175,8 +175,9 @@ int eval_move(int pt, int nx, int ny, unsigned *rr) return 0; if (bmap[ny/CELL][nx/CELL]==WL_ALLOWSOLID && ptypes[pt].falldown!=1) return 0; - // blocking by WL_WALL, WL_WALLELEC and unpowered WL_EWALL is currently done by putting 0x7FFFFFFF in pmap - if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR) + if (bmap[ny/CELL][nx/CELL]==WL_ALLOWAIR || bmap[ny/CELL][nx/CELL]==WL_WALL || bmap[ny/CELL][nx/CELL]==WL_WALLELEC) + return 0; + if (bmap[ny/CELL][nx/CELL]==WL_EWALL && !emap[ny/CELL][nx/CELL]) return 0; if (bmap[ny/CELL][nx/CELL]==WL_EHOLE && !emap[ny/CELL][nx/CELL]) return 2; @@ -329,13 +330,12 @@ int try_move(int i, int x, int y, int nx, int ny) return 0; e = r >> 8; //e is now the particle number at r (pmap[ny][nx]) - if (r && e>8)>=NPART) return 0; - if ((s&0xFF) && (s&0xFF)>8].ctype=PT_DUST; } - if ((pmap[y][x]>>8)>=NPART || !((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) + if (!((pmap[y][x]&0xFF)==PT_INST||(ptypes[pmap[y][x]&0xFF].properties&PROP_CONDUCTS))) return -1; if (parts[pmap[y][x]>>8].life!=0) return -1; @@ -1072,7 +1072,7 @@ inline void delete_part(int x, int y, int flags)//calls kill_part with the parti i = pmap[y][x]; } - if (!i || (i>>8)>=NPART) + if (!i) return; if (!(flags&BRUSH_SPECIFIC_DELETE) || parts[i>>8].type==SLALT || SLALT==0)//specific deletiom { @@ -1195,7 +1195,7 @@ inline int parts_avg(int ci, int ni,int t) if (t==PT_INSL)//to keep electronics working { int pmr = pmap[((int)(parts[ci].y+0.5f) + (int)(parts[ni].y+0.5f))/2][((int)(parts[ci].x+0.5f) + (int)(parts[ni].x+0.5f))/2]; - if ((pmr>>8) < NPART && pmr) + if (pmr) return parts[pmr>>8].type; else return PT_NONE; @@ -1203,7 +1203,7 @@ inline int parts_avg(int ci, int ni,int t) else { int pmr2 = pmap[(int)((parts[ci].y + parts[ni].y)/2+0.5f)][(int)((parts[ci].x + parts[ni].x)/2+0.5f)];//seems to be more accurate. - if ((pmr2>>8) < NPART && pmr2) + if (pmr2) { if (parts[pmr2>>8].type==t) return t; @@ -1344,7 +1344,7 @@ void update_particles_i(pixel *vid, int start, int inc) for (nx=0; nx>8)>=NPART || !r) + if (!r) { continue; } @@ -1369,10 +1369,6 @@ void update_particles_i(pixel *vid, int start, int inc) if (ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) - { - continue; - } if (!rt&&loverule[nnx][nny]==1) create_part(-1,nx+nnx,ny+nny,PT_LOVE); else if (!rt) @@ -1394,7 +1390,7 @@ void update_particles_i(pixel *vid, int start, int inc) for (nx=0; nx>8)>=NPART || !r) + if (!r) { continue; } @@ -1419,10 +1415,6 @@ void update_particles_i(pixel *vid, int start, int inc) if (ny+nny>0&&ny+nny=0&&nx+nnx>8)>=NPART) - { - continue; - } if (!rt&&lolzrule[nny][nnx]==1) create_part(-1,nx+nnx,ny+nny,PT_LOLZ); else if (!rt) @@ -1446,7 +1438,7 @@ void update_particles_i(pixel *vid, int start, int inc) for (ny=0; ny>8)>=NPART || !r) + if (!r) continue; if(parts[r>>8].type==PT_WIRE) parts[r>>8].tmp=parts[r>>8].ctype; @@ -1464,7 +1456,7 @@ void update_particles_i(pixel *vid, int start, int inc) for (ny=CELL; ny>8)>=NPART || !r) + if (!r) { gol[nx][ny] = 0; continue; @@ -1510,7 +1502,7 @@ void update_particles_i(pixel *vid, int start, int inc) { r = pmap[ny][nx]; neighbors = gol2[nx][ny][0]; - if (neighbors==0 || !((r&0xFF)==PT_LIFE || !(r&0xFF)) || (r>>8)>=NPART) + if (neighbors==0 || !((r&0xFF)==PT_LIFE || !(r&0xFF))) continue; for ( golnum = 1; golnum<=NGOL; golnum++) { @@ -1689,7 +1681,7 @@ void update_particles_i(pixel *vid, int start, int inc) { if (y-2 >= 0 && y-2 < YRES && (ptypes[t].properties&TYPE_LIQUID)) {//some heat convection for liquids r = pmap[y-2][x]; - if (!((r>>8)>=NPART || !r || parts[i].type != (r&0xFF))) { + if (!(!r || parts[i].type != (r&0xFF))) { if (parts[i].temp>parts[r>>8].temp) { swappage = parts[i].temp; parts[i].temp = parts[r>>8].temp; @@ -1720,7 +1712,7 @@ void update_particles_i(pixel *vid, int start, int inc) { surround_hconduct[j] = i; r = surround[j]; - if ((r>>8)>=NPART || !r) + if (!r) continue; rt = r&0xFF; if (rt&&ptypes[rt].hconduct&&(rt!=PT_HSWC||parts[r>>8].life==10) @@ -2423,16 +2415,15 @@ void update_particles(pixel *vid)//doesn't update the particles themselves, but else parts[lastPartUnused].life = parts_lastActiveIndex+1; } parts_lastActiveIndex = lastPartUsed; - for (y=0; y