Skip to content

Commit

Permalink
convert r&0xFF in src/simulation/elements
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob1 committed Dec 28, 2017
1 parent 4b1c929 commit 208cf14
Show file tree
Hide file tree
Showing 94 changed files with 247 additions and 242 deletions.
2 changes: 1 addition & 1 deletion src/simulation/elements/ACEL.cpp
Expand Up @@ -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;
Expand Down
15 changes: 8 additions & 7 deletions src/simulation/elements/ACID.cpp
Expand Up @@ -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))
{
Expand All @@ -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;
}
Expand All @@ -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--;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/AMTR.cpp
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/ANAR.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/ARAY.cpp
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BANG.cpp
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BCLN.cpp
Expand Up @@ -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 &&
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BIZR.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BMTL.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BOMB.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/BOYL.cpp
Expand Up @@ -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))
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BRMT.cpp
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/BTRY.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/C5.cpp
Expand Up @@ -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))
{
Expand Down
8 changes: 4 additions & 4 deletions src/simulation/elements/CAUS.cpp
Expand Up @@ -54,22 +54,22 @@ 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)
{
sim->part_change_type(ID(r), x+rx, y+ry, 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
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;
Expand Down
10 changes: 5 additions & 5 deletions src/simulation/elements/CBNW.cpp
Expand Up @@ -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)
{
Expand All @@ -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))
{
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/CLNE.cpp
Expand Up @@ -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 &&
Expand Down
6 changes: 3 additions & 3 deletions src/simulation/elements/CLST.cpp
Expand Up @@ -57,20 +57,20 @@ 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))
{
sim->create_part(i, x, y, PT_PSTS);
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;
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/elements/CO2.cpp
Expand Up @@ -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
Expand Down
19 changes: 10 additions & 9 deletions src/simulation/elements/CONV.cpp
Expand Up @@ -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)<PT_NUM)
int rt = TYP(r);
if (rt != PT_CLNE && rt != PT_PCLN &&
rt != PT_BCLN && rt != PT_STKM &&
rt != PT_PBCN && rt != PT_STKM2 &&
rt != PT_CONV && rt < PT_NUM)
{
parts[i].ctype = r&0xFF;
if ((r&0xFF)==PT_LIFE)
parts[i].ctype = rt;
if (rt == PT_LIFE)
parts[i].ctype |= PMAPID(parts[ID(r)].ctype);
}
}
Expand All @@ -79,11 +80,11 @@ int Element_CONV::update(UPDATE_FUNC_ARGS)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES)
{
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];
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));
}
Expand Down
12 changes: 6 additions & 6 deletions src/simulation/elements/CRAY.cpp
Expand Up @@ -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)<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;
}
}
Expand All @@ -76,7 +76,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
int r = pmap[y+ry][x+rx];
if (!r)
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;
bool destroy = parts[ID(r)].ctype==PT_PSCN;
bool nostop = parts[ID(r)].ctype==PT_INST;
Expand All @@ -102,7 +102,7 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
if(!--partsRemaining)
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)
colored = 0xFF000000;
else if (parts[ID(r)].tmp==0)
Expand All @@ -112,9 +112,9 @@ int Element_CRAY::update(UPDATE_FUNC_ARGS)
else if (colored==0xFF000000)
colored = 0;
parts[ID(r)].life = 4;
} else if ((r&0xFF) == PT_CRAY || nostop) {
} else if (TYP(r) == PT_CRAY || nostop) {
docontinue = 1;
} else if(destroy && r && ((r&0xFF) != PT_DMND)) {
} else if(destroy && r && (TYP(r) != PT_DMND)) {
sim->kill_part(ID(r));
if(!--partsRemaining)
docontinue = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/DCEL.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 208cf14

Please sign in to comment.