Skip to content

Commit

Permalink
PSTN: compatibility with old saves with non-PSTN particles layered on…
Browse files Browse the repository at this point in the history
… top of the starting PSTN particle

P.S. don't use layering, this commit is exactly why it's bad. Layering makes adding new functionality without changing existing behaviour much more difficult, and makes the code more complicated than necessary.
  • Loading branch information
jacksonmj committed Oct 22, 2015
1 parent 7f50529 commit d0cf82d
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/simulation/elements/PSTN.cpp
Expand Up @@ -105,7 +105,8 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
break;
}
r = pmap[y+nyy][x+nxx];
if((r&0xFF)==PT_PSTN) {
if((r&0xFF)==PT_PSTN)
{
if(parts[r>>8].life)
armCount++;
else if (armCount)
Expand All @@ -119,7 +120,16 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
{
pistonCount += floor((parts[r>>8].temp-268.15)/10);// How many tens of degrees above 0 C, rounded to nearest ten degrees. Can be negative.
}
} else {
}
else if (nxx==0 && nyy==0)
{
// compatibility with BAD THINGS: starting PSTN layered underneath other particles
// (in v90, it started scanning from the neighbouring particle, so could not break out of loop at offset=(0,0))
pistonCount += floor((parts[i].temp-268.15)/10);
continue;
}
else
{
pistonEndX = x+nxx;
pistonEndY = y+nyy;
foundEnd = true;
Expand Down

0 comments on commit d0cf82d

Please sign in to comment.