convert r&0xFF in src/simulation/elements

This commit is contained in:
jacob1 2017-12-28 13:00:23 -05:00
parent 4b1c929f58
commit 208cf14ce8
94 changed files with 247 additions and 242 deletions

View File

@ -69,7 +69,7 @@ int Element_ACEL::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; 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)].vx *= multiplier;
parts[ID(r)].vy *= multiplier; parts[ID(r)].vy *= multiplier;

View File

@ -57,16 +57,17 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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(i,x,y,PT_FIRE);
sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE); sim->part_change_type(ID(r),x+rx,y+ry,PT_FIRE);
parts[i].life = 4; parts[i].life = 4;
parts[ID(r)].life = 4; parts[ID(r)].life = 4;
} }
else if ((r&0xFF)==PT_WTRV) else if (rt == PT_WTRV)
{ {
if(!(rand()%250)) if(!(rand()%250))
{ {
@ -75,11 +76,11 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
sim->kill_part(ID(r)); 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 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){ if(newtemp < 0){
newtemp = 0; newtemp = 0;
} }
@ -104,7 +105,7 @@ int Element_ACID::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; int temp = parts[i].life - parts[ID(r)].life;
if (temp == 1) if (temp == 1)

View File

@ -56,7 +56,7 @@ int Element_AMTR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) 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++; parts[i].life++;

View File

@ -58,7 +58,7 @@ int Element_ANAR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_CFLM && !(rand()%4)) if (TYP(r)==PT_CFLM && !(rand()%4))
{ {
sim->part_change_type(i,x,y,PT_CFLM); sim->part_change_type(i,x,y,PT_CFLM);
parts[i].life = rand()%150+50; parts[i].life = rand()%150+50;

View File

@ -56,7 +56,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_SPRK && parts[ID(r)].life == 3) if (TYP(r) == PT_SPRK && parts[ID(r)].life == 3)
{ {
bool isBlackDeco = false; bool isBlackDeco = false;
int destroy = (parts[ID(r)].ctype==PT_PSCN) ? 1 : 0; int destroy = (parts[ID(r)].ctype==PT_PSCN) ? 1 : 0;
@ -68,7 +68,7 @@ int Element_ARAY::update(UPDATE_FUNC_ARGS)
break; break;
r = pmap[y+nyi+nyy][x+nxi+nxx]; r = pmap[y+nyi+nyy][x+nxi+nxx];
rt = r & 0xFF; rt = TYP(r);
r = ID(r); r = ID(r);
if (!rt) if (!rt)
{ {

View File

@ -60,7 +60,7 @@ int Element_BANG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; parts[i].tmp = 1;
} }

View File

@ -68,7 +68,7 @@ int Element_BCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN && if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM && rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 && rt!=PT_PBCN && rt!=PT_STKM2 &&

View File

@ -60,7 +60,7 @@ int Element_BIZR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; tr = (parts[ID(r)].dcolour>>16)&0xFF;
tg = (parts[ID(r)].dcolour>>8)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF;

View File

@ -58,7 +58,7 @@ int Element_BMTL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); 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; parts[ID(r)].tmp=(parts[i].tmp<=7)?parts[i].tmp=1:parts[i].tmp-(rand()%5);//rand()/(RAND_MAX/300)+100;

View File

@ -57,7 +57,7 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) 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; int rad = 8, nt;

View File

@ -68,12 +68,12 @@ int Element_BOYL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_WATR) if (TYP(r)==PT_WATR)
{ {
if (!(rand()%30)) if (!(rand()%30))
sim->part_change_type(ID(r),x+rx,y+ry,PT_FOG); 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)) if (!(rand()%9))
{ {

View File

@ -60,7 +60,7 @@ int Element_BRMT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_BREC && !(rand()%tempFactor)) if (TYP(r)==PT_BREC && !(rand()%tempFactor))
{ {
if(rand()%2) if(rand()%2)
{ {

View File

@ -55,7 +55,7 @@ int Element_BTRY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = (r&0xFF); rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) 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) 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)

View File

@ -56,7 +56,7 @@ int Element_C5::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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)) if (!(rand()%6))
{ {

View File

@ -54,7 +54,7 @@ int Element_CAUS::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_GAS) if (TYP(r) == PT_GAS)
{ {
if (sim->pv[(y+ry)/CELL][(x+rx)/CELL] > 3) 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); 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 // GLAS protects stuff from acid
if (sim->parts_avg(i, ID(r),PT_GLAS) != PT_GLAS) 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) if (newtemp < 0)
newtemp = 0; newtemp = 0;
parts[i].temp += newtemp; parts[i].temp += newtemp;

View File

@ -84,18 +84,18 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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 //Start explode
parts[i].tmp = rand()%25;//(rand()%100)+50; 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); sim->part_change_type(i,x,y,PT_CO2);
parts[i].ctype = 5; parts[i].ctype = 5;
sim->pv[y/CELL][x/CELL] += 0.2f; sim->pv[y/CELL][x/CELL] += 0.2f;
} }
if ((r&0xFF)==PT_CBNW) if (TYP(r)==PT_CBNW)
{ {
if(!parts[i].tmp) if(!parts[i].tmp)
{ {
@ -113,7 +113,7 @@ int Element_CBNW::update(UPDATE_FUNC_ARGS)
parts[ID(r)].tmp++; 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)) 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; 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)); sim->kill_part(ID(r));
if(!(rand()%50)){ if(!(rand()%50)){
sim->kill_part(i); sim->kill_part(i);

View File

@ -59,7 +59,7 @@ int Element_CLNE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN && if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_STKM && rt!=PT_BCLN && rt!=PT_STKM &&
rt!=PT_PBCN && rt!=PT_STKM2 && rt!=PT_PBCN && rt!=PT_STKM2 &&

View File

@ -57,7 +57,7 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_WATR) if (TYP(r)==PT_WATR)
{ {
if (!(rand()%1500)) if (!(rand()%1500))
{ {
@ -65,12 +65,12 @@ int Element_CLST::update(UPDATE_FUNC_ARGS)
sim->kill_part(ID(r)); 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(i, x, y, PT_BANG);
sim->create_part(ID(r), x+rx, y+ry, 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) if(parts[i].temp <195)
cxy = 0.05; cxy = 0.05;

View File

@ -62,14 +62,14 @@ int Element_CO2::update(UPDATE_FUNC_ARGS)
} }
continue; continue;
} }
if ((r&0xFF)==PT_FIRE){ if (TYP(r)==PT_FIRE){
sim->kill_part(ID(r)); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; 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); 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 if (parts[i].ctype==5) //conserve number of water particles - ctype=5 means this CO2 hasn't released the water particle from BUBW yet

View File

@ -60,13 +60,14 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && int rt = TYP(r);
(r&0xFF)!=PT_BCLN && (r&0xFF)!=PT_STKM && if (rt != PT_CLNE && rt != PT_PCLN &&
(r&0xFF)!=PT_PBCN && (r&0xFF)!=PT_STKM2 && rt != PT_BCLN && rt != PT_STKM &&
(r&0xFF)!=PT_CONV && (r&0xFF)<PT_NUM) rt != PT_PBCN && rt != PT_STKM2 &&
rt != PT_CONV && rt < PT_NUM)
{ {
parts[i].ctype = r&0xFF; parts[i].ctype = rt;
if ((r&0xFF)==PT_LIFE) if (rt == PT_LIFE)
parts[i].ctype |= PMAPID(parts[ID(r)].ctype); parts[i].ctype |= PMAPID(parts[ID(r)].ctype);
} }
} }
@ -79,11 +80,11 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{ {
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r || (restrictElement && (r&0xFF)!=restrictElement)) if (!r || (restrictElement && TYP(r) != restrictElement))
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || (restrictElement && (r&0xFF)!=restrictElement)) if (!r || (restrictElement && TYP(r) != restrictElement))
continue; 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)); sim->create_part(ID(r), x+rx, y+ry, parts[i].ctype&0xFF, ID(parts[i].ctype));
} }

