Skip to content

Commit

Permalink
Misc small fixes
Browse files Browse the repository at this point in the history
SPRK has no legacy reactions so don't call update_legacy_PYRO for it.
Use pmap loops excluding energy particles for ARAY.
BIZR reaction with PHOT is already in the movement code for PHOT.
Fix accidental assignment in DLAY_update.
Move ELEC+GLOW reaction into movement code.
Return 1 in some places where parts[i].type has changed.
Add a bit more implementation of FILT modes (started in a435fab).
Reset LCRY properties if tmp is invalid.
  • Loading branch information
jacksonmj committed Nov 7, 2014
1 parent e8809d4 commit 95cf5bd
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 35 deletions.
19 changes: 13 additions & 6 deletions src/elements/pyro.c
Expand Up @@ -80,13 +80,16 @@ int update_PYRO(UPDATE_FUNC_ARGS) {
}
}
}
if (legacy_enable) update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
if (legacy_enable && t!=PT_SPRK) // SPRK has no legacy reactions
update_legacy_PYRO(UPDATE_FUNC_SUBCALL_ARGS);
return 0;
}

int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
int rx, ry, rt, lpv, t = parts[i].type;
int rcount, ri, rnext;
if (t==PT_SPRK)
return 0;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
Expand All @@ -98,13 +101,17 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
rt = parts[ri].type;
lpv = (int)pv[(y+ry)/CELL][(x+rx)/CELL];
if (lpv < 1) lpv = 1;
if (t!=PT_SPRK && ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
if (ptypes[rt].meltable && ((rt!=PT_RBDM && rt!=PT_LRBD) || t!=PT_SPRK) && ((t!=PT_FIRE&&t!=PT_PLSM) || (rt!=PT_METL && rt!=PT_IRON && rt!=PT_ETRD && rt!=PT_PSCN && rt!=PT_NSCN && rt!=PT_NTCT && rt!=PT_PTCT && rt!=PT_BMTL && rt!=PT_BRMT && rt!=PT_SALT && rt!=PT_INWR)) &&
ptypes[rt].meltable*lpv>(rand()%1000))
{
if (t!=PT_LAVA || parts[i].life>0)
{
parts[ri].ctype = (rt==PT_BRMT)?PT_BMTL:rt;
parts[ri].ctype = (parts[ri].ctype==PT_SAND)?PT_GLAS:parts[ri].ctype;
if (rt==PT_BRMT)
parts[ri].ctype = PT_BMTL;
else if (rt==PT_SAND)
parts[ri].ctype = PT_GLAS;
else
parts[ri].ctype = rt;
part_change_type(ri,x+rx,y+ry,PT_LAVA);
parts[ri].life = rand()%120+240;
}
Expand All @@ -116,7 +123,7 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
return 1;
}
}
if (t!=PT_SPRK && (rt==PT_ICEI || rt==PT_SNOW))
if (rt==PT_ICEI || rt==PT_SNOW)
{
part_change_type(ri,x+rx,y+ry,PT_WATR);
if (t==PT_FIRE)
Expand All @@ -130,7 +137,7 @@ int update_legacy_PYRO(UPDATE_FUNC_ARGS) {
part_change_type(i,x,y,PT_STNE);
}
}
if (t!=PT_SPRK && (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW))
if (rt==PT_WATR || rt==PT_DSTW || rt==PT_SLTW)
{
kill_part(ri);
if (t==PT_FIRE)
Expand Down
4 changes: 4 additions & 0 deletions src/powder.c
Expand Up @@ -480,6 +480,10 @@ int try_move(int i, int x, int y, int nx, int ny)
if (rand() < RAND_MAX/10)
create_cherenkov_photon(i);
}
if (t==PT_ELEC && rt==PT_GLOW)
{
part_change_type(i, x, y, PT_PHOT);
}
}
return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/simulation/elements/ARAY.cpp
Expand Up @@ -24,7 +24,7 @@ int ARAY_update(UPDATE_FUNC_ARGS)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
FOR_PMAP_POSITION(sim, x+rx, y+ry, scount, si, snext)// TODO: not energy parts
FOR_PMAP_POSITION_NOENERGY(sim, x+rx, y+ry, scount, si, snext)
{
if (parts[si].type==PT_SPRK && parts[si].life==3) {
int destroy = (parts[si].ctype==PT_PSCN)?1:0;
Expand All @@ -48,7 +48,7 @@ int ARAY_update(UPDATE_FUNC_ARGS)
}
parts[np].temp = parts[i].temp;
} else if (!destroy) {
FOR_PMAP_POSITION(sim, x+nxi+nxx, y+nyi+nyy, rcount, ri, rnext)// TODO: not energy parts
FOR_PMAP_POSITION_NOENERGY(sim, x+nxi+nxx, y+nyi+nyy, rcount, ri, rnext)
{
int rt = parts[ri].type;
if (rt==PT_BRAY)
Expand Down Expand Up @@ -105,7 +105,7 @@ int ARAY_update(UPDATE_FUNC_ARGS)
}
}
} else if (destroy) {
FOR_PMAP_POSITION(sim, x+nxi+nxx, y+nyi+nyy, rcount, ri, rnext)// TODO: not energy parts
FOR_PMAP_POSITION_NOENERGY(sim, x+nxi+nxx, y+nyi+nyy, rcount, ri, rnext)
{
int rt = parts[ri].type;
if (rt==PT_BRAY) {
Expand Down
8 changes: 0 additions & 8 deletions src/simulation/elements/BIZR.cpp
Expand Up @@ -53,14 +53,6 @@ int BIZR_update(UPDATE_FUNC_ARGS)
}
}
}
FOR_PMAP_POSITION(sim, x, y, rcount, ri, rnext)
{
if (parts[ri].type==PT_PHOT)
{
part_change_type(ri, x, y, PT_ELEC);
parts[ri].ctype = 0;
}
}
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/simulation/elements/DLAY.cpp
Expand Up @@ -30,7 +30,7 @@ int DLAY_update(UPDATE_FUNC_ARGS)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
if (sim->pmap[y+ry][x+rx].count_notEnergy=0 || sim->is_spark_blocked(x,y,x+rx,y+ry))
if (sim->pmap[y+ry][x+rx].count_notEnergy==0 || sim->is_spark_blocked(x,y,x+rx,y+ry))
continue;
FOR_PMAP_POSITION_NOENERGY(sim, x+rx, y+ry, rcount, ri, rnext)
{
Expand Down
7 changes: 0 additions & 7 deletions src/simulation/elements/ELEC.cpp
Expand Up @@ -21,13 +21,6 @@ int ELEC_update(UPDATE_FUNC_ARGS)
int rcount, ri, rnext;
parts[i].pavg[0] = x;
parts[i].pavg[1] = y;
FOR_PMAP_POSITION_NOENERGY(sim, x, y, rcount, ri, rnext)
{
if(parts[ri].type==PT_GLOW)
{
part_change_type(i, x, y, PT_PHOT);
}
}
for (rx=-2; rx<=2; rx++)
for (ry=-2; ry<=2; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) {
Expand Down
6 changes: 3 additions & 3 deletions src/simulation/elements/EXOT.cpp
Expand Up @@ -51,7 +51,7 @@ int EXOT_update(UPDATE_FUNC_ARGS)
if (rt!=PT_EXOT && rt!=PT_BREL && rt!=PT_DMND && rt!=PT_CLNE && rt!=PT_PRTI && rt!=PT_PRTO && rt!=PT_PCLN && rt!=PT_VOID && rt!=PT_NBHL && rt!=PT_WARP)
{
sim->part_create(i, x, y, rt);
return 0;
return 1;
}
}
}
Expand All @@ -68,7 +68,7 @@ int EXOT_update(UPDATE_FUNC_ARGS)
if (parts[i].life<1001)
{
part_change_type(i, x, y, PT_WARP);
return 0;
return 1;
}
}
else if (parts[i].life<1001)
Expand All @@ -77,7 +77,7 @@ int EXOT_update(UPDATE_FUNC_ARGS)
{
parts[i].tmp2 = 6000;
part_change_type(i, x, y, PT_WARP);
return 0;
return 1;
}
if (parts[i].tmp2>100)
{
Expand Down
11 changes: 4 additions & 7 deletions src/simulation/elements/FILT.cpp
Expand Up @@ -81,19 +81,16 @@ int FILT_interactWavelengths(particle *cpart, int origWl)

int FILT_graphics(GRAPHICS_FUNC_ARGS)
{
int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f);
if (temp_bin < 0) temp_bin = 0;
if (temp_bin > 25) temp_bin = 25;
cpart->ctype = 0x1F << temp_bin;
int x, ctype = FILT_getWavelengths(cpart);
*colg = 0;
*colb = 0;
*colr = 0;
for (x=0; x<12; x++) {
*colr += (cpart->ctype >> (x+18)) & 1;
*colb += (cpart->ctype >> x) & 1;
*colr += (ctype >> (x+18)) & 1;
*colb += (ctype >> x) & 1;
}
for (x=0; x<12; x++)
*colg += (cpart->ctype >> (x+9)) & 1;
*colg += (ctype >> (x+9)) & 1;
x = 624/(*colr+*colg+*colb+1);
*cola = 127;
*colr *= x;
Expand Down
7 changes: 7 additions & 0 deletions src/simulation/elements/H2.cpp
Expand Up @@ -19,6 +19,7 @@ int H2_update(UPDATE_FUNC_ARGS)
{
int rx,ry,rt;
int rcount, ri, rnext;
bool typeChanged = false;
for (rx=-2; rx<3; rx++)
for (ry=-2; ry<3; ry++)
if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES && (rx || ry))
Expand All @@ -30,6 +31,7 @@ int H2_update(UPDATE_FUNC_ARGS)
{
part_change_type(ri,x+rx,y+ry,PT_WATR);
part_change_type(i,x,y,PT_OIL);
typeChanged = true;
}
if (pv[y/CELL][x/CELL] > 45.0f)
{
Expand All @@ -46,12 +48,14 @@ int H2_update(UPDATE_FUNC_ARGS)
parts[ri].temp=2473.15f;
parts[ri].tmp |= 1;
sim->part_create(i,x,y,PT_FIRE);
typeChanged = true;
parts[i].temp+=(rand()%100);
parts[i].tmp |= 1;
}
else if ((rt==PT_PLSM && !(parts[ri].tmp&4)) || (rt==PT_LAVA && parts[ri].ctype != PT_BMTL))
{
sim->part_create(i,x,y,PT_FIRE);
typeChanged = true;
parts[i].temp+=(rand()%100);
parts[i].tmp |= 1;
}
Expand All @@ -65,6 +69,7 @@ int H2_update(UPDATE_FUNC_ARGS)
int j;
float temp = parts[i].temp;
sim->part_create(i,x,y,PT_NBLE);
typeChanged = true;

j = sim->part_create(-3,x+rand()%3-1,y+rand()%3-1,PT_NEUT);
if (j>=0)
Expand Down Expand Up @@ -93,6 +98,8 @@ int H2_update(UPDATE_FUNC_ARGS)
pv[y/CELL][x/CELL] += 30;
}
}
if (typeChanged)
return 1;
return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions src/simulation/elements/LCRY.cpp
Expand Up @@ -53,6 +53,8 @@ int LCRY_update(UPDATE_FUNC_ARGS)
setto = 2;
break;
default:
parts[i].tmp = 0;
parts[i].life = 0;
return 0;
}

Expand Down

0 comments on commit 95cf5bd

Please sign in to comment.