From 208cf14ce81428332499fa7d4bd8110971d06e22 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Thu, 28 Dec 2017 13:00:23 -0500 Subject: [PATCH] convert r&0xFF in src/simulation/elements --- src/simulation/elements/ACEL.cpp | 2 +- src/simulation/elements/ACID.cpp | 15 ++++++++------- src/simulation/elements/AMTR.cpp | 2 +- src/simulation/elements/ANAR.cpp | 2 +- src/simulation/elements/ARAY.cpp | 4 ++-- src/simulation/elements/BANG.cpp | 2 +- src/simulation/elements/BCLN.cpp | 2 +- src/simulation/elements/BIZR.cpp | 2 +- src/simulation/elements/BMTL.cpp | 2 +- src/simulation/elements/BOMB.cpp | 2 +- src/simulation/elements/BOYL.cpp | 4 ++-- src/simulation/elements/BRMT.cpp | 2 +- src/simulation/elements/BTRY.cpp | 2 +- src/simulation/elements/C5.cpp | 2 +- src/simulation/elements/CAUS.cpp | 8 ++++---- src/simulation/elements/CBNW.cpp | 10 +++++----- src/simulation/elements/CLNE.cpp | 2 +- src/simulation/elements/CLST.cpp | 6 +++--- src/simulation/elements/CO2.cpp | 4 ++-- src/simulation/elements/CONV.cpp | 19 ++++++++++--------- src/simulation/elements/CRAY.cpp | 12 ++++++------ src/simulation/elements/DCEL.cpp | 2 +- src/simulation/elements/DEST.cpp | 13 ++++++++----- src/simulation/elements/DEUT.cpp | 4 ++-- src/simulation/elements/DLAY.cpp | 6 +++--- src/simulation/elements/DMG.cpp | 4 ++-- src/simulation/elements/DRAY.cpp | 2 +- src/simulation/elements/DTEC.cpp | 8 ++++---- src/simulation/elements/ELEC.cpp | 2 +- src/simulation/elements/EMBR.cpp | 2 +- src/simulation/elements/ETRD.cpp | 2 +- src/simulation/elements/EXOT.cpp | 4 ++-- src/simulation/elements/Element.cpp | 16 ++++++++-------- src/simulation/elements/FIRE.cpp | 4 ++-- src/simulation/elements/FIRW.cpp | 2 +- src/simulation/elements/FOG.cpp | 4 ++-- src/simulation/elements/FRAY.cpp | 4 ++-- src/simulation/elements/FRZW.cpp | 2 +- src/simulation/elements/FRZZ.cpp | 2 +- src/simulation/elements/FSEP.cpp | 2 +- src/simulation/elements/FUSE.cpp | 2 +- src/simulation/elements/GBMB.cpp | 6 +++--- src/simulation/elements/GEL.cpp | 2 +- src/simulation/elements/GLOW.cpp | 2 +- src/simulation/elements/GOLD.cpp | 4 ++-- src/simulation/elements/GPMP.cpp | 2 +- src/simulation/elements/H2.cpp | 2 +- src/simulation/elements/HEAC.cpp | 8 ++++---- src/simulation/elements/HSWC.cpp | 4 ++-- src/simulation/elements/ICEI.cpp | 4 ++-- src/simulation/elements/IGNT.cpp | 2 +- src/simulation/elements/IRON.cpp | 2 +- src/simulation/elements/LCRY.cpp | 2 +- src/simulation/elements/LIGH.cpp | 10 +++++----- src/simulation/elements/LSNS.cpp | 2 +- src/simulation/elements/MERC.cpp | 4 ++-- src/simulation/elements/O2.cpp | 4 ++-- src/simulation/elements/PBCN.cpp | 4 ++-- src/simulation/elements/PCLN.cpp | 6 +++--- src/simulation/elements/PHOT.cpp | 10 +++++----- src/simulation/elements/PIPE.cpp | 24 ++++++++++++------------ src/simulation/elements/PRTI.cpp | 12 ++++++------ src/simulation/elements/PSNS.cpp | 2 +- src/simulation/elements/PSTN.cpp | 14 +++++++------- src/simulation/elements/PUMP.cpp | 2 +- src/simulation/elements/PVOD.cpp | 4 ++-- src/simulation/elements/QRTZ.cpp | 4 ++-- src/simulation/elements/RIME.cpp | 4 ++-- src/simulation/elements/RPEL.cpp | 2 +- src/simulation/elements/SHLD1.cpp | 4 ++-- src/simulation/elements/SHLD2.cpp | 4 ++-- src/simulation/elements/SHLD3.cpp | 4 ++-- src/simulation/elements/SHLD4.cpp | 4 ++-- src/simulation/elements/SING.cpp | 4 ++-- src/simulation/elements/SLTW.cpp | 2 +- src/simulation/elements/SNOW.cpp | 2 +- src/simulation/elements/SOAP.cpp | 10 +++++----- src/simulation/elements/SPNG.cpp | 6 +++--- src/simulation/elements/SPRK.cpp | 4 ++-- src/simulation/elements/STKM.cpp | 24 ++++++++++++------------ src/simulation/elements/STOR.cpp | 6 +++--- src/simulation/elements/SWCH.cpp | 2 +- src/simulation/elements/THDR.cpp | 4 ++-- src/simulation/elements/TRON.cpp | 4 ++-- src/simulation/elements/TSNS.cpp | 8 ++++---- src/simulation/elements/TUNG.cpp | 2 +- src/simulation/elements/VIBR.cpp | 16 ++++++++-------- src/simulation/elements/VIRS.cpp | 10 +++++----- src/simulation/elements/WARP.cpp | 2 +- src/simulation/elements/WATR.cpp | 10 +++++----- src/simulation/elements/WIFI.cpp | 6 +++--- src/simulation/elements/WIRE.cpp | 6 +++--- src/simulation/elements/WTRV.cpp | 2 +- src/simulation/elements/YEST.cpp | 2 +- 94 files changed, 247 insertions(+), 242 deletions(-) diff --git a/src/simulation/elements/ACEL.cpp b/src/simulation/elements/ACEL.cpp index fa554c044d..cb2fdb52d0 100644 --- a/src/simulation/elements/ACEL.cpp +++ b/src/simulation/elements/ACEL.cpp @@ -69,7 +69,7 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if (!r) continue; - if(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) + if(sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) { parts[ID(r)].vx *= multiplier; parts[ID(r)].vy *= multiplier; diff --git a/src/simulation/elements/ACID.cpp b/src/simulation/elements/ACID.cpp index a81293342a..fe78351e8a 100644 --- a/src/simulation/elements/ACID.cpp +++ b/src/simulation/elements/ACID.cpp @@ -57,16 +57,17 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_ACID && (r&0xFF)!=PT_CAUS) + int rt = TYP(r); + if (rt != PT_ACID && rt != PT_CAUS) { - if ((r&0xFF)==PT_PLEX || (r&0xFF)==PT_NITR || (r&0xFF)==PT_GUNP || (r&0xFF)==PT_RBDM || (r&0xFF)==PT_LRBD) + if (rt == PT_PLEX || rt == PT_NITR || rt == PT_GUNP || rt == PT_RBDM || rt == PT_LRBD) { sim->part_change_type(i,x,y,PT_FIRE); sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE); parts[i].life = 4; parts[ID(r)].life = 4; } - else if ((r&0xFF)==PT_WTRV) + else if (rt == PT_WTRV) { if(!(rand()%250)) { @@ -75,11 +76,11 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) sim->kill_part(ID(r)); } } - else if (((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && sim->elements[r&0xFF].Hardness>(rand()%1000))&&parts[i].life>=50) + else if ((rt != PT_CLNE && rt != PT_PCLN && sim->elements[rt].Hardness>(rand()%1000))&&parts[i].life>=50) { if (sim->parts_avg(i, ID(r),PT_GLAS)!= PT_GLAS)//GLAS protects stuff from acid { - float newtemp = ((60.0f-(float)sim->elements[r&0xFF].Hardness))*7.0f; + float newtemp = ((60.0f-(float)sim->elements[rt].Hardness))*7.0f; if(newtemp < 0){ newtemp = 0; } @@ -104,10 +105,10 @@ int Element_ACID::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_ACID && (parts[i].life>parts[ID(r)].life) && parts[i].life>0)//diffusion + if (TYP(r) == PT_ACID && (parts[i].life > parts[ID(r)].life) && parts[i].life>0)//diffusion { int temp = parts[i].life - parts[ID(r)].life; - if (temp==1) + if (temp == 1) { parts[ID(r)].life++; parts[i].life--; diff --git a/src/simulation/elements/AMTR.cpp b/src/simulation/elements/AMTR.cpp index c7cc1e6751..740c29af95 100644 --- a/src/simulation/elements/AMTR.cpp +++ b/src/simulation/elements/AMTR.cpp @@ -56,7 +56,7 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_AMTR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_BHOL && rt!=PT_NBHL && rt!=PT_PRTI && rt!=PT_PRTO) { parts[i].life++; diff --git a/src/simulation/elements/ANAR.cpp b/src/simulation/elements/ANAR.cpp index ac501757b8..9c4b4c01dc 100644 --- a/src/simulation/elements/ANAR.cpp +++ b/src/simulation/elements/ANAR.cpp @@ -58,7 +58,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_CFLM && !(rand()%4)) + if (TYP(r)==PT_CFLM && !(rand()%4)) { sim->part_change_type(i,x,y,PT_CFLM); parts[i].life = rand()%150+50; diff --git a/src/simulation/elements/ARAY.cpp b/src/simulation/elements/ARAY.cpp index 322f6383fa..a613641e52 100644 --- a/src/simulation/elements/ARAY.cpp +++ b/src/simulation/elements/ARAY.cpp @@ -56,7 +56,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS) int r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3) + if (TYP(r) == PT_SPRK && parts[ID(r)].life == 3) { bool isBlackDeco = false; int destroy = (parts[ID(r)].ctype==PT_PSCN) ? 1 : 0; @@ -68,7 +68,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS) break; r = pmap[y+nyi+nyy][x+nxi+nxx]; - rt = r & 0xFF; + rt = TYP(r); r = ID(r); if (!rt) { diff --git a/src/simulation/elements/BANG.cpp b/src/simulation/elements/BANG.cpp index edf3a3f7f4..1dcbbe0b77 100644 --- a/src/simulation/elements/BANG.cpp +++ b/src/simulation/elements/BANG.cpp @@ -60,7 +60,7 @@ int Element_BANG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_FIRE || (r&0xFF)==PT_PLSM || (r&0xFF)==PT_SPRK || (r&0xFF)==PT_LIGH) + if (TYP(r)==PT_FIRE || TYP(r)==PT_PLSM || TYP(r)==PT_SPRK || TYP(r)==PT_LIGH) { parts[i].tmp = 1; } diff --git a/src/simulation/elements/BCLN.cpp b/src/simulation/elements/BCLN.cpp index c54c16e943..e344e3db36 100644 --- a/src/simulation/elements/BCLN.cpp +++ b/src/simulation/elements/BCLN.cpp @@ -68,7 +68,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_STKM && rt!=PT_PBCN && rt!=PT_STKM2 && diff --git a/src/simulation/elements/BIZR.cpp b/src/simulation/elements/BIZR.cpp index 59f39cdb88..a95306a9c3 100644 --- a/src/simulation/elements/BIZR.cpp +++ b/src/simulation/elements/BIZR.cpp @@ -60,7 +60,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS) + if (TYP(r)!=PT_BIZR && TYP(r)!=PT_BIZRG && TYP(r)!=PT_BIZRS) { tr = (parts[ID(r)].dcolour>>16)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF; diff --git a/src/simulation/elements/BMTL.cpp b/src/simulation/elements/BMTL.cpp index 68eb05b9a0..5518164832 100644 --- a/src/simulation/elements/BMTL.cpp +++ b/src/simulation/elements/BMTL.cpp @@ -58,7 +58,7 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_METL || (r&0xFF)==PT_IRON) && !(rand()%100)) + if ((TYP(r)==PT_METL || TYP(r)==PT_IRON) && !(rand()%100)) { sim->part_change_type(ID(r),x+rx,y+ry,PT_BMTL); parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100; diff --git a/src/simulation/elements/BOMB.cpp b/src/simulation/elements/BOMB.cpp index cc29d0851f..38ae777675 100644 --- a/src/simulation/elements/BOMB.cpp +++ b/src/simulation/elements/BOMB.cpp @@ -57,7 +57,7 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_BOMB && rt!=PT_EMBR && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_VIBR) { int rad = 8, nt; diff --git a/src/simulation/elements/BOYL.cpp b/src/simulation/elements/BOYL.cpp index 6baddcc260..7041ede4d0 100644 --- a/src/simulation/elements/BOYL.cpp +++ b/src/simulation/elements/BOYL.cpp @@ -68,12 +68,12 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR) + if (TYP(r)==PT_WATR) { if (!(rand()%30)) sim->part_change_type(ID(r),x+rx,y+ry,PT_FOG); } - else if ((r&0xFF)==PT_O2) + else if (TYP(r)==PT_O2) { if (!(rand()%9)) { diff --git a/src/simulation/elements/BRMT.cpp b/src/simulation/elements/BRMT.cpp index d39ca2194f..46ee6d91b5 100644 --- a/src/simulation/elements/BRMT.cpp +++ b/src/simulation/elements/BRMT.cpp @@ -60,7 +60,7 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_BREC && !(rand()%tempFactor)) + if (TYP(r)==PT_BREC && !(rand()%tempFactor)) { if(rand()%2) { diff --git a/src/simulation/elements/BTRY.cpp b/src/simulation/elements/BTRY.cpp index c25cb2b318..62b81c3a0f 100644 --- a/src/simulation/elements/BTRY.cpp +++ b/src/simulation/elements/BTRY.cpp @@ -55,7 +55,7 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = (r&0xFF); + rt = TYP(r); if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) diff --git a/src/simulation/elements/C5.cpp b/src/simulation/elements/C5.cpp index 1945ebff32..d810ccec1f 100644 --- a/src/simulation/elements/C5.cpp +++ b/src/simulation/elements/C5.cpp @@ -56,7 +56,7 @@ int Element_C5::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)!=PT_C5 && parts[ID(r)].temp<100 && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[ID(r)].life==10)) || (r&0xFF)==PT_CFLM) + if ((TYP(r)!=PT_C5 && parts[ID(r)].temp<100 && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10)) || TYP(r)==PT_CFLM) { if (!(rand()%6)) { diff --git a/src/simulation/elements/CAUS.cpp b/src/simulation/elements/CAUS.cpp index 1392278fb9..1802145e5f 100644 --- a/src/simulation/elements/CAUS.cpp +++ b/src/simulation/elements/CAUS.cpp @@ -54,7 +54,7 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS) int r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) == PT_GAS) + if (TYP(r) == PT_GAS) { if (sim->pv[(y+ry)/CELL][(x+rx)/CELL] > 3) { @@ -62,14 +62,14 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS) sim->part_change_type(i, x, y, PT_RFRG); } } - else if ((r&0xFF) != PT_ACID && (r&0xFF) != PT_CAUS && (r&0xFF) != PT_RFRG && (r&0xFF) != PT_RFGL) + else if (TYP(r) != PT_ACID && TYP(r) != PT_CAUS && TYP(r) != PT_RFRG && TYP(r) != PT_RFGL) { - if (((r&0xFF) != PT_CLNE && (r&0xFF) != PT_PCLN && sim->elements[r&0xFF].Hardness > (rand()%1000)) && parts[i].life >= 50) + if ((TYP(r) != PT_CLNE && TYP(r) != PT_PCLN && sim->elements[TYP(r)].Hardness > (rand()%1000)) && parts[i].life >= 50) { // GLAS protects stuff from acid if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS) { - float newtemp = ((60.0f - (float)sim->elements[r&0xFF].Hardness)) * 7.0f; + float newtemp = ((60.0f - (float)sim->elements[TYP(r)].Hardness)) * 7.0f; if (newtemp < 0) newtemp = 0; parts[i].temp += newtemp; diff --git a/src/simulation/elements/CBNW.cpp b/src/simulation/elements/CBNW.cpp index 8f1a449e29..7c8605a229 100644 --- a/src/simulation/elements/CBNW.cpp +++ b/src/simulation/elements/CBNW.cpp @@ -84,18 +84,18 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((sim->elements[r&0xFF].Properties&TYPE_PART) && parts[i].tmp == 0 && !(rand()%83)) + if ((sim->elements[TYP(r)].Properties&TYPE_PART) && parts[i].tmp == 0 && !(rand()%83)) { //Start explode parts[i].tmp = rand()%25;//(rand()%100)+50; } - else if((sim->elements[r&0xFF].Properties&TYPE_SOLID) && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%6667)) + else if((sim->elements[TYP(r)].Properties&TYPE_SOLID) && TYP(r)!=PT_DMND && TYP(r)!=PT_GLAS && parts[i].tmp == 0 && (2-sim->pv[y/CELL][x/CELL])>(rand()%6667)) { sim->part_change_type(i,x,y,PT_CO2); parts[i].ctype = 5; sim->pv[y/CELL][x/CELL] += 0.2f; } - if ((r&0xFF)==PT_CBNW) + if (TYP(r)==PT_CBNW) { if(!parts[i].tmp) { @@ -113,7 +113,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) parts[ID(r)].tmp++; } } - else if ((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) + else if (TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) { if ((sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%166)) { @@ -122,7 +122,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS) parts[i].ctype = PT_WATR; } } - else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ + else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ sim->kill_part(ID(r)); if(!(rand()%50)){ sim->kill_part(i); diff --git a/src/simulation/elements/CLNE.cpp b/src/simulation/elements/CLNE.cpp index 20f4c3bb18..8c42dce7e8 100644 --- a/src/simulation/elements/CLNE.cpp +++ b/src/simulation/elements/CLNE.cpp @@ -59,7 +59,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_STKM && rt!=PT_PBCN && rt!=PT_STKM2 && diff --git a/src/simulation/elements/CLST.cpp b/src/simulation/elements/CLST.cpp index 3bfe30c479..6a1c8c56bf 100644 --- a/src/simulation/elements/CLST.cpp +++ b/src/simulation/elements/CLST.cpp @@ -57,7 +57,7 @@ int Element_CLST::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR) + if (TYP(r)==PT_WATR) { if (!(rand()%1500)) { @@ -65,12 +65,12 @@ int Element_CLST::update(UPDATE_FUNC_ARGS) sim->kill_part(ID(r)); } } - else if ((r&0xFF)==PT_NITR) + else if (TYP(r)==PT_NITR) { sim->create_part(i, x, y, PT_BANG); sim->create_part(ID(r), x+rx, y+ry, PT_BANG); } - else if ((r&0xFF)==PT_CLST) + else if (TYP(r)==PT_CLST) { if(parts[i].temp <195) cxy = 0.05; diff --git a/src/simulation/elements/CO2.cpp b/src/simulation/elements/CO2.cpp index 72cf28f4be..f0e43b4895 100644 --- a/src/simulation/elements/CO2.cpp +++ b/src/simulation/elements/CO2.cpp @@ -62,14 +62,14 @@ int Element_CO2::update(UPDATE_FUNC_ARGS) } continue; } - if ((r&0xFF)==PT_FIRE){ + if (TYP(r)==PT_FIRE){ sim->kill_part(ID(r)); if(!(rand()%30)){ sim->kill_part(i); return 1; } } - else if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && !(rand()%50)) + else if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && !(rand()%50)) { sim->part_change_type(ID(r), x+rx, y+ry, PT_CBNW); if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet diff --git a/src/simulation/elements/CONV.cpp b/src/simulation/elements/CONV.cpp index 9ed0fde438..ac0e1a7560 100644 --- a/src/simulation/elements/CONV.cpp +++ b/src/simulation/elements/CONV.cpp @@ -60,13 +60,14 @@ int Element_CONV::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && - (r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && - (r&0xFF)!=PT_CONV && (r&0xFF)=0 && y+ry>=0 && x+rxphotons[y+ry][x+rx]; - if (!r || (restrictElement && (r&0xFF)!=restrictElement)) + if (!r || (restrictElement && TYP(r) != restrictElement)) r = pmap[y+ry][x+rx]; - if (!r || (restrictElement && (r&0xFF)!=restrictElement)) + if (!r || (restrictElement && TYP(r) != restrictElement)) continue; - if((r&0xFF)!=PT_CONV && (r&0xFF)!=PT_DMND && (r&0xFF)!=ctype) + if (TYP(r) != PT_CONV && TYP(r) != PT_DMND && TYP(r) != ctype) { sim->create_part(ID(r), x+rx, y+ry, parts[i].ctype&0xFF, ID(parts[i].ctype)); } diff --git a/src/simulation/elements/CRAY.cpp b/src/simulation/elements/CRAY.cpp index ea39ddaf72..509459733f 100644 --- a/src/simulation/elements/CRAY.cpp +++ b/src/simulation/elements/CRAY.cpp @@ -60,9 +60,9 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)kill_part(ID(r)); if(!--partsRemaining) docontinue = 0; diff --git a/src/simulation/elements/DCEL.cpp b/src/simulation/elements/DCEL.cpp index e043ecb2e2..be797cff8a 100644 --- a/src/simulation/elements/DCEL.cpp +++ b/src/simulation/elements/DCEL.cpp @@ -64,7 +64,7 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if (!r) continue; - if (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) + if (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) { parts[ID(r)].vx *= multiplier; parts[ID(r)].vy *= multiplier; diff --git a/src/simulation/elements/DEST.cpp b/src/simulation/elements/DEST.cpp index 859d96b8f1..739376ce02 100644 --- a/src/simulation/elements/DEST.cpp +++ b/src/simulation/elements/DEST.cpp @@ -51,7 +51,10 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) int rx = rand()%5-2; int ry = rand()%5-2; int r = pmap[y+ry][x+rx]; - if (!r || !BOUNDS_CHECK || (r&0xFF)==PT_DEST || (r&0xFF)==PT_DMND || (r&0xFF)==PT_BCLN || (r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN || (r&0xFF)==PT_PBCN) + if (!r) + return 0; + int rt = TYP(r); + if (rt == PT_DEST || rt == PT_DMND || rt == PT_BCLN || rt == PT_CLNE || rt == PT_PCLN || rt == PT_PBCN) return 0; if (parts[i].life<=0 || parts[i].life>37) @@ -59,7 +62,7 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) parts[i].life=30+rand()%20; sim->pv[y/CELL][x/CELL]+=60.0f; } - if ((r&0xFF)==PT_PLUT || (r&0xFF)==PT_DEUT) + if (rt == PT_PLUT || rt == PT_DEUT) { sim->pv[y/CELL][x/CELL]+=20.0f; if (rand()%2) @@ -70,18 +73,18 @@ int Element_DEST::update(UPDATE_FUNC_ARGS) parts[i].life-=4; } } - else if ((r&0xFF)==PT_INSL) + else if (rt == PT_INSL) { sim->create_part(ID(r), x+rx, y+ry, PT_PLSM); } else if (!(rand()%3)) { sim->kill_part(ID(r)); - parts[i].life -= 4*((sim->elements[r&0xFF].Properties&TYPE_SOLID)?3:1); + parts[i].life -= 4*((sim->elements[rt].Properties&TYPE_SOLID)?3:1); if (parts[i].life<=0) parts[i].life=1; } - else if (sim->elements[r&0xFF].HeatConduct) + else if (sim->elements[rt].HeatConduct) parts[ID(r)].temp = MAX_TEMP; parts[i].temp=MAX_TEMP; sim->pv[y/CELL][x/CELL]+=80.0f; diff --git a/src/simulation/elements/DEUT.cpp b/src/simulation/elements/DEUT.cpp index fea2cd04ca..cc9b97b989 100644 --- a/src/simulation/elements/DEUT.cpp +++ b/src/simulation/elements/DEUT.cpp @@ -65,7 +65,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r || (parts[i].life >=maxlife)) continue; - if ((r&0xFF)==PT_DEUT&& !(rand()%3)) + if (TYP(r)==PT_DEUT&& !(rand()%3)) { // If neighbour life+1 fits in the free capacity for this particle, absorb neighbour // Condition is written in this way so that large neighbour life values don't cause integer overflow @@ -105,7 +105,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_DEUT&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion + if (TYP(r)==PT_DEUT&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion { int temp = parts[i].life - parts[ID(r)].life; if (temp ==1) diff --git a/src/simulation/elements/DLAY.cpp b/src/simulation/elements/DLAY.cpp index addc47240d..9865659aed 100644 --- a/src/simulation/elements/DLAY.cpp +++ b/src/simulation/elements/DLAY.cpp @@ -61,11 +61,11 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL) continue; - if ((r&0xFF)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN) + if (TYP(r)==PT_SPRK && parts[i].life==0 && parts[ID(r)].life>0 && parts[ID(r)].life<4 && parts[ID(r)].ctype==PT_PSCN) { parts[i].life = (int)(parts[i].temp-273.15f+0.5f); } - else if ((r&0xFF)==PT_DLAY) + else if (TYP(r)==PT_DLAY) { if (!parts[i].life) { @@ -83,7 +83,7 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS) parts[ID(r)].life++; } } - else if((r&0xFF)==PT_NSCN && oldl==1) + else if(TYP(r)==PT_NSCN && oldl==1) { sim->create_part(-1, x+rx, y+ry, PT_SPRK); } diff --git a/src/simulation/elements/DMG.cpp b/src/simulation/elements/DMG.cpp index 76e146cbd3..47c8c79530 100644 --- a/src/simulation/elements/DMG.cpp +++ b/src/simulation/elements/DMG.cpp @@ -59,7 +59,7 @@ int Element_DMG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_DMG && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) + if (TYP(r)!=PT_DMG && TYP(r)!=PT_EMBR && TYP(r)!=PT_DMND && TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN && TYP(r)!=PT_BCLN) { sim->kill_part(i); for (nxj=-rad; nxj<=rad; nxj++) @@ -80,7 +80,7 @@ int Element_DMG::update(UPDATE_FUNC_ARGS) sim->vx[(y+nxj)/CELL][(x+nxi)/CELL] += fx; sim->vy[(y+nxj)/CELL][(x+nxi)/CELL] += fy; sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 1.0f; - t = rr&0xFF; + t = TYP(rr); if (t && sim->elements[t].HighPressureTransition>-1 && sim->elements[t].HighPressureTransitionpart_change_type(ID(rr), x+nxi, y+nxj, sim->elements[t].HighPressureTransition); else if (t == PT_BMTL) diff --git a/src/simulation/elements/DRAY.cpp b/src/simulation/elements/DRAY.cpp index b6f9f2e34d..36282f11c4 100644 --- a/src/simulation/elements/DRAY.cpp +++ b/src/simulation/elements/DRAY.cpp @@ -68,7 +68,7 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { int r = pmap[y+ry][x+rx]; - if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3) //spark found, start creating + if (TYP(r) == PT_SPRK && parts[ID(r)].life == 3) //spark found, start creating { bool overwrite = parts[ID(r)].ctype == PT_PSCN; int partsRemaining = copyLength, xCopyTo, yCopyTo; //positions where the line will start being copied at diff --git a/src/simulation/elements/DTEC.cpp b/src/simulation/elements/DTEC.cpp index baaf3d3ba5..f306026325 100644 --- a/src/simulation/elements/DTEC.cpp +++ b/src/simulation/elements/DTEC.cpp @@ -59,7 +59,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) @@ -82,9 +82,9 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if(!r) continue; - if ((r&0xFF) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[ID(r)].ctype || !parts[i].tmp)) + if (TYP(r) == parts[i].ctype && (parts[i].ctype != PT_LIFE || parts[i].tmp == parts[ID(r)].ctype || !parts[i].tmp)) parts[i].life = 1; - if ((r&0xFF) == PT_PHOT || ((r&0xFF) == PT_BRAY && parts[ID(r)].tmp!=2)) + if (TYP(r) == PT_PHOT || (TYP(r) == PT_BRAY && parts[ID(r)].tmp!=2)) { setFilt = true; photonWl = parts[ID(r)].ctype; @@ -102,7 +102,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS) continue; nx = x+rx; ny = y+ry; - while ((r&0xFF)==PT_FILT) + while (TYP(r)==PT_FILT) { parts[ID(r)].ctype = photonWl; nx += rx; diff --git a/src/simulation/elements/ELEC.cpp b/src/simulation/elements/ELEC.cpp index fd371991e7..85af13b4c1 100644 --- a/src/simulation/elements/ELEC.cpp +++ b/src/simulation/elements/ELEC.cpp @@ -57,7 +57,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); switch (rt) { case PT_GLAS: diff --git a/src/simulation/elements/EMBR.cpp b/src/simulation/elements/EMBR.cpp index 407b713df1..90dd4953e1 100644 --- a/src/simulation/elements/EMBR.cpp +++ b/src/simulation/elements/EMBR.cpp @@ -55,7 +55,7 @@ int Element_EMBR::update(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if ((sim->elements[r&0xFF].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[r&0xFF].Properties & PROP_SPARKSETTLE)) + if ((sim->elements[TYP(r)].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[TYP(r)].Properties & PROP_SPARKSETTLE)) { sim->kill_part(i); return 1; diff --git a/src/simulation/elements/ETRD.cpp b/src/simulation/elements/ETRD.cpp index 84b0343bd6..5c7980ff9a 100644 --- a/src/simulation/elements/ETRD.cpp +++ b/src/simulation/elements/ETRD.cpp @@ -119,7 +119,7 @@ int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId) if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance) { int r = sim->pmap[checkPos.Y][checkPos.X]; - if (r && (r&0xFF) == PT_ETRD && !parts[ID(r)].life && ID(r) != targetId && checkDistance < foundDistance) + if (r && TYP(r) == PT_ETRD && !parts[ID(r)].life && ID(r) != targetId && checkDistance < foundDistance) { foundDistance = checkDistance; foundI = ID(r); diff --git a/src/simulation/elements/EXOT.cpp b/src/simulation/elements/EXOT.cpp index 15312b8668..10cfaedb67 100644 --- a/src/simulation/elements/EXOT.cpp +++ b/src/simulation/elements/EXOT.cpp @@ -56,7 +56,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt == PT_WARP) { if (parts[ID(r)].tmp2>2000 && !(rand()%100)) @@ -138,7 +138,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_EXOT && (parts[i].tmp2 > parts[ID(r)].tmp2) && parts[ID(r)].tmp2 >= 0) //diffusion + if (TYP(r)==PT_EXOT && (parts[i].tmp2 > parts[ID(r)].tmp2) && parts[ID(r)].tmp2 >= 0) //diffusion { tym = parts[i].tmp2 - parts[ID(r)].tmp2; if (tym == 1) diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp index a243de19fb..42ee959ec3 100644 --- a/src/simulation/elements/Element.cpp +++ b/src/simulation/elements/Element.cpp @@ -99,12 +99,12 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_WATR||(r&0xFF)==PT_DSTW||(r&0xFF)==PT_SLTW) && 1>(rand()%1000)) + if ((TYP(r)==PT_WATR||TYP(r)==PT_DSTW||TYP(r)==PT_SLTW) && 1>(rand()%1000)) { sim->part_change_type(i,x,y,PT_WATR); sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR); } - if (((r&0xFF)==PT_ICEI || (r&0xFF)==PT_SNOW) && 1>(rand()%1000)) + if ((TYP(r)==PT_ICEI || TYP(r)==PT_SNOW) && 1>(rand()%1000)) { sim->part_change_type(i,x,y,PT_WATR); if (1>(rand()%1000)) @@ -121,7 +121,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10)) { sim->part_change_type(i,x,y,PT_WTRV); } @@ -136,7 +136,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10)) { if (rand()%4==0) sim->part_change_type(i,x,y,PT_SALT); else sim->part_change_type(i,x,y,PT_WTRV); @@ -152,7 +152,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_FIRE || (r&0xFF)==PT_LAVA) && 1>(rand()%10)) + if ((TYP(r)==PT_FIRE || TYP(r)==PT_LAVA) && 1>(rand()%10)) { sim->part_change_type(i,x,y,PT_WTRV); } @@ -166,7 +166,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) + if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(rand()%1000)) { sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI); @@ -181,12 +181,12 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) { r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 1>(rand()%1000)) + if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 1>(rand()%1000)) { sim->part_change_type(i,x,y,PT_ICEI); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI); } - if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW) && 15>(rand()%1000)) + if ((TYP(r)==PT_WATR || TYP(r)==PT_DSTW) && 15>(rand()%1000)) sim->part_change_type(i,x,y,PT_WATR); } } diff --git a/src/simulation/elements/FIRE.cpp b/src/simulation/elements/FIRE.cpp index 69053fa1f1..baead09f8b 100644 --- a/src/simulation/elements/FIRE.cpp +++ b/src/simulation/elements/FIRE.cpp @@ -93,7 +93,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); //THRM burning if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA)) @@ -184,7 +184,7 @@ int Element_FIRE::updateLegacy(UPDATE_FUNC_ARGS) { continue; if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) continue; - rt = r&0xFF; + rt = TYP(r); lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL]; if (lpv < 1) lpv = 1; diff --git a/src/simulation/elements/FIRW.cpp b/src/simulation/elements/FIRW.cpp index 9c31f02e73..82206c5163 100644 --- a/src/simulation/elements/FIRW.cpp +++ b/src/simulation/elements/FIRW.cpp @@ -61,7 +61,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) { float gx, gy, multiplier; diff --git a/src/simulation/elements/FOG.cpp b/src/simulation/elements/FOG.cpp index fed262c9dd..7beda1f6e4 100644 --- a/src/simulation/elements/FOG.cpp +++ b/src/simulation/elements/FOG.cpp @@ -55,11 +55,11 @@ int Element_FOG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((sim->elements[r&0xFF].Properties&TYPE_SOLID) && !(rand()%10) && parts[i].life==0 && !((r&0xFF)==PT_CLNE || (r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN? + if ((sim->elements[TYP(r)].Properties&TYPE_SOLID) && !(rand()%10) && parts[i].life==0 && !(TYP(r)==PT_CLNE || TYP(r)==PT_PCLN)) // TODO: should this also exclude BCLN? { sim->part_change_type(i,x,y,PT_RIME); } - if ((r&0xFF)==PT_SPRK) + if (TYP(r)==PT_SPRK) { parts[i].life += rand()%20; } diff --git a/src/simulation/elements/FRAY.cpp b/src/simulation/elements/FRAY.cpp index eed6713a55..abeb938faf 100644 --- a/src/simulation/elements/FRAY.cpp +++ b/src/simulation/elements/FRAY.cpp @@ -60,7 +60,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK) { + if (TYP(r)==PT_SPRK) { for (nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++) { if (!(x+nxi+nxx= 0 && y+nyi+nyy >= 0) || len>curlen) { break; @@ -68,7 +68,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS) r = pmap[y+nyi+nyy][x+nxi+nxx]; if (!r) r = sim->photons[y+nyi+nyy][x+nxi+nxx]; - if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)){ + if (r && !(sim->elements[TYP(r)].Properties & TYPE_SOLID)){ parts[ID(r)].vx += nxi*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += nyi*((parts[i].temp-273.15)/10.0f); } diff --git a/src/simulation/elements/FRZW.cpp b/src/simulation/elements/FRZW.cpp index fa9a735582..8129e0ed64 100644 --- a/src/simulation/elements/FRZW.cpp +++ b/src/simulation/elements/FRZW.cpp @@ -55,7 +55,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR && !(rand()%14)) + if (TYP(r)==PT_WATR && !(rand()%14)) { sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW); } diff --git a/src/simulation/elements/FRZZ.cpp b/src/simulation/elements/FRZZ.cpp index 373ba9f03f..354f43a158 100644 --- a/src/simulation/elements/FRZZ.cpp +++ b/src/simulation/elements/FRZZ.cpp @@ -55,7 +55,7 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR && !(rand()%20)) + if (TYP(r)==PT_WATR && !(rand()%20)) { sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW); parts[ID(r)].life = 100; diff --git a/src/simulation/elements/FSEP.cpp b/src/simulation/elements/FSEP.cpp index f5e1d8ff99..745869143b 100644 --- a/src/simulation/elements/FSEP.cpp +++ b/src/simulation/elements/FSEP.cpp @@ -70,7 +70,7 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && !(rand()%15)) + if ((TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+400.0f))) && parts[i].life>40 && !(rand()%15)) { parts[i].life = 39; } diff --git a/src/simulation/elements/FUSE.cpp b/src/simulation/elements/FUSE.cpp index 021fa0c069..c2041abbff 100644 --- a/src/simulation/elements/FUSE.cpp +++ b/src/simulation/elements/FUSE.cpp @@ -78,7 +78,7 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && !(rand()%20))) + if (TYP(r)==PT_SPRK || (parts[i].temp>=(273.15+700.0f) && !(rand()%20))) { if (parts[i].life > 40) parts[i].life = 39; diff --git a/src/simulation/elements/GBMB.cpp b/src/simulation/elements/GBMB.cpp index 08d3e60553..0b597cbdb4 100644 --- a/src/simulation/elements/GBMB.cpp +++ b/src/simulation/elements/GBMB.cpp @@ -59,9 +59,9 @@ int Element_GBMB::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if(!r) continue; - if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && - (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && - (r&0xFF)!=PT_DMND) + if(TYP(r)!=PT_BOMB && TYP(r)!=PT_GBMB && + TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN && + TYP(r)!=PT_DMND) { parts[i].life=60; break; diff --git a/src/simulation/elements/GEL.cpp b/src/simulation/elements/GEL.cpp index 9f3ea1f609..5655ff8258 100644 --- a/src/simulation/elements/GEL.cpp +++ b/src/simulation/elements/GEL.cpp @@ -62,7 +62,7 @@ int Element_GEL::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); //Desaturation switch (rt) { diff --git a/src/simulation/elements/GLOW.cpp b/src/simulation/elements/GLOW.cpp index a9cdaee577..b22c5e5bc7 100644 --- a/src/simulation/elements/GLOW.cpp +++ b/src/simulation/elements/GLOW.cpp @@ -56,7 +56,7 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_WATR && !(rand()%400)) + if (TYP(r)==PT_WATR && !(rand()%400)) { sim->kill_part(i); sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT); diff --git a/src/simulation/elements/GOLD.cpp b/src/simulation/elements/GOLD.cpp index ab19fb92fc..6a9d9c4056 100644 --- a/src/simulation/elements/GOLD.cpp +++ b/src/simulation/elements/GOLD.cpp @@ -62,7 +62,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS) if ((!rx != !ry) && BOUNDS_CHECK) { r = pmap[y+ry][x+rx]; if(!r) continue; - if((r&0xFF)==PT_BMTL && parts[ID(r)].tmp) + if(TYP(r)==PT_BMTL && parts[ID(r)].tmp) { parts[ID(r)].tmp = 0; sim->part_change_type(ID(r), x+rx, y+ry, PT_IRON); @@ -78,7 +78,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK) { r = pmap[y+ry][x+rx]; if(!r) continue; - if((r&0xFF)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4) + if(TYP(r)==PT_SPRK && parts[ID(r)].life && parts[ID(r)].life<4) { sim->part_change_type(i, x, y, PT_SPRK); parts[i].life = 4; diff --git a/src/simulation/elements/GPMP.cpp b/src/simulation/elements/GPMP.cpp index f61063c672..7555b93c5c 100644 --- a/src/simulation/elements/GPMP.cpp +++ b/src/simulation/elements/GPMP.cpp @@ -69,7 +69,7 @@ int Element_GPMP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_GPMP) + if (TYP(r)==PT_GPMP) { if (parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; diff --git a/src/simulation/elements/H2.cpp b/src/simulation/elements/H2.cpp index 985bf50045..1ca36ca1c5 100644 --- a/src/simulation/elements/H2.cpp +++ b/src/simulation/elements/H2.cpp @@ -55,7 +55,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = (r&0xFF); + rt = TYP(r); if (sim->pv[y/CELL][x/CELL] > 8.0f && rt == PT_DESL) // This will not work. DESL turns to fire above 5.0 pressure { sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR); diff --git a/src/simulation/elements/HEAC.cpp b/src/simulation/elements/HEAC.cpp index c1fda66aa5..c29a227c19 100644 --- a/src/simulation/elements/HEAC.cpp +++ b/src/simulation/elements/HEAC.cpp @@ -139,13 +139,13 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) { r = pmap[y+rry][x+rrx]; - if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10)) + if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) { count++; tempAgg += parts[ID(r)].temp; } r = sim->photons[y+rry][x+rrx]; - if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10)) + if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) { count++; tempAgg += parts[ID(r)].temp; @@ -167,12 +167,12 @@ int Element_HEAC::update(UPDATE_FUNC_ARGS) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine(sim, x, y, x+rrx, y+rry, isInsulator)) { r = pmap[y+rry][x+rrx]; - if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10)) + if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) { parts[ID(r)].temp = parts[i].temp; } r = sim->photons[y+rry][x+rrx]; - if (r && sim->elements[r&0xFF].HeatConduct > 0 && ((r&0xFF) != PT_HSWC || parts[ID(r)].life == 10)) + if (r && sim->elements[TYP(r)].HeatConduct > 0 && (TYP(r) != PT_HSWC || parts[ID(r)].life == 10)) { parts[ID(r)].temp = parts[i].temp; } diff --git a/src/simulation/elements/HSWC.cpp b/src/simulation/elements/HSWC.cpp index 75fc2061dc..a8cd7a3139 100644 --- a/src/simulation/elements/HSWC.cpp +++ b/src/simulation/elements/HSWC.cpp @@ -65,14 +65,14 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS) r = sim->photons[y + ry][x + rx]; if (!r) continue; - if ((r&0xFF)==PT_HSWC) + if (TYP(r)==PT_HSWC) { if (parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; else if (parts[ID(r)].life==0) parts[ID(r)].life = 10; } - if (parts[i].tmp == 1 && ((r&0xFF) == PT_FILT || (r&0xFF) == PT_PHOT || (r&0xFF) == PT_BRAY)) + if (parts[i].tmp == 1 && (TYP(r) == PT_FILT || TYP(r) == PT_PHOT || TYP(r) == PT_BRAY)) { parts[i].temp = parts[ID(r)].ctype - 0x10000000; } diff --git a/src/simulation/elements/ICEI.cpp b/src/simulation/elements/ICEI.cpp index 0a3a7f2ee2..b54a836a00 100644 --- a/src/simulation/elements/ICEI.cpp +++ b/src/simulation/elements/ICEI.cpp @@ -59,7 +59,7 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) + if (TYP(r)==PT_SALT || TYP(r)==PT_SLTW) { if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200)) { @@ -68,7 +68,7 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS) return 0; } } - else if (((r&0xFF)==PT_FRZZ) && !(rand()%200)) + else if ((TYP(r)==PT_FRZZ) && !(rand()%200)) { sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI); parts[ID(r)].ctype = PT_FRZW; diff --git a/src/simulation/elements/IGNT.cpp b/src/simulation/elements/IGNT.cpp index d50bd4eac9..74b987b596 100644 --- a/src/simulation/elements/IGNT.cpp +++ b/src/simulation/elements/IGNT.cpp @@ -57,7 +57,7 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt==PT_FIRE || rt==PT_PLSM || rt==PT_SPRK || rt==PT_LIGH || (rt==PT_IGNT && parts[ID(r)].life==1)) { parts[i].tmp = 1; diff --git a/src/simulation/elements/IRON.cpp b/src/simulation/elements/IRON.cpp index 2d6e3ec603..79517752af 100644 --- a/src/simulation/elements/IRON.cpp +++ b/src/simulation/elements/IRON.cpp @@ -55,7 +55,7 @@ int Element_IRON::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch (r&0xFF) + switch TYP(r) { case PT_SALT: if (!(rand()%47)) diff --git a/src/simulation/elements/LCRY.cpp b/src/simulation/elements/LCRY.cpp index fa7e25ba50..cdb3d7da4d 100644 --- a/src/simulation/elements/LCRY.cpp +++ b/src/simulation/elements/LCRY.cpp @@ -92,7 +92,7 @@ int Element_LCRY::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_LCRY && parts[ID(r)].tmp == check) + if (TYP(r)==PT_LCRY && parts[ID(r)].tmp == check) { parts[ID(r)].tmp = setto; } diff --git a/src/simulation/elements/LIGH.cpp b/src/simulation/elements/LIGH.cpp index 1f4db070eb..b254053253 100644 --- a/src/simulation/elements/LIGH.cpp +++ b/src/simulation/elements/LIGH.cpp @@ -85,7 +85,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if ((surround_space || sim->elements[rt].Explosive) && (rt!=PT_SPNG || parts[ID(r)].life==0) && sim->elements[rt].Flammable && (sim->elements[rt].Flammable + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]*10.0f))>(rand()%1000)) @@ -144,10 +144,10 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS) default: break; } - if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0) + if ((sim->elements[TYP(r)].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0) sim->create_part(ID(r),x+rx,y+ry,PT_SPRK); sim->pv[y/CELL][x/CELL] += powderful/400; - if (sim->elements[r&0xFF].HeatConduct) parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/1.3, MIN_TEMP, MAX_TEMP); + if (sim->elements[TYP(r)].HeatConduct) parts[ID(r)].temp = restrict_flt(parts[ID(r)].temp+powderful/1.3, MIN_TEMP, MAX_TEMP); } if (parts[i].tmp2==3) { @@ -259,7 +259,7 @@ int Element_LIGH::contact_part(Simulation * sim, int i, int tp) r = sim->pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==tp) + if (TYP(r)==tp) return ID(r); } return -1; @@ -287,7 +287,7 @@ bool Element_LIGH::create_LIGH(Simulation * sim, int x, int y, int c, int temp, else if (x >= 0 && x < XRES && y >= 0 && y < YRES) { int r = sim->pmap[y][x]; - if ((((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[ID(r)].life >= 10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==c)!=(sim->parts[ID(r)].tmp&1))) || (r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) // VOID, PVOD, VACU, and BHOL eat LIGH here + if (((TYP(r)==PT_VOID || (TYP(r)==PT_PVOD && sim->parts[ID(r)].life >= 10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==c)!=(sim->parts[ID(r)].tmp&1))) || TYP(r)==PT_BHOL || TYP(r)==PT_NBHL) // VOID, PVOD, VACU, and BHOL eat LIGH here return true; } else return true; diff --git a/src/simulation/elements/LSNS.cpp b/src/simulation/elements/LSNS.cpp index 9073663567..51b2de1288 100644 --- a/src/simulation/elements/LSNS.cpp +++ b/src/simulation/elements/LSNS.cpp @@ -59,7 +59,7 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) diff --git a/src/simulation/elements/MERC.cpp b/src/simulation/elements/MERC.cpp index 51af9effcb..e3d36a94ae 100644 --- a/src/simulation/elements/MERC.cpp +++ b/src/simulation/elements/MERC.cpp @@ -71,7 +71,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r || (parts[i].tmp >=maxtmp)) continue; - if ((r&0xFF)==PT_MERC&& !(rand()%3)) + if (TYP(r)==PT_MERC&& !(rand()%3)) { if ((parts[i].tmp + parts[ID(r)].tmp + 1) <= maxtmp) { @@ -108,7 +108,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_MERC&&(parts[i].tmp>parts[ID(r)].tmp)&&parts[i].tmp>0)//diffusion + if (TYP(r)==PT_MERC&&(parts[i].tmp>parts[ID(r)].tmp)&&parts[i].tmp>0)//diffusion { int temp = parts[i].tmp - parts[ID(r)].tmp; if (temp ==1) diff --git a/src/simulation/elements/O2.cpp b/src/simulation/elements/O2.cpp index 0bf08d3690..c5e4705d59 100644 --- a/src/simulation/elements/O2.cpp +++ b/src/simulation/elements/O2.cpp @@ -56,7 +56,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS) if (!r) continue; - if ((r&0xFF)==PT_FIRE) + if (TYP(r)==PT_FIRE) { parts[ID(r)].temp+=(rand()%100); if(parts[ID(r)].tmp&0x01) @@ -67,7 +67,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS) parts[i].temp+=(rand()%100); parts[i].tmp |= 2; } - else if ((r&0xFF)==PT_PLSM && !(parts[ID(r)].tmp&4)) + else if (TYP(r)==PT_PLSM && !(parts[ID(r)].tmp&4)) { sim->create_part(i,x,y,PT_FIRE); parts[i].temp+=(rand()%100); diff --git a/src/simulation/elements/PBCN.cpp b/src/simulation/elements/PBCN.cpp index 28afceeb78..004b459269 100644 --- a/src/simulation/elements/PBCN.cpp +++ b/src/simulation/elements/PBCN.cpp @@ -73,7 +73,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_SPRK && rt!=PT_NSCN && rt!=PT_PSCN && @@ -99,7 +99,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_PBCN) + if (TYP(r)==PT_PBCN) { if (parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; diff --git a/src/simulation/elements/PCLN.cpp b/src/simulation/elements/PCLN.cpp index 393d5f9f27..44b2721804 100644 --- a/src/simulation/elements/PCLN.cpp +++ b/src/simulation/elements/PCLN.cpp @@ -58,7 +58,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK) + if (TYP(r)==PT_SPRK) { if (parts[ID(r)].life>0 && parts[ID(r)].life<4) { @@ -68,7 +68,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) parts[i].life = 9; } } - else if ((r&0xFF)==PT_PCLN) + else if (TYP(r)==PT_PCLN) { if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; @@ -86,7 +86,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (rt!=PT_CLNE && rt!=PT_PCLN && rt!=PT_BCLN && rt!=PT_SPRK && rt!=PT_NSCN && rt!=PT_PSCN && diff --git a/src/simulation/elements/PHOT.cpp b/src/simulation/elements/PHOT.cpp index b65605d09b..17c65d02bc 100644 --- a/src/simulation/elements/PHOT.cpp +++ b/src/simulation/elements/PHOT.cpp @@ -62,7 +62,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS) + if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS) { if (!(rand()%400)) { @@ -70,7 +70,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) parts[i].vy *= 0.90; sim->create_part(ID(r), x+rx, y+ry, PT_PHOT); rrr = (rand()%360)*3.14159f/180.0f; - if ((r&0xFF) == PT_ISOZ) + if (TYP(r) == PT_ISOZ) rr = (rand()%128+128)/127.0f; else rr = (rand()%228+128)/127.0f; @@ -79,7 +79,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) sim->pv[y/CELL][x/CELL] -= 15.0f * CFDS; } } - else if(((r&0xFF) == PT_QRTZ || (r&0xFF) == PT_PQRT) && !ry && !rx)//if on QRTZ + else if((TYP(r) == PT_QRTZ || TYP(r) == PT_PQRT) && !ry && !rx)//if on QRTZ { float a = (rand()%360)*3.14159f/180.0f; parts[i].vx = 3.0f*cosf(a); @@ -89,7 +89,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) if (parts[i].life) parts[i].life++; //Delay death } - else if((r&0xFF) == PT_BGLA && !ry && !rx)//if on BGLA + else if(TYP(r) == PT_BGLA && !ry && !rx)//if on BGLA { float a = (rand()%101 - 50) * 0.001f; float rx = cosf(a), ry = sinf(a), vx, vy; @@ -98,7 +98,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS) parts[i].vx = vx; parts[i].vy = vy; } - else if ((r&0xFF) == PT_FILT && parts[ID(r)].tmp==9) + else if (TYP(r) == PT_FILT && parts[ID(r)].tmp==9) { parts[i].vx += ((float)(rand()%1000-500))/1000.0f; parts[i].vy += ((float)(rand()%1000-500))/1000.0f; diff --git a/src/simulation/elements/PIPE.cpp b/src/simulation/elements/PIPE.cpp index eba1f880e6..4f9da7dd00 100644 --- a/src/simulation/elements/PIPE.cpp +++ b/src/simulation/elements/PIPE.cpp @@ -101,7 +101,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - if ((r&0xFF) == PT_BRCK) + if (TYP(r) == PT_BRCK) { if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) parts[ID(r)].tmp = 0; @@ -146,7 +146,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[ID(r)].ctype==1) + if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP)&&parts[ID(r)].ctype==1) { parts[ID(r)].ctype = (((parts[i].ctype)%3)+2);//reverse parts[ID(r)].life = 6; @@ -160,7 +160,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) neighborcount ++; lastneighbor = ID(r); } - else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP)&&parts[ID(r)].ctype!=(((parts[i].ctype-1)%3)+2)) + else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP)&&parts[ID(r)].ctype!=(((parts[i].ctype-1)%3)+2)) { neighborcount ++; lastneighbor = ID(r); @@ -202,14 +202,14 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) } } //try eating particle at entrance - else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) + else if ((parts[i].tmp&0xFF) == 0 && (sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { - if ((r&0xFF)==PT_SOAP) + if (TYP(r)==PT_SOAP) Element_SOAP::detach(sim, ID(r)); transfer_part_to_pipe(parts+(ID(r)), parts+i); sim->kill_part(ID(r)); } - else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[ID(r)].tmp>0 && sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) + else if ((parts[i].tmp&0xFF) == 0 && TYP(r)==PT_STOR && parts[ID(r)].tmp>0 && sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { // STOR stores properties in the same places as PIPE does transfer_pipe_to_pipe(parts+(ID(r)), parts+i); @@ -258,7 +258,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && parts[i].ctype==1 && parts[i].life ) + if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && parts[i].ctype==1 && parts[i].life ) issingle = 0; } if (issingle) @@ -415,7 +415,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original r = sim->pmap[y+ry][x+rx]; if (!r) continue; - else if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0) + else if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0) { transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); if (ID(r) > original) @@ -423,7 +423,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original count++; pushParticle(sim, ID(r),count,original); } - else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase + else if (TYP(r) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase { int portaltmp = sim->parts[ID(r)].tmp; if (portaltmp >= CHANNELS) @@ -445,7 +445,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original { int coords = 7 - ((sim->parts[i].tmp>>10)&7); r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; - if (((r&0xFF)==PT_PIPE || (r&0xFF) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0) + if ((TYP(r)==PT_PIPE || TYP(r) == PT_PPIP) && sim->parts[ID(r)].ctype!=notctype && (sim->parts[ID(r)].tmp&0xFF)==0) { transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r))); if (ID(r) > original) @@ -453,7 +453,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original count++; pushParticle(sim, ID(r),count,original); } - else if ((r&0xFF) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase + else if (TYP(r) == PT_PRTI) //Pass particles into PRTI for a pipe speed increase { int portaltmp = sim->parts[ID(r)].tmp; if (portaltmp >= CHANNELS) @@ -468,7 +468,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original break; } } - else if ((r&0xFF) == PT_NONE) //Move particles out of pipe automatically, much faster at ends + else if (TYP(r) == PT_NONE) //Move particles out of pipe automatically, much faster at ends { rx = pos_1_rx[coords]; ry = pos_1_ry[coords]; diff --git a/src/simulation/elements/PRTI.cpp b/src/simulation/elements/PRTI.cpp index 0d6437a749..db1a7f29a1 100644 --- a/src/simulation/elements/PRTI.cpp +++ b/src/simulation/elements/PRTI.cpp @@ -71,25 +71,25 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { int r = pmap[y+ry][x+rx]; - if (!r || (r&0xFF) == PT_STOR) + if (!r || TYP(r) == PT_STOR) fe = 1; - if (!r || (!(sim->elements[r&0xFF].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && (r&0xFF)!=PT_SPRK && (r&0xFF)!=PT_STOR)) + if (!r || (!(sim->elements[TYP(r)].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY)) && TYP(r)!=PT_SPRK && TYP(r)!=PT_STOR)) { r = sim->photons[y+ry][x+rx]; if (!r) continue; } - if ((r&0xFF)==PT_STKM || (r&0xFF)==PT_STKM2 || (r&0xFF)==PT_FIGH) + if (TYP(r)==PT_STKM || TYP(r)==PT_STKM2 || TYP(r)==PT_FIGH) continue;// Handling these is a bit more complicated, and is done in STKM_interact() - if ((r&0xFF) == PT_SOAP) + if (TYP(r) == PT_SOAP) Element_SOAP::detach(sim, ID(r)); for (int nnx=0; nnx<80; nnx++) if (!sim->portalp[parts[i].tmp][count][nnx].type) { - if ((r&0xFF) == PT_STOR) + if (TYP(r) == PT_STOR) { if (sim->IsValidElement(parts[ID(r)].tmp) && (sim->elements[parts[ID(r)].tmp].Properties & (TYPE_PART | TYPE_LIQUID | TYPE_GAS | TYPE_ENERGY))) { @@ -101,7 +101,7 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS) else { sim->portalp[parts[i].tmp][count][nnx] = parts[ID(r)]; - if ((r&0xFF) == PT_SPRK) + if (TYP(r) == PT_SPRK) sim->part_change_type(ID(r),x+rx,y+ry,parts[ID(r)].ctype); else sim->kill_part(ID(r)); diff --git a/src/simulation/elements/PSNS.cpp b/src/simulation/elements/PSNS.cpp index e4ce0ee1d5..eb7a35be34 100644 --- a/src/simulation/elements/PSNS.cpp +++ b/src/simulation/elements/PSNS.cpp @@ -58,7 +58,7 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; + rt = TYP(r); if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt==PT_WATR||rt==PT_SLTW||rt==PT_NTCT||rt==PT_PTCT||rt==PT_INWR) && parts[ID(r)].life==0) diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 8744710278..5667fc2116 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -88,7 +88,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3) { + if (TYP(r)==PT_SPRK && parts[ID(r)].life==3) { if(parts[ID(r)].ctype == PT_PSCN) state = PISTON_EXTEND; else @@ -104,7 +104,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) == PT_PSTN) + if (TYP(r) == PT_PSTN) { bool movedPiston = false; bool foundEnd = false; @@ -119,7 +119,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) break; } r = pmap[y+nyy][x+nxx]; - if((r&0xFF)==PT_PSTN) + if(TYP(r)==PT_PSTN) { if(parts[ID(r)].life) armCount++; @@ -202,7 +202,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX, break; r = sim->pmap[posY][posX]; - if (sim->IsWallBlocking(posX, posY, 0) || (block && (r&0xFF) == block)) + if (sim->IsWallBlocking(posX, posY, 0) || (block && TYP(r) == block)) return StackData(currentPos - spaces, spaces); if (!r) { @@ -213,7 +213,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX, } else { - if (currentPos - spaces < maxSize && (!retract || ((r&0xFF) == PT_FRME && posX == stackX && posY == stackY))) + if (currentPos - spaces < maxSize && (!retract || (TYP(r) == PT_FRME && posX == stackX && posY == stackY))) tempParts[currentPos++] = ID(r); else return StackData(currentPos - spaces, spaces); @@ -227,7 +227,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct { int posX, posY, r; r = sim->pmap[stackY][stackX]; - if(!callDepth && (r&0xFF) == PT_FRME) { + if(!callDepth && TYP(r) == PT_FRME) { int newY = !!directionX, newX = !!directionY; int realDirectionX = retract?-directionX:directionX; int realDirectionY = retract?-directionY:directionY; @@ -289,7 +289,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct break; } r = sim->pmap[posY][posX]; - if(!r || (r&0xFF) == block || (!sticky && (r&0xFF) != PT_FRME)) { + if(!r || TYP(r) == block || (!sticky && TYP(r) != PT_FRME)) { break; } else { foundParts = true; diff --git a/src/simulation/elements/PUMP.cpp b/src/simulation/elements/PUMP.cpp index 4772904286..b05592e498 100644 --- a/src/simulation/elements/PUMP.cpp +++ b/src/simulation/elements/PUMP.cpp @@ -74,7 +74,7 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_PUMP) + if (TYP(r)==PT_PUMP) { if (parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; diff --git a/src/simulation/elements/PVOD.cpp b/src/simulation/elements/PVOD.cpp index d0262317a7..1d26a32f1b 100644 --- a/src/simulation/elements/PVOD.cpp +++ b/src/simulation/elements/PVOD.cpp @@ -58,7 +58,7 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK) + if (TYP(r)==PT_SPRK) { if (parts[ID(r)].life>0 && parts[ID(r)].life<4) { @@ -68,7 +68,7 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS) parts[i].life = 9; } } - else if ((r&0xFF)==PT_PVOD) + else if (TYP(r)==PT_PVOD) { if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0) parts[i].life = 9; diff --git a/src/simulation/elements/QRTZ.cpp b/src/simulation/elements/QRTZ.cpp index eeed7ae76e..f2d0ef464d 100644 --- a/src/simulation/elements/QRTZ.cpp +++ b/src/simulation/elements/QRTZ.cpp @@ -70,7 +70,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - else if ((r&0xFF)==PT_SLTW && !(rand()%500)) + else if (TYP(r)==PT_SLTW && !(rand()%500)) { sim->kill_part(ID(r)); parts[i].tmp++; @@ -122,7 +122,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - else if ((r&0xFF)==PT_QRTZ && (parts[i].tmp>parts[ID(r)].tmp) && parts[ID(r)].tmp>=0) + else if (TYP(r)==PT_QRTZ && (parts[i].tmp>parts[ID(r)].tmp) && parts[ID(r)].tmp>=0) { tmp = parts[i].tmp - parts[ID(r)].tmp; if (tmp ==1) diff --git a/src/simulation/elements/RIME.cpp b/src/simulation/elements/RIME.cpp index bccee90049..02d1f0b4b0 100644 --- a/src/simulation/elements/RIME.cpp +++ b/src/simulation/elements/RIME.cpp @@ -55,12 +55,12 @@ int Element_RIME::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK) + if (TYP(r)==PT_SPRK) { sim->part_change_type(i,x,y,PT_FOG); parts[i].life = rand()%50 + 60; } - else if ((r&0xFF)==PT_FOG&&parts[ID(r)].life>0) + else if (TYP(r)==PT_FOG&&parts[ID(r)].life>0) { sim->part_change_type(i,x,y,PT_FOG); parts[i].life = parts[ID(r)].life; diff --git a/src/simulation/elements/RPEL.cpp b/src/simulation/elements/RPEL.cpp index 924d6c6d59..062aa7e102 100644 --- a/src/simulation/elements/RPEL.cpp +++ b/src/simulation/elements/RPEL.cpp @@ -58,7 +58,7 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS) if (!r) r = sim->photons[y+ry][x+rx]; - if (r && !(sim->elements[r&0xFF].Properties & TYPE_SOLID)) { + if (r && !(sim->elements[TYP(r)].Properties & TYPE_SOLID)) { if (!parts[i].ctype || parts[i].ctype == parts[ID(r)].type) { parts[ID(r)].vx += isign(rx)*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); diff --git a/src/simulation/elements/SHLD1.cpp b/src/simulation/elements/SHLD1.cpp index c6b5859a36..b63d29cddb 100644 --- a/src/simulation/elements/SHLD1.cpp +++ b/src/simulation/elements/SHLD1.cpp @@ -55,7 +55,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + else if (TYP(r)==PT_SPRK&&parts[i].life==0) { if (11>rand()%40) { @@ -72,7 +72,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS) } } } - else if ((r&0xFF)==PT_SHLD3&&2>rand()%5) + else if (TYP(r)==PT_SHLD3&&2>rand()%5) { sim->part_change_type(i,x,y,PT_SHLD2); parts[i].life = 7; diff --git a/src/simulation/elements/SHLD2.cpp b/src/simulation/elements/SHLD2.cpp index 0e6e0982a6..360ef1e146 100644 --- a/src/simulation/elements/SHLD2.cpp +++ b/src/simulation/elements/SHLD2.cpp @@ -59,7 +59,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS) sim->create_part(-1,x+rx,y+ry,PT_SHLD1); continue; } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + else if (TYP(r)==PT_SPRK&&parts[i].life==0) { if (!(rand()%8)) { @@ -77,7 +77,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS) } } } - else if ((r&0xFF)==PT_SHLD4&&2>rand()%5) + else if (TYP(r)==PT_SHLD4&&2>rand()%5) { sim->part_change_type(i,x,y,PT_SHLD3); parts[i].life = 7; diff --git a/src/simulation/elements/SHLD3.cpp b/src/simulation/elements/SHLD3.cpp index 61a2648293..c5ad1c4ed6 100644 --- a/src/simulation/elements/SHLD3.cpp +++ b/src/simulation/elements/SHLD3.cpp @@ -64,12 +64,12 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS) } continue; } - if ((r&0xFF)==PT_SHLD1 && parts[i].life>3) + if (TYP(r)==PT_SHLD1 && parts[i].life>3) { sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD2); parts[ID(r)].life=7; } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + else if (TYP(r)==PT_SPRK&&parts[i].life==0) { if (3>rand()%500) { diff --git a/src/simulation/elements/SHLD4.cpp b/src/simulation/elements/SHLD4.cpp index 98e0e4d4ab..cb183f15c1 100644 --- a/src/simulation/elements/SHLD4.cpp +++ b/src/simulation/elements/SHLD4.cpp @@ -65,12 +65,12 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS) continue; } - if ((r&0xFF)==PT_SHLD2 && parts[i].life>3) + if (TYP(r)==PT_SHLD2 && parts[i].life>3) { sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD3); parts[ID(r)].life = 7; } - else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) + else if (TYP(r)==PT_SPRK&&parts[i].life==0) for ( nnx=-1; nnx<2; nnx++) for ( nny=-1; nny<2; nny++) { diff --git a/src/simulation/elements/SING.cpp b/src/simulation/elements/SING.cpp index 8d78826dd6..1c5982d56f 100644 --- a/src/simulation/elements/SING.cpp +++ b/src/simulation/elements/SING.cpp @@ -111,9 +111,9 @@ int Element_SING::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_DMND&& !(rand()%3)) + if (TYP(r)!=PT_DMND&& !(rand()%3)) { - if ((r&0xFF)==PT_SING && parts[ID(r)].life >10) + if (TYP(r)==PT_SING && parts[ID(r)].life >10) { if (parts[i].life+parts[ID(r)].life > 255) continue; diff --git a/src/simulation/elements/SLTW.cpp b/src/simulation/elements/SLTW.cpp index a0363e7519..01ce8b42fa 100644 --- a/src/simulation/elements/SLTW.cpp +++ b/src/simulation/elements/SLTW.cpp @@ -53,7 +53,7 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch (r&0xFF) + switch TYP(r) { case PT_SALT: if (!(rand()%2000)) diff --git a/src/simulation/elements/SNOW.cpp b/src/simulation/elements/SNOW.cpp index 62e7a7a616..7c066e8296 100644 --- a/src/simulation/elements/SNOW.cpp +++ b/src/simulation/elements/SNOW.cpp @@ -60,7 +60,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_SALT || (r&0xFF)==PT_SLTW) && !(rand()%333)) + if ((TYP(r)==PT_SALT || TYP(r)==PT_SLTW) && !(rand()%333)) { sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW); diff --git a/src/simulation/elements/SOAP.cpp b/src/simulation/elements/SOAP.cpp index 57e05f95e5..255031d1f1 100644 --- a/src/simulation/elements/SOAP.cpp +++ b/src/simulation/elements/SOAP.cpp @@ -163,14 +163,14 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) if (parts[i].temp>FREEZING) { if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] - || (r && !(sim->elements[r&0xFF].Properties&TYPE_GAS) - && (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS)) + || (r && !(sim->elements[TYP(r)].Properties&TYPE_GAS) + && TYP(r) != PT_SOAP && TYP(r) != PT_GLAS)) { detach(sim, i); continue; } } - if ((r&0xFF) == PT_SOAP) + if (TYP(r) == PT_SOAP) { if (parts[ID(r)].ctype == 1) { @@ -237,7 +237,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) == PT_OIL) + if (TYP(r) == PT_OIL) { float ax, ay; ax = (parts[i].vx*0.5f + parts[ID(r)].vx)/2; @@ -254,7 +254,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)!=PT_SOAP) + if (TYP(r)!=PT_SOAP) { tr = (parts[ID(r)].dcolour>>16)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF; diff --git a/src/simulation/elements/SPNG.cpp b/src/simulation/elements/SPNG.cpp index a0fdfc3831..281202df78 100644 --- a/src/simulation/elements/SPNG.cpp +++ b/src/simulation/elements/SPNG.cpp @@ -58,7 +58,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - switch (r&0xFF) + switch TYP(r) { case PT_WATR: case PT_DSTW: @@ -119,7 +119,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPNG&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion + if (TYP(r)==PT_SPNG&&(parts[i].life>parts[ID(r)].life)&&parts[i].life>0)//diffusion { tmp = parts[i].life - parts[ID(r)].life; if (tmp ==1) @@ -147,7 +147,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_FIRE) + if (TYP(r)==PT_FIRE) { tmp++; if (parts[ID(r)].life>60) diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp index 7652ab4923..daddb46cef 100644 --- a/src/simulation/elements/SPRK.cpp +++ b/src/simulation/elements/SPRK.cpp @@ -148,7 +148,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_WATR) + if (TYP(r)==PT_DSTW || TYP(r)==PT_SLTW || TYP(r)==PT_WATR) { int rnd = rand()%100; if (!rnd) @@ -172,7 +172,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - receiver = r&0xFF; + receiver = TYP(r); sender = ct; pavg = sim->parts_avg(ID(r), i,PT_INSL); //receiver is the element SPRK is trying to conduct to diff --git a/src/simulation/elements/STKM.cpp b/src/simulation/elements/STKM.cpp index 183128b1f3..de55943fc6 100644 --- a/src/simulation/elements/STKM.cpp +++ b/src/simulation/elements/STKM.cpp @@ -368,8 +368,8 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL]) continue; - STKM_set_element(sim, playerp, r&0xFF); - if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP + STKM_set_element(sim, playerp, TYP(r)); + if (TYP(r) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP { if (parts[i].life<=95) parts[i].life += 5; @@ -378,7 +378,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { sim->kill_part(ID(r)); } - if ((r&0xFF) == PT_NEUT) + if (TYP(r) == PT_NEUT) { if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2; else parts[i].life *= 0.9f; @@ -390,7 +390,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { playerp->rocketBoots = false; else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */) playerp->rocketBoots = true; - if ((r&0xFF)==PT_PRTI) + if (TYP(r)==PT_PRTI) Element_STKM::STKM_interact(sim, playerp, i, rx, ry); if (!parts[i].type)//STKM_interact may kill STKM return 1; @@ -405,7 +405,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) { { ry -= 2*(rand()%2)+1; r = pmap[ry][rx]; - if (sim->elements[r&0xFF].Properties&TYPE_SOLID) + if (sim->elements[TYP(r)].Properties&TYPE_SOLID) { sim->create_part(-1, rx, ry, PT_SPRK); playerp->frames = 0; @@ -578,18 +578,18 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int r = sim->pmap[y][x]; if (r) { - if ((r&0xFF)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge + if (TYP(r)==PT_SPRK && playerp->elem!=PT_LIGH) //If on charge { sim->parts[i].life -= (int)(rand()*20/RAND_MAX)+32; } - if (sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||sim->parts[ID(r)].life==10) && ((playerp->elem!=PT_LIGH && sim->parts[ID(r)].temp>=323) || sim->parts[ID(r)].temp<=243) && (!playerp->rocketBoots || (r&0xFF)!=PT_PLSM)) + if (sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||sim->parts[ID(r)].life==10) && ((playerp->elem!=PT_LIGH && sim->parts[ID(r)].temp>=323) || sim->parts[ID(r)].temp<=243) && (!playerp->rocketBoots || TYP(r)!=PT_PLSM)) { sim->parts[i].life -= 2; playerp->accs[3] -= 1; } - if (sim->elements[r&0xFF].Properties&PROP_DEADLY) + if (sim->elements[TYP(r)].Properties&PROP_DEADLY) switch (r&0xFF) { case PT_ACID: @@ -600,10 +600,10 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int break; } - if (sim->elements[r&0xFF].Properties&PROP_RADIOACTIVE) + if (sim->elements[TYP(r)].Properties&PROP_RADIOACTIVE) sim->parts[i].life -= 1; - if ((r&0xFF)==PT_PRTI && sim->parts[i].type) + if (TYP(r)==PT_PRTI && sim->parts[i].type) { int nnx, count=1;//gives rx=0, ry=1 in update_PRTO sim->parts[ID(r)].tmp = (int)((sim->parts[ID(r)].temp-73.15f)/100+1); @@ -621,7 +621,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int break; } } - if (((r&0xFF)==PT_BHOL || (r&0xFF)==PT_NBHL) && sim->parts[i].type) + if ((TYP(r)==PT_BHOL || TYP(r)==PT_NBHL) && sim->parts[i].type) { if (!sim->legacy_enable) { @@ -629,7 +629,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int } sim->kill_part(i); } - if (((r&0xFF)==PT_VOID || ((r&0xFF)==PT_PVOD && sim->parts[ID(r)].life==10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==sim->parts[i].type)!=(sim->parts[ID(r)].tmp&1)) && sim->parts[i].type) + if ((TYP(r)==PT_VOID || (TYP(r)==PT_PVOD && sim->parts[ID(r)].life==10)) && (!sim->parts[ID(r)].ctype || (sim->parts[ID(r)].ctype==sim->parts[i].type)!=(sim->parts[ID(r)].tmp&1)) && sim->parts[i].type) { sim->kill_part(i); } diff --git a/src/simulation/elements/STOR.cpp b/src/simulation/elements/STOR.cpp index dbd98e5419..e3bcc2730a 100644 --- a/src/simulation/elements/STOR.cpp +++ b/src/simulation/elements/STOR.cpp @@ -60,9 +60,9 @@ int Element_STOR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if ((ID(r))>=NPART || !r) continue; - if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && !(sim->elements[(r&0xFF)].Properties&TYPE_SOLID) && (!parts[i].ctype || (r&0xFF)==parts[i].ctype)) + if (!parts[i].tmp && !parts[i].life && TYP(r)!=PT_STOR && !(sim->elements[TYP(r)].Properties&TYPE_SOLID) && (!parts[i].ctype || TYP(r)==parts[i].ctype)) { - if ((r&0xFF) == PT_SOAP) + if (TYP(r) == PT_SOAP) Element_SOAP::detach(sim, ID(r)); parts[i].tmp = parts[ID(r)].type; parts[i].temp = parts[ID(r)].temp; @@ -71,7 +71,7 @@ int Element_STOR::update(UPDATE_FUNC_ARGS) parts[i].pavg[1] = parts[ID(r)].ctype; sim->kill_part(ID(r)); } - if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[ID(r)].ctype==PT_PSCN && parts[ID(r)].life>0 && parts[ID(r)].life<4) + if(parts[i].tmp && TYP(r)==PT_SPRK && parts[ID(r)].ctype==PT_PSCN && parts[ID(r)].life>0 && parts[ID(r)].life<4) { for(ry1 = 1; ry1 >= -1; ry1--){ for(rx1 = 0; rx1 >= -1 && rx1 <= 1; rx1 = -rx1-rx1+1){ // Oscillate the X starting at 0, 1, -1, 3, -5, etc (Though stop at -1) diff --git a/src/simulation/elements/SWCH.cpp b/src/simulation/elements/SWCH.cpp index a520cd8db7..8d4d0038e8 100644 --- a/src/simulation/elements/SWCH.cpp +++ b/src/simulation/elements/SWCH.cpp @@ -64,7 +64,7 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS) if (!r) continue; if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) { - rt = r&0xFF; + rt = TYP(r); if (rt==PT_SWCH) { if (parts[i].life>=10&&parts[ID(r)].life<10&&parts[ID(r)].life>0) diff --git a/src/simulation/elements/THDR.cpp b/src/simulation/elements/THDR.cpp index a9bd61f464..e1aaa53622 100644 --- a/src/simulation/elements/THDR.cpp +++ b/src/simulation/elements/THDR.cpp @@ -57,8 +57,8 @@ int Element_THDR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - rt = r&0xFF; - if ((sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[ID(r)].ctype!=PT_SPRK) + rt = TYP(r); + if ((sim->elements[TYP(r)].Properties&PROP_CONDUCTS) && parts[ID(r)].life==0 && !(rt==PT_WATR||rt==PT_SLTW) && parts[ID(r)].ctype!=PT_SPRK) { parts[ID(r)].ctype = parts[ID(r)].type; sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); diff --git a/src/simulation/elements/TRON.cpp b/src/simulation/elements/TRON.cpp index c25453bcd5..92a5884ddd 100644 --- a/src/simulation/elements/TRON.cpp +++ b/src/simulation/elements/TRON.cpp @@ -258,9 +258,9 @@ int Element_TRON::trymovetron(Simulation * sim, int x, int y, int dir, int i, in //#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len) bool Element_TRON::canmovetron(Simulation * sim, int r, int len) { - if (!r || ((r&0xFF) == PT_SWCH && sim->parts[ID(r)].life >= 10) || ((r&0xFF) == PT_INVIS && sim->parts[ID(r)].tmp2 == 1)) + if (!r || (TYP(r) == PT_SWCH && sim->parts[ID(r)].life >= 10) || (TYP(r) == PT_INVIS && sim->parts[ID(r)].tmp2 == 1)) return true; - if ((((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL_DEC) && sim->parts[ID(r)].life > 0)|| ((sim->elements[r&0xFF].Properties & PROP_LIFE_KILL) && (sim->elements[r&0xFF].Properties & PROP_LIFE_DEC))) && sim->parts[ID(r)].life < len) + if ((((sim->elements[TYP(r)].Properties & PROP_LIFE_KILL_DEC) && sim->parts[ID(r)].life > 0)|| ((sim->elements[TYP(r)].Properties & PROP_LIFE_KILL) && (sim->elements[TYP(r)].Properties & PROP_LIFE_DEC))) && sim->parts[ID(r)].life < len) return true; return false; } diff --git a/src/simulation/elements/TSNS.cpp b/src/simulation/elements/TSNS.cpp index 1d4792c9a0..4fd5709bbb 100644 --- a/src/simulation/elements/TSNS.cpp +++ b/src/simulation/elements/TSNS.cpp @@ -60,7 +60,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) int r = pmap[y+ry][x+rx]; if (!r) continue; - int rt = r&0xFF; + int rt = TYP(r); if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL) { if ((sim->elements[rt].Properties&PROP_CONDUCTS) && !(rt == PT_WATR || rt == PT_SLTW || rt == PT_NTCT || rt == PT_PTCT || rt == PT_INWR) && parts[ID(r)].life == 0) @@ -83,9 +83,9 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) r = sim->photons[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF) != PT_TSNS && (r&0xFF) != PT_METL && parts[ID(r)].temp > parts[i].temp) + if (TYP(r) != PT_TSNS && TYP(r) != PT_METL && parts[ID(r)].temp > parts[i].temp) parts[i].life = 1; - if (parts[i].tmp == 1 && (r&0xFF) != PT_TSNS && (r&0xFF) != PT_FILT) + if (parts[i].tmp == 1 && TYP(r) != PT_TSNS && TYP(r) != PT_FILT) { setFilt = true; photonWl = parts[ID(r)].temp; @@ -103,7 +103,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS) continue; nx = x + rx; ny = y + ry; - while ((r & 0xFF) == PT_FILT) + while (TYP(r) == PT_FILT) { parts[ID(r)].ctype = 0x10000000 + photonWl; nx += rx; diff --git a/src/simulation/elements/TUNG.cpp b/src/simulation/elements/TUNG.cpp index 5be67b9e52..5303da0a54 100644 --- a/src/simulation/elements/TUNG.cpp +++ b/src/simulation/elements/TUNG.cpp @@ -60,7 +60,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS) if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - if((r&0xFF) == PT_O2) + if(TYP(r) == PT_O2) { splode = true; } diff --git a/src/simulation/elements/VIBR.cpp b/src/simulation/elements/VIBR.cpp index 4676719359..f3a8b4fe09 100644 --- a/src/simulation/elements/VIBR.cpp +++ b/src/simulation/elements/VIBR.cpp @@ -87,10 +87,10 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { ry = (rndstore>>2)%3-1; rndstore = rndstore >> 4; r = pmap[y+ry][x+rx]; - if ((r&0xFF) && (r&0xFF) != PT_BREC && (sim->elements[r&0xFF].Properties&PROP_CONDUCTS) && !parts[ID(r)].life) + if (TYP(r) && TYP(r) != PT_BREC && (sim->elements[TYP(r)].Properties&PROP_CONDUCTS) && !parts[ID(r)].life) { parts[ID(r)].life = 4; - parts[ID(r)].ctype = r&0xFF; + parts[ID(r)].ctype = TYP(r); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); } } @@ -102,7 +102,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { if(BOUNDS_CHECK) { r = pmap[y+ry][x+rx]; - if ((r&0xFF) && (r&0xFF)!=PT_VIBR && (r&0xFF)!=PT_BVBR && sim->elements[r&0xFF].HeatConduct && ((r&0xFF)!=PT_HSWC||parts[ID(r)].life==10)) + if (TYP(r) && TYP(r)!=PT_VIBR && TYP(r)!=PT_BVBR && sim->elements[TYP(r)].HeatConduct && (TYP(r)!=PT_HSWC||parts[ID(r)].life==10)) { parts[ID(r)].temp += parts[i].tmp*3; parts[i].tmp = 0; @@ -152,7 +152,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { if (parts[i].life) { //Makes EXOT around it get tmp to start exploding too - if (((r&0xFF)==PT_VIBR || (r&0xFF)==PT_BVBR)) + if ((TYP(r)==PT_VIBR || TYP(r)==PT_BVBR)) { if (!parts[ID(r)].life) parts[ID(r)].tmp += 45; @@ -162,7 +162,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { parts[i].tmp = 0; } } - else if ((r&0xFF)==PT_CFLM) + else if (TYP(r)==PT_CFLM) { parts[i].tmp2 = 1; parts[i].tmp = 0; @@ -171,14 +171,14 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { else { //Melts into EXOT - if ((r&0xFF) == PT_EXOT && !(rand()%25)) + if (TYP(r) == PT_EXOT && !(rand()%25)) { sim->part_change_type(i, x, y, PT_EXOT); return 1; } } //VIBR+ANAR=BVBR - if (parts[i].type != PT_BVBR && (r&0xFF) == PT_ANAR) + if (parts[i].type != PT_BVBR && TYP(r) == PT_ANAR) { sim->part_change_type(i,x,y,PT_BVBR); sim->pv[y/CELL][x/CELL] -= 1; @@ -195,7 +195,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) { if (BOUNDS_CHECK && (rx || ry)) { r = pmap[y+ry][x+rx]; - if ((r&0xFF) != PT_VIBR && (r&0xFF) != PT_BVBR) + if (TYP(r) != PT_VIBR && TYP(r) != PT_BVBR) continue; if (parts[i].tmp > parts[ID(r)].tmp) { diff --git a/src/simulation/elements/VIRS.cpp b/src/simulation/elements/VIRS.cpp index fa23c2ce07..6da928eeb7 100644 --- a/src/simulation/elements/VIRS.cpp +++ b/src/simulation/elements/VIRS.cpp @@ -86,20 +86,20 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) continue; //spread "being cured" state - if (parts[ID(r)].pavg[0] && ((r&0xFF) == PT_VIRS || (r&0xFF) == PT_VRSS || (r&0xFF) == PT_VRSG)) + if (parts[ID(r)].pavg[0] && (TYP(r) == PT_VIRS || TYP(r) == PT_VRSS || TYP(r) == PT_VRSG)) { parts[i].pavg[0] = parts[ID(r)].pavg[0] + ((rndstore & 0x3) ? 2:1); return 0; } //soap cures virus - else if ((r&0xFF) == PT_SOAP) + else if (TYP(r) == PT_SOAP) { parts[i].pavg[0] += 10; if (!(rndstore & 0x3)) sim->kill_part(ID(r)); return 0; } - else if ((r&0xFF) == PT_PLSM) + else if (TYP(r) == PT_PLSM) { if (surround_space && 10 + (int)(sim->pv[(y+ry)/CELL][(x+rx)/CELL]) > (rand()%100)) { @@ -108,11 +108,11 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS) } } //transforms things into virus here - else if ((r&0xFF) != PT_VIRS && (r&0xFF) != PT_VRSS && (r&0xFF) != PT_VRSG && (r&0xFF) != PT_DMND) + else if (TYP(r) != PT_VIRS && TYP(r) != PT_VRSS && TYP(r) != PT_VRSG && TYP(r) != PT_DMND) { if (!(rndstore & 0x7)) { - parts[ID(r)].tmp2 = (r&0xFF); + parts[ID(r)].tmp2 = TYP(r); parts[ID(r)].pavg[0] = 0; if (parts[i].pavg[1]) parts[ID(r)].pavg[1] = parts[i].pavg[1] + 1; diff --git a/src/simulation/elements/WARP.cpp b/src/simulation/elements/WARP.cpp index c9a3093e69..698b6a331b 100644 --- a/src/simulation/elements/WARP.cpp +++ b/src/simulation/elements/WARP.cpp @@ -65,7 +65,7 @@ int Element_WARP::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; 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) + if (TYP(r)!=PT_WARP&&TYP(r)!=PT_STKM&&TYP(r)!=PT_STKM2&&TYP(r)!=PT_DMND&&TYP(r)!=PT_CLNE&&TYP(r)!=PT_BCLN&&TYP(r)!=PT_PCLN) { parts[i].x = parts[ID(r)].x; parts[i].y = parts[ID(r)].y; diff --git a/src/simulation/elements/WATR.cpp b/src/simulation/elements/WATR.cpp index d55a06d9d7..92d83e42d6 100644 --- a/src/simulation/elements/WATR.cpp +++ b/src/simulation/elements/WATR.cpp @@ -55,31 +55,31 @@ int Element_WATR::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SALT && !(rand()%50)) + if (TYP(r)==PT_SALT && !(rand()%50)) { sim->part_change_type(i,x,y,PT_SLTW); // on average, convert 3 WATR to SLTW before SALT turns into SLTW if (!(rand()%3)) sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW); } - else if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100)) + else if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && (sim->legacy_enable||parts[i].temp>(273.15f+12.0f)) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; parts[i].ctype = PT_WATR; } - else if ((r&0xFF)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ + else if (TYP(r)==PT_FIRE && parts[ID(r)].ctype!=PT_WATR){ sim->kill_part(ID(r)); if(!(rand()%30)){ sim->kill_part(i); return 1; } } - else if ((r&0xFF)==PT_SLTW && !(rand()%2000)) + else if (TYP(r)==PT_SLTW && !(rand()%2000)) { sim->part_change_type(i,x,y,PT_SLTW); } - /*if ((r&0xFF)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular + /*if (TYP(r)==PT_CNCT && !(rand()%100)) Concrete+Water to paste, not very popular { part_change_type(i,x,y,PT_PSTE); sim.kill_part(ID(r)); diff --git a/src/simulation/elements/WIFI.cpp b/src/simulation/elements/WIFI.cpp index ff677c8583..c3ab4d1062 100644 --- a/src/simulation/elements/WIFI.cpp +++ b/src/simulation/elements/WIFI.cpp @@ -63,14 +63,14 @@ int Element_WIFI::update(UPDATE_FUNC_ARGS) // wireless[][1] - whether channel should be active on next frame if (sim->wireless[parts[i].tmp][0]) { - if (((r&0xFF)==PT_NSCN||(r&0xFF)==PT_PSCN||(r&0xFF)==PT_INWR)&&parts[ID(r)].life==0 && sim->wireless[parts[i].tmp][0]) + if ((TYP(r)==PT_NSCN||TYP(r)==PT_PSCN||TYP(r)==PT_INWR)&&parts[ID(r)].life==0 && sim->wireless[parts[i].tmp][0]) { - parts[ID(r)].ctype = r&0xFF; + parts[ID(r)].ctype = TYP(r); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); parts[ID(r)].life = 4; } } - if ((r&0xFF)==PT_SPRK && parts[ID(r)].ctype!=PT_NSCN && parts[ID(r)].life>=3) + if (TYP(r)==PT_SPRK && parts[ID(r)].ctype!=PT_NSCN && parts[ID(r)].life>=3) { sim->wireless[parts[i].tmp][1] = 1; sim->ISWIRE = 2; diff --git a/src/simulation/elements/WIRE.cpp b/src/simulation/elements/WIRE.cpp index 78d455bd58..15434161cb 100644 --- a/src/simulation/elements/WIRE.cpp +++ b/src/simulation/elements/WIRE.cpp @@ -74,14 +74,14 @@ int Element_WIRE::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_SPRK && parts[ID(r)].life==3 && parts[ID(r)].ctype==PT_PSCN) + if (TYP(r)==PT_SPRK && parts[ID(r)].life==3 && parts[ID(r)].ctype==PT_PSCN) { parts[i].ctype=1; return 0; } - else if ((r&0xFF)==PT_NSCN && parts[i].tmp==1) + else if (TYP(r)==PT_NSCN && parts[i].tmp==1) sim->create_part(-1, x+rx, y+ry, PT_SPRK); - else if ((r&0xFF)==PT_WIRE && parts[ID(r)].tmp==1 && !parts[i].tmp) + else if (TYP(r)==PT_WIRE && parts[ID(r)].tmp==1 && !parts[i].tmp) count++; } } diff --git a/src/simulation/elements/WTRV.cpp b/src/simulation/elements/WTRV.cpp index 3fe7718ce3..f0152de661 100644 --- a/src/simulation/elements/WTRV.cpp +++ b/src/simulation/elements/WTRV.cpp @@ -55,7 +55,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if (((r&0xFF)==PT_RBDM||(r&0xFF)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%100)) + if ((TYP(r)==PT_RBDM||TYP(r)==PT_LRBD) && !sim->legacy_enable && parts[i].temp>(273.15f+12.0f) && !(rand()%100)) { sim->part_change_type(i,x,y,PT_FIRE); parts[i].life = 4; diff --git a/src/simulation/elements/YEST.cpp b/src/simulation/elements/YEST.cpp index 48b4c08161..92584d05c8 100644 --- a/src/simulation/elements/YEST.cpp +++ b/src/simulation/elements/YEST.cpp @@ -55,7 +55,7 @@ int Element_YEST::update(UPDATE_FUNC_ARGS) r = pmap[y+ry][x+rx]; if (!r) continue; - if ((r&0xFF)==PT_DYST && !(rand()%6) && !sim->legacy_enable) + if (TYP(r)==PT_DYST && !(rand()%6) && !sim->legacy_enable) { sim->part_change_type(i,x,y,PT_DYST); }