View File

@ -60,9 +60,9 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)!=PT_CRAY && (r&0xFF)!=PT_PSCN && (r&0xFF)!=PT_INST && (r&0xFF)!=PT_METL && (r&0xFF)!=PT_SPRK && (r&0xFF)<PT_NUM) if (TYP(r)!=PT_CRAY && TYP(r)!=PT_PSCN && TYP(r)!=PT_INST && TYP(r)!=PT_METL && TYP(r)!=PT_SPRK && TYP(r)<PT_NUM)
{ {
parts[i].ctype = r&0xFF; parts[i].ctype = TYP(r);
parts[i].temp = parts[ID(r)].temp; parts[i].temp = parts[ID(r)].temp;
} }
} }
@ -76,7 +76,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
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
unsigned int colored = 0; unsigned int colored = 0;
bool destroy = parts[ID(r)].ctype==PT_PSCN; bool destroy = parts[ID(r)].ctype==PT_PSCN;
bool nostop = parts[ID(r)].ctype==PT_INST; bool nostop = parts[ID(r)].ctype==PT_INST;
@ -102,7 +102,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
if(!--partsRemaining) if(!--partsRemaining)
docontinue = 0; docontinue = 0;
} }
} else if ((r&0xFF)==PT_FILT) { // get color if passed through FILT } else if (TYP(r)==PT_FILT) { // get color if passed through FILT
if (parts[ID(r)].dcolour == 0xFF000000) if (parts[ID(r)].dcolour == 0xFF000000)
colored = 0xFF000000; colored = 0xFF000000;
else if (parts[ID(r)].tmp==0) else if (parts[ID(r)].tmp==0)
@ -112,9 +112,9 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
else if (colored==0xFF000000) else if (colored==0xFF000000)
colored = 0; colored = 0;
parts[ID(r)].life = 4; parts[ID(r)].life = 4;
} else if ((r&0xFF) == PT_CRAY || nostop) { } else if (TYP(r) == PT_CRAY || nostop) {
docontinue = 1; docontinue = 1;
} else if(destroy && r && ((r&0xFF) != PT_DMND)) { } else if(destroy && r && (TYP(r) != PT_DMND)) {
sim->kill_part(ID(r)); sim->kill_part(ID(r));
if(!--partsRemaining) if(!--partsRemaining)
docontinue = 0; docontinue = 0;

View File

@ -64,7 +64,7 @@ int Element_DCEL::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; 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)].vx *= multiplier;
parts[ID(r)].vy *= multiplier; parts[ID(r)].vy *= multiplier;

View File

@ -51,7 +51,10 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
int rx = rand()%5-2; int rx = rand()%5-2;
int ry = rand()%5-2; int ry = rand()%5-2;
int r = pmap[y+ry][x+rx]; 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; return 0;
if (parts[i].life<=0 || parts[i].life>37) 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; parts[i].life=30+rand()%20;
sim->pv[y/CELL][x/CELL]+=60.0f; 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; sim->pv[y/CELL][x/CELL]+=20.0f;
if (rand()%2) if (rand()%2)
@ -70,18 +73,18 @@ int Element_DEST::update(UPDATE_FUNC_ARGS)
parts[i].life-=4; 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); sim->create_part(ID(r), x+rx, y+ry, PT_PLSM);
} }
else if (!(rand()%3)) else if (!(rand()%3))
{ {
sim->kill_part(ID(r)); 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) if (parts[i].life<=0)
parts[i].life=1; parts[i].life=1;
} }
else if (sim->elements[r&0xFF].HeatConduct) else if (sim->elements[rt].HeatConduct)
parts[ID(r)].temp = MAX_TEMP; parts[ID(r)].temp = MAX_TEMP;
parts[i].temp=MAX_TEMP; parts[i].temp=MAX_TEMP;
sim->pv[y/CELL][x/CELL]+=80.0f; sim->pv[y/CELL][x/CELL]+=80.0f;

View File

@ -65,7 +65,7 @@ int Element_DEUT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || (parts[i].life >=maxlife)) if (!r || (parts[i].life >=maxlife))
continue; 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 // 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 // Condition is written in this way so that large neighbour life values don't cause integer overflow
@ -105,7 +105,7 @@ trade:
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; int temp = parts[i].life - parts[ID(r)].life;
if (temp ==1) if (temp ==1)

