summaryrefslogtreecommitdiff
path: root/src/simulation/elements/PSTN.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-01-26 19:44:05 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-01-26 19:44:05 (GMT)
commit486d26e40b1a11fbad2e203ec9bed88098504b77 (patch)
tree2bc2974c0c3f4be8d868b203b7e51cbe3056ac35 /src/simulation/elements/PSTN.cpp
parent03fde95719df5c917de84a8a791bd3f42e3c7859 (diff)
downloadpowder-486d26e40b1a11fbad2e203ec9bed88098504b77.zip
powder-486d26e40b1a11fbad2e203ec9bed88098504b77.tar.gz
Allow limited arm size from tmp2
Diffstat (limited to 'src/simulation/elements/PSTN.cpp')
-rw-r--r--src/simulation/elements/PSTN.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp
index d25f249..7d075a4 100644
--- a/src/simulation/elements/PSTN.cpp
+++ b/src/simulation/elements/PSTN.cpp
@@ -52,11 +52,12 @@ int Element_PSTN::tempParts[128];
//#TPT-Directive ElementHeader Element_PSTN static int tempPartAmount[128];
int Element_PSTN::tempPartAmount[128];
-#define PISTON_INACTIVE 0x00
-#define PISTON_RETRACT 0x01
-#define PISTON_EXTEND 0x02
-#define MAX_FRAME 0x0F
-#define DEFAULT_LIMIT 0x1F
+#define PISTON_INACTIVE 0x00
+#define PISTON_RETRACT 0x01
+#define PISTON_EXTEND 0x02
+#define MAX_FRAME 0x0F
+#define DEFAULT_LIMIT 0x1F
+#define DEFAULT_ARM_LIMIT 0xFF
//#TPT-Directive ElementHeader Element_PSTN static int update(UPDATE_FUNC_ARGS)
int Element_PSTN::update(UPDATE_FUNC_ARGS)
@@ -64,7 +65,8 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
if(parts[i].ctype)
return 0;
int maxSize = parts[i].tmp ? parts[i].tmp : DEFAULT_LIMIT;
- int state = parts[i].tmp2;
+ int armLimit = parts[i].tmp2 ? parts[i].tmp2 : DEFAULT_ARM_LIMIT;
+ int state = 0;
int r, nxx, nyy, nxi, nyi, rx, ry;
int directionX = 0, directionY = 0;
if (parts[i].life==0 && state == PISTON_INACTIVE) {
@@ -91,7 +93,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
r = pmap[y+ry][x+rx];
if (!r)
continue;
- if ((r&0xFF) == PT_PSTN && parts[r>>8].tmp2 == PISTON_INACTIVE) {
+ if ((r&0xFF) == PT_PSTN) {
directionX = rx;
directionY = ry;
{
@@ -119,13 +121,17 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
}
if(foundEnd) {
if(state == PISTON_EXTEND) {
- newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false);
- if(newSpace) {
- //Create new piston section
- for(int j = 0; j < newSpace; j++) {
- int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
- if (nr!=-1) {
- parts[nr].ctype = 1;
+ if(armCount+pistonCount > armLimit)
+ pistonCount = armLimit-armCount;
+ if(pistonCount > 0) {
+ newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false);
+ if(newSpace) {
+ //Create new piston section
+ for(int j = 0; j < newSpace; j++) {
+ int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
+ if (nr!=-1) {
+ parts[nr].ctype = 1;
+ }
}
}
}