Permalink
Browse files

PSTN: compatibility with old saves with non-PSTN particles layered on…

… 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 d0cf82de03b6d33fea4e5e5c0418625fc78d46e8
Showing with 12 additions and 2 deletions.
  1. +12 −2 src/simulation/elements/PSTN.cpp
@@ -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)
@@ -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;

0 comments on commit d0cf82d

Please sign in to comment.