View File

@ -61,11 +61,11 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL) if (!r || sim->parts_avg(ID(r), i,PT_INSL)==PT_INSL)
continue; 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); 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) if (!parts[i].life)
{ {
@ -83,7 +83,7 @@ int Element_DLAY::update(UPDATE_FUNC_ARGS)
parts[ID(r)].life++; 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); sim->create_part(-1, x+rx, y+ry, PT_SPRK);
} }

View File

@ -59,7 +59,7 @@ int Element_DMG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->kill_part(i);
for (nxj=-rad; nxj<=rad; nxj++) 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->vx[(y+nxj)/CELL][(x+nxi)/CELL] += fx;
sim->vy[(y+nxj)/CELL][(x+nxi)/CELL] += fy; sim->vy[(y+nxj)/CELL][(x+nxi)/CELL] += fy;
sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 1.0f; 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].HighPressureTransition<PT_NUM) if (t && sim->elements[t].HighPressureTransition>-1 && sim->elements[t].HighPressureTransition<PT_NUM)
sim->part_change_type(ID(rr), x+nxi, y+nxj, sim->elements[t].HighPressureTransition); sim->part_change_type(ID(rr), x+nxi, y+nxj, sim->elements[t].HighPressureTransition);
else if (t == PT_BMTL) else if (t == PT_BMTL)

View File

@ -68,7 +68,7 @@ int Element_DRAY::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
int r = pmap[y+ry][x+rx]; 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; bool overwrite = parts[ID(r)].ctype == PT_PSCN;
int partsRemaining = copyLength, xCopyTo, yCopyTo; //positions where the line will start being copied at int partsRemaining = copyLength, xCopyTo, yCopyTo; //positions where the line will start being copied at

View File

@ -59,7 +59,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) 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) 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]; r = sim->photons[y+ry][x+rx];
if(!r) if(!r)
continue; 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; 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; setFilt = true;
photonWl = parts[ID(r)].ctype; photonWl = parts[ID(r)].ctype;
@ -102,7 +102,7 @@ int Element_DTEC::update(UPDATE_FUNC_ARGS)
continue; continue;
nx = x+rx; nx = x+rx;
ny = y+ry; ny = y+ry;
while ((r&0xFF)==PT_FILT) while (TYP(r)==PT_FILT)
{ {
parts[ID(r)].ctype = photonWl; parts[ID(r)].ctype = photonWl;
nx += rx; nx += rx;

View File

@ -57,7 +57,7 @@ int Element_ELEC::update(UPDATE_FUNC_ARGS)
r = sim->photons[y+ry][x+rx]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
switch (rt) switch (rt)
{ {
case PT_GLAS: case PT_GLAS:

View File

@ -55,7 +55,7 @@ int Element_EMBR::update(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->kill_part(i);
return 1; return 1;

View File

@ -119,7 +119,7 @@ int Element_ETRD::nearestSparkablePart(Simulation *sim, int targetId)
if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance) if (sim->InBounds(checkPos.X, checkPos.Y) && checkDistance <= foundDistance)
{ {
int r = sim->pmap[checkPos.Y][checkPos.X]; 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; foundDistance = checkDistance;
foundI = ID(r); foundI = ID(r);

View File

@ -56,7 +56,7 @@ int Element_EXOT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt == PT_WARP) if (rt == PT_WARP)
{ {
if (parts[ID(r)].tmp2>2000 && !(rand()%100)) 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; tym = parts[i].tmp2 - parts[ID(r)].tmp2;
if (tym == 1) if (tym == 1)

View File

@ -99,12 +99,12 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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(i,x,y,PT_WATR);
sim->part_change_type(ID(r),x+rx,y+ry,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); sim->part_change_type(i,x,y,PT_WATR);
if (1>(rand()%1000)) if (1>(rand()%1000))
@ -121,7 +121,7 @@ int Element::legacyUpdate(UPDATE_FUNC_ARGS) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); if (rand()%4==0) sim->part_change_type(i,x,y,PT_SALT);
else sim->part_change_type(i,x,y,PT_WTRV); 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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(i,x,y,PT_ICEI);
sim->part_change_type(ID(r),x+rx,y+ry,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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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(i,x,y,PT_ICEI);
sim->part_change_type(ID(r),x+rx,y+ry,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); sim->part_change_type(i,x,y,PT_WATR);
} }
} }

View File

@ -93,7 +93,7 @@ int Element_FIRE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
//THRM burning //THRM burning
if (rt==PT_THRM && (t==PT_FIRE || t==PT_PLSM || t==PT_LAVA)) 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; continue;
if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM) if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] && sim->bmap[(y+ry)/CELL][(x+rx)/CELL]!=WL_STREAM)
continue; continue;
rt = r&0xFF; rt = TYP(r);
lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL]; lpv = (int)sim->pv[(y+ry)/CELL][(x+rx)/CELL];
if (lpv < 1) lpv = 1; if (lpv < 1) lpv = 1;

View File

@ -61,7 +61,7 @@ int Element_FIRW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR) if (rt==PT_FIRE||rt==PT_PLSM||rt==PT_THDR)
{ {
float gx, gy, multiplier; float gx, gy, multiplier;

View File

@ -55,11 +55,11 @@ int Element_FOG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->part_change_type(i,x,y,PT_RIME);
} }
if ((r&0xFF)==PT_SPRK) if (TYP(r)==PT_SPRK)
{ {
parts[i].life += rand()%20; parts[i].life += rand()%20;
} }

View File

@ -60,7 +60,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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++) { for (nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; ; nyy+=nyi, nxx+=nxi, len++) {
if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen) { if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>curlen) {
break; break;
@ -68,7 +68,7 @@ int Element_FRAY::update(UPDATE_FUNC_ARGS)
r = pmap[y+nyi+nyy][x+nxi+nxx]; r = pmap[y+nyi+nyy][x+nxi+nxx];
if (!r) if (!r)
r = sim->photons[y+nyi+nyy][x+nxi+nxx]; 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)].vx += nxi*((parts[i].temp-273.15)/10.0f);
parts[ID(r)].vy += nyi*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += nyi*((parts[i].temp-273.15)/10.0f);
} }

