From d0cf82de03b6d33fea4e5e5c0418625fc78d46e8 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Thu, 22 Oct 2015 22:33:06 +0100 Subject: [PATCH] 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. --- src/simulation/elements/PSTN.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 8c6d91a36..3c7a473b8 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/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;