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

This commit is contained in:
jacob1
2013-02-22 16:50:33 -05:00
parent 11f45e3e99
commit 20d8eff7f5

View File

@@ -94,6 +94,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
if (!r) if (!r)
continue; continue;
if ((r&0xFF) == PT_PSTN) { if ((r&0xFF) == PT_PSTN) {
bool movedPiston = false;
directionX = rx; directionX = rx;
directionY = ry; directionY = ry;
{ {
@@ -102,7 +103,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
int pistonCount = 0; int pistonCount = 0;
int newSpace = 0; int newSpace = 0;
int armCount = 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)) { if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
break; break;
} }
@@ -110,6 +111,13 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
if((r&0xFF)==PT_PSTN) { if((r&0xFF)==PT_PSTN) {
if(parts[r>>8].ctype) if(parts[r>>8].ctype)
armCount++; armCount++;
else if (armCount)
{
pistonEndX = x+nxi+nxx;
pistonEndY = y+nyi+nyy;
foundEnd = true;
break;
}
else else
pistonCount++; pistonCount++;
} else { } else {
@@ -133,6 +141,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
parts[nr].ctype = 1; parts[nr].ctype = 1;
} }
} }
movedPiston = true;
} }
} }
} else if(state == PISTON_RETRACT) { } else if(state == PISTON_RETRACT) {
@@ -147,11 +156,13 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
} }
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true); MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
//newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true); //newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
movedPiston = true;
} }
} }
} }
} }
if (movedPiston)
break; break;
} }
} }