View File

@ -55,7 +55,7 @@ int Element_FRZW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
} }

View File

@ -55,7 +55,7 @@ int Element_FRZZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_FRZW);
parts[ID(r)].life = 100; parts[ID(r)].life = 100;

View File

@ -70,7 +70,7 @@ int Element_FSEP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; parts[i].life = 39;
} }

View File

@ -78,7 +78,7 @@ int Element_FUSE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) if (parts[i].life > 40)
parts[i].life = 39; parts[i].life = 39;

View File

@ -59,9 +59,9 @@ int Element_GBMB::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if(!r) if(!r)
continue; continue;
if((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_GBMB && if(TYP(r)!=PT_BOMB && TYP(r)!=PT_GBMB &&
(r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && TYP(r)!=PT_CLNE && TYP(r)!=PT_PCLN &&
(r&0xFF)!=PT_DMND) TYP(r)!=PT_DMND)
{ {
parts[i].life=60; parts[i].life=60;
break; break;

View File

@ -62,7 +62,7 @@ int Element_GEL::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
//Desaturation //Desaturation
switch (rt) switch (rt)
{ {

View File

@ -56,7 +56,7 @@ int Element_GLOW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_WATR && !(rand()%400)) if (TYP(r)==PT_WATR && !(rand()%400))
{ {
sim->kill_part(i); sim->kill_part(i);
sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT); sim->part_change_type(ID(r),x+rx,y+ry,PT_DEUT);

View File

@ -62,7 +62,7 @@ int Element_GOLD::update(UPDATE_FUNC_ARGS)
if ((!rx != !ry) && BOUNDS_CHECK) { if ((!rx != !ry) && BOUNDS_CHECK) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if(!r) continue; 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; parts[ID(r)].tmp = 0;
sim->part_change_type(ID(r), x+rx, y+ry, PT_IRON); 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) { if (BOUNDS_CHECK) {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if(!r) continue; 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); sim->part_change_type(i, x, y, PT_SPRK);
parts[i].life = 4; parts[i].life = 4;

View File

@ -69,7 +69,7 @@ int Element_GPMP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_GPMP) if (TYP(r)==PT_GPMP)
{ {
if (parts[ID(r)].life<10&&parts[ID(r)].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;

View File

@ -55,7 +55,7 @@ int Element_H2::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_WATR);

View File

@ -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<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator)) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator))
{ {
r = pmap[y+rry][x+rrx]; 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++; count++;
tempAgg += parts[ID(r)].temp; tempAgg += parts[ID(r)].temp;
} }
r = sim->photons[y+rry][x+rrx]; 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++; count++;
tempAgg += parts[ID(r)].temp; 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<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator)) if (x+rrx >= 0 && x+rrx < XRES && y+rry >= 0 && y+rry < YRES && !Element_HEAC::CheckLine<Element_HEAC::IsInsulator>(sim, x, y, x+rrx, y+rry, isInsulator))
{ {
r = pmap[y+rry][x+rrx]; 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; parts[ID(r)].temp = parts[i].temp;
} }
r = sim->photons[y+rry][x+rrx]; 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; parts[ID(r)].temp = parts[i].temp;
} }

View File

@ -65,14 +65,14 @@ int Element_HSWC::update(UPDATE_FUNC_ARGS)
r = sim->photons[y + ry][x + rx]; r = sim->photons[y + ry][x + rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_HSWC) if (TYP(r)==PT_HSWC)
{ {
if (parts[ID(r)].life<10&&parts[ID(r)].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
else if (parts[ID(r)].life==0) else if (parts[ID(r)].life==0)
parts[ID(r)].life = 10; 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; parts[i].temp = parts[ID(r)].ctype - 0x10000000;
} }

View File

@ -59,7 +59,7 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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)) if (parts[i].temp > sim->elements[PT_SLTW].LowTemperature && !(rand()%200))
{ {
@ -68,7 +68,7 @@ int Element_ICEI::update(UPDATE_FUNC_ARGS)
return 0; 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_ICEI);
parts[ID(r)].ctype = PT_FRZW; parts[ID(r)].ctype = PT_FRZW;

View File

@ -57,7 +57,7 @@ int Element_IGNT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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)) 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; parts[i].tmp = 1;

View File

@ -55,7 +55,7 @@ int Element_IRON::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
switch (r&0xFF) switch TYP(r)
{ {
case PT_SALT: case PT_SALT:
if (!(rand()%47)) if (!(rand()%47))

View File

@ -92,7 +92,7 @@ int Element_LCRY::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; parts[ID(r)].tmp = setto;
} }

View File

@ -85,7 +85,7 @@ int Element_LIGH::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if ((surround_space || sim->elements[rt].Explosive) && if ((surround_space || sim->elements[rt].Explosive) &&
(rt!=PT_SPNG || parts[ID(r)].life==0) && (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)) 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: default:
break; 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->create_part(ID(r),x+rx,y+ry,PT_SPRK);
sim->pv[y/CELL][x/CELL] += powderful/400; 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) 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]; r = sim->pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==tp) if (TYP(r)==tp)
return ID(r); return ID(r);
} }
return -1; 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) else if (x >= 0 && x < XRES && y >= 0 && y < YRES)
{ {
int r = sim->pmap[y][x]; 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; return true;
} }
else return true; else return true;

View File

@ -59,7 +59,7 @@ int Element_LSNS::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) 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) 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)

View File

@ -71,7 +71,7 @@ int Element_MERC::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r || (parts[i].tmp >=maxtmp)) if (!r || (parts[i].tmp >=maxtmp))
continue; 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) 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; int temp = parts[i].tmp - parts[ID(r)].tmp;
if (temp ==1) if (temp ==1)

View File

@ -56,7 +56,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_FIRE) if (TYP(r)==PT_FIRE)
{ {
parts[ID(r)].temp+=(rand()%100); parts[ID(r)].temp+=(rand()%100);
if(parts[ID(r)].tmp&0x01) if(parts[ID(r)].tmp&0x01)
@ -67,7 +67,7 @@ int Element_O2::update(UPDATE_FUNC_ARGS)
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);
parts[i].tmp |= 2; 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); sim->create_part(i,x,y,PT_FIRE);
parts[i].temp+=(rand()%100); parts[i].temp+=(rand()%100);

