Skip to content

Commit

Permalink
PSTN: allow zero or negative contributions towards movement amount
Browse files Browse the repository at this point in the history
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 91e871d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/simulation/elements/PSTN.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 91e871d

Please sign in to comment.