Permalink
Browse files

PSTN: allow zero or negative contributions towards movement amount

Note that final movement amount < 0 means no movement, it will not reverse the movement direction. This is to keep interpretation of inputs simple - PSCN always extends, other conductors always retract.
  • Loading branch information...
jacksonmj committed Feb 24, 2015
1 parent cd71a6d commit 91e871d0eaf2c36df4ec5337cc15ff2d871be1fe
Showing with 2 additions and 5 deletions.
  1. +2 −5 src/simulation/elements/PSTN.cpp
@@ -117,10 +117,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
}
else
{
if (parts[r>>8].temp>283.15)
pistonCount += (int)((parts[r>>8].temp-268.15)/10);// how many tens of degrees above 0 C, rounded to nearest 10
else
pistonCount++;
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 {
pistonEndX = x+nxx;
@@ -154,7 +151,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
} else if(state == PISTON_RETRACT) {
if(pistonCount > armCount)
pistonCount = armCount;
if(armCount) {
if(armCount && pistonCount > 0) {
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true, parts[i].ctype, true);
movedPiston = true;
}

0 comments on commit 91e871d

Please sign in to comment.