View File

@ -73,7 +73,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN && if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK && rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_PSCN &&
@ -99,7 +99,7 @@ int Element_PBCN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_PBCN) if (TYP(r)==PT_PBCN)
{ {
if (parts[ID(r)].life<10&&parts[ID(r)].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;

View File

@ -58,7 +58,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPRK) if (TYP(r)==PT_SPRK)
{ {
if (parts[ID(r)].life>0 && parts[ID(r)].life<4) 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; 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) if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;
@ -86,7 +86,7 @@ int Element_PCLN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (rt!=PT_CLNE && rt!=PT_PCLN && if (rt!=PT_CLNE && rt!=PT_PCLN &&
rt!=PT_BCLN && rt!=PT_SPRK && rt!=PT_BCLN && rt!=PT_SPRK &&
rt!=PT_NSCN && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_PSCN &&

View File

@ -62,7 +62,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_ISOZ || (r&0xFF)==PT_ISZS) if (TYP(r)==PT_ISOZ || TYP(r)==PT_ISZS)
{ {
if (!(rand()%400)) if (!(rand()%400))
{ {
@ -70,7 +70,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
parts[i].vy *= 0.90; parts[i].vy *= 0.90;
sim->create_part(ID(r), x+rx, y+ry, PT_PHOT); sim->create_part(ID(r), x+rx, y+ry, PT_PHOT);
rrr = (rand()%360)*3.14159f/180.0f; rrr = (rand()%360)*3.14159f/180.0f;
if ((r&0xFF) == PT_ISOZ) if (TYP(r) == PT_ISOZ)
rr = (rand()%128+128)/127.0f; rr = (rand()%128+128)/127.0f;
else else
rr = (rand()%228+128)/127.0f; 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; 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; float a = (rand()%360)*3.14159f/180.0f;
parts[i].vx = 3.0f*cosf(a); parts[i].vx = 3.0f*cosf(a);
@ -89,7 +89,7 @@ int Element_PHOT::update(UPDATE_FUNC_ARGS)
if (parts[i].life) if (parts[i].life)
parts[i].life++; //Delay death 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 a = (rand()%101 - 50) * 0.001f;
float rx = cosf(a), ry = sinf(a), vx, vy; 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].vx = vx;
parts[i].vy = vy; 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].vx += ((float)(rand()%1000-500))/1000.0f;
parts[i].vy += ((float)(rand()%1000-500))/1000.0f; parts[i].vy += ((float)(rand()%1000-500))/1000.0f;

View File

@ -101,7 +101,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((r&0xFF) == PT_BRCK) if (TYP(r) == PT_BRCK)
{ {
if (parts[i].tmp & PPIP_TMPFLAG_PAUSED) if (parts[i].tmp & PPIP_TMPFLAG_PAUSED)
parts[ID(r)].tmp = 0; parts[ID(r)].tmp = 0;
@ -146,7 +146,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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)].ctype = (((parts[i].ctype)%3)+2);//reverse
parts[ID(r)].life = 6; parts[ID(r)].life = 6;
@ -160,7 +160,7 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
neighborcount ++; neighborcount ++;
lastneighbor = ID(r); 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 ++; neighborcount ++;
lastneighbor = ID(r); lastneighbor = ID(r);
@ -202,14 +202,14 @@ int Element_PIPE::update(UPDATE_FUNC_ARGS)
} }
} }
//try eating particle at entrance //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)); Element_SOAP::detach(sim, ID(r));
transfer_part_to_pipe(parts+(ID(r)), parts+i); transfer_part_to_pipe(parts+(ID(r)), parts+i);
sim->kill_part(ID(r)); 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 // STOR stores properties in the same places as PIPE does
transfer_pipe_to_pipe(parts+(ID(r)), parts+i); 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)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; 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; issingle = 0;
} }
if (issingle) 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]; r = sim->pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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))); transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
if (ID(r) > original) if (ID(r) > original)
@ -423,7 +423,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
count++; count++;
pushParticle(sim, ID(r),count,original); 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; int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS) 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); int coords = 7 - ((sim->parts[i].tmp>>10)&7);
r = sim->pmap[y+ pos_1_ry[coords]][x+ pos_1_rx[coords]]; 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))); transfer_pipe_to_pipe(sim->parts+i, sim->parts+(ID(r)));
if (ID(r) > original) if (ID(r) > original)
@ -453,7 +453,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
count++; count++;
pushParticle(sim, ID(r),count,original); 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; int portaltmp = sim->parts[ID(r)].tmp;
if (portaltmp >= CHANNELS) if (portaltmp >= CHANNELS)
@ -468,7 +468,7 @@ void Element_PIPE::pushParticle(Simulation * sim, int i, int count, int original
break; 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]; rx = pos_1_rx[coords];
ry = pos_1_ry[coords]; ry = pos_1_ry[coords];

View File

@ -71,25 +71,25 @@ int Element_PRTI::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r || (r&0xFF) == PT_STOR) if (!r || TYP(r) == PT_STOR)
fe = 1; 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]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; 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() 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)); Element_SOAP::detach(sim, ID(r));
for (int nnx=0; nnx<80; nnx++) for (int nnx=0; nnx<80; nnx++)
if (!sim->portalp[parts[i].tmp][count][nnx].type) 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))) 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 else
{ {
sim->portalp[parts[i].tmp][count][nnx] = parts[ID(r)]; 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); sim->part_change_type(ID(r),x+rx,y+ry,parts[ID(r)].ctype);
else else
sim->kill_part(ID(r)); sim->kill_part(ID(r));

View File

@ -58,7 +58,7 @@ int Element_PSNS::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
if (sim->parts_avg(i,ID(r),PT_INSL) != PT_INSL) 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) 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)

View File

