diff options
| author | jacob1 <jfu614@gmail.com> | 2013-02-22 21:50:33 (GMT) |
|---|---|---|
| committer | jacob1 <jfu614@gmail.com> | 2013-02-22 21:50:33 (GMT) |
| commit | 20d8eff7f526aa91997ec09266374d14775607ef (patch) | |
| tree | 45d786b2a9f5caa0ff11dc8e55a454a221022c50 /src/simulation/elements | |
| parent | 11f45e3e992adc83447375f3b4e3d340970c91e5 (diff) | |
| download | powder-20d8eff7f526aa91997ec09266374d14775607ef.zip powder-20d8eff7f526aa91997ec09266374d14775607ef.tar.gz | |
remove uneeded PSTN check, fix PSTN not retracting sometimes, fix PSTN bug where is wouldn't properly tell the difference between PSTN and PSTN arms
Diffstat (limited to 'src/simulation/elements')
| -rw-r--r-- | src/simulation/elements/PSTN.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 6496483..da67f76 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -94,6 +94,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) if (!r) continue; if ((r&0xFF) == PT_PSTN) { + bool movedPiston = false; directionX = rx; directionY = ry; { @@ -102,7 +103,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) int pistonCount = 0; int newSpace = 0; int armCount = 0; - for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; pistonCount < maxSize; nyy += nyi, nxx += nxi) { + for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) { if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) { break; } @@ -110,6 +111,13 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) if((r&0xFF)==PT_PSTN) { if(parts[r>>8].ctype) armCount++; + else if (armCount) + { + pistonEndX = x+nxi+nxx; + pistonEndY = y+nyi+nyy; + foundEnd = true; + break; + } else pistonCount++; } else { @@ -133,6 +141,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) parts[nr].ctype = 1; } } + movedPiston = true; } } } else if(state == PISTON_RETRACT) { @@ -147,12 +156,14 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) } MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true); //newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true); + movedPiston = true; } } } } - break; + if (movedPiston) + break; } } |
