diff options
| author | jacob1 <jfu614@gmail.com> | 2013-07-11 01:01:34 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-07-11 01:01:34 (GMT) |
| commit | c29bfd285de0b94b32860b783f686d14dfb8ba15 (patch) | |
| tree | 504440437e7ed25fa2be1496704d994a301b9758 /src/simulation/elements/PSTN.cpp | |
| parent | 081c58990e9445e34131f110fd0d86c9fda5961f (diff) | |
| download | powder-c29bfd285de0b94b32860b783f686d14dfb8ba15.zip powder-c29bfd285de0b94b32860b783f686d14dfb8ba15.tar.gz | |
fix bug where PSTN would write past tempParts and into other things, like corrupting TRON colors and making it all blue
Diffstat (limited to 'src/simulation/elements/PSTN.cpp')
| -rw-r--r-- | src/simulation/elements/PSTN.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index d880ee8..6dda77f 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -46,8 +46,8 @@ Element_PSTN::Element_PSTN() Graphics = &Element_PSTN::graphics; } -//#TPT-Directive ElementHeader Element_PSTN static int tempParts[128]; -int Element_PSTN::tempParts[128]; +//#TPT-Directive ElementHeader Element_PSTN static int tempParts[XRES] +int Element_PSTN::tempParts[XRES]; #define PISTON_INACTIVE 0x00 #define PISTON_RETRACT 0x01 @@ -170,7 +170,7 @@ int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int dir int posX, posY, r, spaces = 0, currentPos = 0; if (amount <= 0) return 0; - for(posX = stackX, posY = stackY; currentPos < maxSize + amount; posX += directionX, posY += directionY) { + for(posX = stackX, posY = stackY; currentPos < maxSize + amount && currentPos < XRES-1; posX += directionX, posY += directionY) { if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) { break; } @@ -257,7 +257,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct for(int j = 1; j <= amount; j++) sim->kill_part(sim->pmap[stackY+(directionY*-j)][stackX+(directionX*-j)]>>8); bool foundEnd = false; - for(posX = stackX, posY = stackY; currentPos < maxSize; posX += directionX, posY += directionY) { + for(posX = stackX, posY = stackY; currentPos < maxSize && currentPos < XRES-1; posX += directionX, posY += directionY) { if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) { break; } |