@ -88,7 +88,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) if(parts[ID(r)].ctype == PT_PSCN)
state = PISTON_EXTEND; state = PISTON_EXTEND;
else else
@ -104,7 +104,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_PSTN) if (TYP(r) == PT_PSTN)
{ {
bool movedPiston = false; bool movedPiston = false;
bool foundEnd = false; bool foundEnd = false;
@ -119,7 +119,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
break; break;
} }
r = pmap[y+nyy][x+nxx]; r = pmap[y+nyy][x+nxx];
if((r&0xFF)==PT_PSTN) if(TYP(r)==PT_PSTN)
{ {
if(parts[ID(r)].life) if(parts[ID(r)].life)
armCount++; armCount++;
@ -202,7 +202,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX,
break; break;
r = sim->pmap[posY][posX]; 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); return StackData(currentPos - spaces, spaces);
if (!r) if (!r)
{ {
@ -213,7 +213,7 @@ Element_PSTN::StackData Element_PSTN::CanMoveStack(Simulation * sim, int stackX,
} }
else 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); tempParts[currentPos++] = ID(r);
else else
return StackData(currentPos - spaces, spaces); 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; int posX, posY, r;
r = sim->pmap[stackY][stackX]; r = sim->pmap[stackY][stackX];
if(!callDepth && (r&0xFF) == PT_FRME) { if(!callDepth && TYP(r) == PT_FRME) {
int newY = !!directionX, newX = !!directionY; int newY = !!directionX, newX = !!directionY;
int realDirectionX = retract?-directionX:directionX; int realDirectionX = retract?-directionX:directionX;
int realDirectionY = retract?-directionY:directionY; int realDirectionY = retract?-directionY:directionY;
@ -289,7 +289,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
break; break;
} }
r = sim->pmap[posY][posX]; 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; break;
} else { } else {
foundParts = true; foundParts = true;

View File

@ -74,7 +74,7 @@ int Element_PUMP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_PUMP) if (TYP(r)==PT_PUMP)
{ {
if (parts[ID(r)].life<10&&parts[ID(r)].life>0) if (parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;

View File

@ -58,7 +58,7 @@ int Element_PVOD::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPRK) if (TYP(r)==PT_SPRK)
{ {
if (parts[ID(r)].life>0 && parts[ID(r)].life<4) 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; 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) if (parts[i].life==10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)
parts[i].life = 9; parts[i].life = 9;

View File

@ -70,7 +70,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
else if ((r&0xFF)==PT_SLTW && !(rand()%500)) else if (TYP(r)==PT_SLTW && !(rand()%500))
{ {
sim->kill_part(ID(r)); sim->kill_part(ID(r));
parts[i].tmp++; parts[i].tmp++;
@ -122,7 +122,7 @@ int Element_QRTZ::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; tmp = parts[i].tmp - parts[ID(r)].tmp;
if (tmp ==1) if (tmp ==1)

View File

@ -55,12 +55,12 @@ int Element_RIME::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SPRK) if (TYP(r)==PT_SPRK)
{ {
sim->part_change_type(i,x,y,PT_FOG); sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = rand()%50 + 60; 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); sim->part_change_type(i,x,y,PT_FOG);
parts[i].life = parts[ID(r)].life; parts[i].life = parts[ID(r)].life;

View File

@ -58,7 +58,7 @@ int Element_RPEL::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
r = sim->photons[y+ry][x+rx]; 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) { 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)].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f); parts[ID(r)].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);

View File

@ -55,7 +55,7 @@ int Element_SHLD1::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) 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); sim->part_change_type(i,x,y,PT_SHLD2);
parts[i].life = 7; parts[i].life = 7;

View File

@ -59,7 +59,7 @@ int Element_SHLD2::update(UPDATE_FUNC_ARGS)
sim->create_part(-1,x+rx,y+ry,PT_SHLD1); sim->create_part(-1,x+rx,y+ry,PT_SHLD1);
continue; continue;
} }
else if ((r&0xFF)==PT_SPRK&&parts[i].life==0) else if (TYP(r)==PT_SPRK&&parts[i].life==0)
{ {
if (!(rand()%8)) 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); sim->part_change_type(i,x,y,PT_SHLD3);
parts[i].life = 7; parts[i].life = 7;

View File

@ -64,12 +64,12 @@ int Element_SHLD3::update(UPDATE_FUNC_ARGS)
} }
continue; 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD2);
parts[ID(r)].life=7; 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) if (3>rand()%500)
{ {

View File

@ -65,12 +65,12 @@ int Element_SHLD4::update(UPDATE_FUNC_ARGS)
continue; 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_SHLD3);
parts[ID(r)].life = 7; 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 ( nnx=-1; nnx<2; nnx++)
for ( nny=-1; nny<2; nny++) for ( nny=-1; nny<2; nny++)
{ {

View File

@ -111,9 +111,9 @@ int Element_SING::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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) if (parts[i].life+parts[ID(r)].life > 255)
continue; continue;

View File

@ -53,7 +53,7 @@ int Element_SLTW::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
switch (r&0xFF) switch TYP(r)
{ {
case PT_SALT: case PT_SALT:
if (!(rand()%2000)) if (!(rand()%2000))

View File

@ -60,7 +60,7 @@ int Element_SNOW::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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(i,x,y,PT_SLTW);
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW); sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW);

View File

@ -163,14 +163,14 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
if (parts[i].temp>FREEZING) if (parts[i].temp>FREEZING)
{ {
if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL] if (sim->bmap[(y+ry)/CELL][(x+rx)/CELL]
|| (r && !(sim->elements[r&0xFF].Properties&TYPE_GAS) || (r && !(sim->elements[TYP(r)].Properties&TYPE_GAS)
&& (r&0xFF) != PT_SOAP && (r&0xFF) != PT_GLAS)) && TYP(r) != PT_SOAP && TYP(r) != PT_GLAS))
{ {
detach(sim, i); detach(sim, i);
continue; continue;
} }
} }
if ((r&0xFF) == PT_SOAP) if (TYP(r) == PT_SOAP)
{ {
if (parts[ID(r)].ctype == 1) if (parts[ID(r)].ctype == 1)
{ {
@ -237,7 +237,7 @@ int Element_SOAP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_OIL) if (TYP(r) == PT_OIL)
{ {
float ax, ay; float ax, ay;
ax = (parts[i].vx*0.5f + parts[ID(r)].vx)/2; 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]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)!=PT_SOAP) if (TYP(r)!=PT_SOAP)
{ {
tr = (parts[ID(r)].dcolour>>16)&0xFF; tr = (parts[ID(r)].dcolour>>16)&0xFF;
tg = (parts[ID(r)].dcolour>>8)&0xFF; tg = (parts[ID(r)].dcolour>>8)&0xFF;

View File

@ -58,7 +58,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
switch (r&0xFF) switch TYP(r)
{ {
case PT_WATR: case PT_WATR:
case PT_DSTW: case PT_DSTW:
@ -119,7 +119,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; tmp = parts[i].life - parts[ID(r)].life;
if (tmp ==1) if (tmp ==1)
@ -147,7 +147,7 @@ int Element_SPNG::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_FIRE) if (TYP(r)==PT_FIRE)
{ {
tmp++; tmp++;
if (parts[ID(r)].life>60) if (parts[ID(r)].life>60)

View File

@ -148,7 +148,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; int rnd = rand()%100;
if (!rnd) if (!rnd)
@ -172,7 +172,7 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
receiver = r&0xFF; receiver = TYP(r);
sender = ct; sender = ct;
pavg = sim->parts_avg(ID(r), i,PT_INSL); pavg = sim->parts_avg(ID(r), i,PT_INSL);
//receiver is the element SPRK is trying to conduct to //receiver is the element SPRK is trying to conduct to

View File

@ -368,8 +368,8 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL]) if (!r && !sim->bmap[(y+ry)/CELL][(x+rx)/CELL])
continue; continue;
STKM_set_element(sim, playerp, r&0xFF); STKM_set_element(sim, playerp, TYP(r));
if ((r&0xFF) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP if (TYP(r) == PT_PLNT && parts[i].life<100) //Plant gives him 5 HP
{ {
if (parts[i].life<=95) if (parts[i].life<=95)
parts[i].life += 5; parts[i].life += 5;
@ -378,7 +378,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
sim->kill_part(ID(r)); 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; if (parts[i].life<=100) parts[i].life -= (102-parts[i].life)/2;
else parts[i].life *= 0.9f; else parts[i].life *= 0.9f;
@ -390,7 +390,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
playerp->rocketBoots = false; playerp->rocketBoots = false;
else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */) else if (sim->bmap[(ry+y)/CELL][(rx+x)/CELL]==WL_GRAV /* && parts[i].type!=PT_FIGH */)
playerp->rocketBoots = true; playerp->rocketBoots = true;
if ((r&0xFF)==PT_PRTI) if (TYP(r)==PT_PRTI)
Element_STKM::STKM_interact(sim, playerp, i, rx, ry); Element_STKM::STKM_interact(sim, playerp, i, rx, ry);
if (!parts[i].type)//STKM_interact may kill STKM if (!parts[i].type)//STKM_interact may kill STKM
return 1; return 1;
@ -405,7 +405,7 @@ int Element_STKM::run_stickman(playerst *playerp, UPDATE_FUNC_ARGS) {
{ {
ry -= 2*(rand()%2)+1; ry -= 2*(rand()%2)+1;
r = pmap[ry][rx]; 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); sim->create_part(-1, rx, ry, PT_SPRK);
playerp->frames = 0; playerp->frames = 0;
@ -578,18 +578,18 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
r = sim->pmap[y][x]; r = sim->pmap[y][x];
if (r) 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; 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; sim->parts[i].life -= 2;
playerp->accs[3] -= 1; playerp->accs[3] -= 1;
} }
if (sim->elements[r&0xFF].Properties&PROP_DEADLY) if (sim->elements[TYP(r)].Properties&PROP_DEADLY)
switch (r&0xFF) switch (r&0xFF)
{ {
case PT_ACID: case PT_ACID:
@ -600,10 +600,10 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
break; break;
} }
if (sim->elements[r&0xFF].Properties&PROP_RADIOACTIVE) if (sim->elements[TYP(r)].Properties&PROP_RADIOACTIVE)
sim->parts[i].life -= 1; 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 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); 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; 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) if (!sim->legacy_enable)
{ {
@ -629,7 +629,7 @@ void Element_STKM::STKM_interact(Simulation *sim, playerst *playerp, int i, int
} }
sim->kill_part(i); 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); sim->kill_part(i);
} }

View File

@ -60,9 +60,9 @@ int Element_STOR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if ((ID(r))>=NPART || !r) if ((ID(r))>=NPART || !r)
continue; 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)); Element_SOAP::detach(sim, ID(r));
parts[i].tmp = parts[ID(r)].type; parts[i].tmp = parts[ID(r)].type;
parts[i].temp = parts[ID(r)].temp; 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; parts[i].pavg[1] = parts[ID(r)].ctype;
sim->kill_part(ID(r)); 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(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) 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)

View File

@ -64,7 +64,7 @@ int Element_SWCH::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) { if (sim->parts_avg(i,ID(r),PT_INSL)!=PT_INSL) {
rt = r&0xFF; rt = TYP(r);
if (rt==PT_SWCH) if (rt==PT_SWCH)
{ {
if (parts[i].life>=10&&parts[ID(r)].life<10&&parts[ID(r)].life>0) if (parts[i].life>=10&&parts[ID(r)].life<10&&parts[ID(r)].life>0)

View File

@ -57,8 +57,8 @@ int Element_THDR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
rt = r&0xFF; rt = TYP(r);
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) 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; parts[ID(r)].ctype = parts[ID(r)].type;
sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);

View File

@ -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) //#TPT-Directive ElementHeader Element_TRON static bool canmovetron(Simulation * sim, int r, int len)
bool Element_TRON::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; 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 true;
return false; return false;
} }

View File

@ -60,7 +60,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx]; int r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
int rt = r&0xFF; int rt = TYP(r);
if (sim->parts_avg(i, ID(r), PT_INSL) != PT_INSL) 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) 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]; r = sim->photons[y+ry][x+rx];
if (!r) if (!r)
continue; 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; 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; setFilt = true;
photonWl = parts[ID(r)].temp; photonWl = parts[ID(r)].temp;
@ -103,7 +103,7 @@ int Element_TSNS::update(UPDATE_FUNC_ARGS)
continue; continue;
nx = x + rx; nx = x + rx;
ny = y + ry; ny = y + ry;
while ((r & 0xFF) == PT_FILT) while (TYP(r) == PT_FILT)
{ {
parts[ID(r)].ctype = 0x10000000 + photonWl; parts[ID(r)].ctype = 0x10000000 + photonWl;
nx += rx; nx += rx;

View File

@ -60,7 +60,7 @@ int Element_TUNG::update(UPDATE_FUNC_ARGS)
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if((r&0xFF) == PT_O2) if(TYP(r) == PT_O2)
{ {
splode = true; splode = true;
} }

View File

@ -87,10 +87,10 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
ry = (rndstore>>2)%3-1; ry = (rndstore>>2)%3-1;
rndstore = rndstore >> 4; rndstore = rndstore >> 4;
r = pmap[y+ry][x+rx]; 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)].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); 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) if(BOUNDS_CHECK)
{ {
r = pmap[y+ry][x+rx]; 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[ID(r)].temp += parts[i].tmp*3;
parts[i].tmp = 0; parts[i].tmp = 0;
@ -152,7 +152,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
if (parts[i].life) if (parts[i].life)
{ {
//Makes EXOT around it get tmp to start exploding too //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) if (!parts[ID(r)].life)
parts[ID(r)].tmp += 45; parts[ID(r)].tmp += 45;
@ -162,7 +162,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
parts[i].tmp = 0; parts[i].tmp = 0;
} }
} }
else if ((r&0xFF)==PT_CFLM) else if (TYP(r)==PT_CFLM)
{ {
parts[i].tmp2 = 1; parts[i].tmp2 = 1;
parts[i].tmp = 0; parts[i].tmp = 0;
@ -171,14 +171,14 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
else else
{ {
//Melts into EXOT //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); sim->part_change_type(i, x, y, PT_EXOT);
return 1; return 1;
} }
} }
//VIBR+ANAR=BVBR //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->part_change_type(i,x,y,PT_BVBR);
sim->pv[y/CELL][x/CELL] -= 1; sim->pv[y/CELL][x/CELL] -= 1;
@ -195,7 +195,7 @@ int Element_VIBR::update(UPDATE_FUNC_ARGS) {
if (BOUNDS_CHECK && (rx || ry)) if (BOUNDS_CHECK && (rx || ry))
{ {
r = pmap[y+ry][x+rx]; 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; continue;
if (parts[i].tmp > parts[ID(r)].tmp) if (parts[i].tmp > parts[ID(r)].tmp)
{ {

View File

@ -86,20 +86,20 @@ int Element_VIRS::update(UPDATE_FUNC_ARGS)
continue; continue;
//spread "being cured" state //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); parts[i].pavg[0] = parts[ID(r)].pavg[0] + ((rndstore & 0x3) ? 2:1);
return 0; return 0;
} }
//soap cures virus //soap cures virus
else if ((r&0xFF) == PT_SOAP) else if (TYP(r) == PT_SOAP)
{ {
parts[i].pavg[0] += 10; parts[i].pavg[0] += 10;
if (!(rndstore & 0x3)) if (!(rndstore & 0x3))
sim->kill_part(ID(r)); sim->kill_part(ID(r));
return 0; 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)) 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 //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)) if (!(rndstore & 0x7))
{ {
parts[ID(r)].tmp2 = (r&0xFF); parts[ID(r)].tmp2 = TYP(r);
parts[ID(r)].pavg[0] = 0; parts[ID(r)].pavg[0] = 0;
if (parts[i].pavg[1]) if (parts[i].pavg[1])
parts[ID(r)].pavg[1] = parts[i].pavg[1] + 1; parts[ID(r)].pavg[1] = parts[i].pavg[1] + 1;

View File

@ -65,7 +65,7 @@ int Element_WARP::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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].x = parts[ID(r)].x;
parts[i].y = parts[ID(r)].y; parts[i].y = parts[ID(r)].y;

View File

@ -55,31 +55,31 @@ int Element_WATR::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; continue;
if ((r&0xFF)==PT_SALT && !(rand()%50)) if (TYP(r)==PT_SALT && !(rand()%50))
{ {
sim->part_change_type(i,x,y,PT_SLTW); sim->part_change_type(i,x,y,PT_SLTW);
// on average, convert 3 WATR to SLTW before SALT turns into SLTW // on average, convert 3 WATR to SLTW before SALT turns into SLTW
if (!(rand()%3)) if (!(rand()%3))
sim->part_change_type(ID(r),x+rx,y+ry,PT_SLTW); 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); sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4; parts[i].life = 4;
parts[i].ctype = PT_WATR; 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)); sim->kill_part(ID(r));
if(!(rand()%30)){ if(!(rand()%30)){
sim->kill_part(i); sim->kill_part(i);
return 1; 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); 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); part_change_type(i,x,y,PT_PSTE);
sim.kill_part(ID(r)); sim.kill_part(ID(r));

View File

@ -63,14 +63,14 @@ int Element_WIFI::update(UPDATE_FUNC_ARGS)
// wireless[][1] - whether channel should be active on next frame // wireless[][1] - whether channel should be active on next frame
if (sim->wireless[parts[i].tmp][0]) 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); sim->part_change_type(ID(r),x+rx,y+ry,PT_SPRK);
parts[ID(r)].life = 4; 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->wireless[parts[i].tmp][1] = 1;
sim->ISWIRE = 2; sim->ISWIRE = 2;

View File

@ -74,14 +74,14 @@ int Element_WIRE::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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; parts[i].ctype=1;
return 0; 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); 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++; count++;
} }
} }

View File

@ -55,7 +55,7 @@ int Element_WTRV::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->part_change_type(i,x,y,PT_FIRE);
parts[i].life = 4; parts[i].life = 4;

View File

@ -55,7 +55,7 @@ int Element_YEST::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx]; r = pmap[y+ry][x+rx];
if (!r) if (!r)
continue; 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); sim->part_change_type(i,x,y,PT_DYST);
} }