From fb796c873b4db200db26df6ef9c108811bc47e62 Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Tue, 4 Nov 2014 15:38:41 +0000 Subject: [PATCH] PSTN: allow movement amount to be set by temperature. Requires major version increment. --- src/client/GameSave.cpp | 3 +++ src/simulation/elements/PSTN.cpp | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index f185f7154..c36edfc4c 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -979,6 +979,8 @@ void GameSave::readOPS(char * data, int dataLength) case PT_PSTN: if (savedVersion < 87 && particles[newIndex].ctype) particles[newIndex].life = 1; + if (savedVersion < 91) + particles[newIndex].temp = 283.15; break; case PT_STKM: case PT_STKM2: @@ -1008,6 +1010,7 @@ void GameSave::readOPS(char * data, int dataLength) { particles[newIndex].flags |= FLAG_PHOTDECO; } + break; } //note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old newIndex++; diff --git a/src/simulation/elements/PSTN.cpp b/src/simulation/elements/PSTN.cpp index 6dda77ffc..758b88039 100644 --- a/src/simulation/elements/PSTN.cpp +++ b/src/simulation/elements/PSTN.cpp @@ -26,7 +26,7 @@ Element_PSTN::Element_PSTN() Weight = 100; - Temperature = R_TEMP+0.0f +273.15f; + Temperature = 283.15f; HeatConduct = 0; Description = "Piston, extends and pushes particles."; @@ -95,31 +95,36 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS) bool movedPiston = false; bool foundEnd = false; int pistonEndX, pistonEndY; - int pistonCount = 0; + int pistonCount = -1;// number of PSTN particles minus 1 int newSpace = 0; int armCount = 0; directionX = rx; directionY = ry; for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; nyy += nyi, nxx += nxi) { - if (!(x+nxi+nxx= 0 && y+nyi+nyy >= 0)) { + if (!(x+nxx= 0 && y+nyy >= 0)) { break; } - r = pmap[y+nyi+nyy][x+nxi+nxx]; + r = pmap[y+nyy][x+nxx]; if((r&0xFF)==PT_PSTN) { if(parts[r>>8].life) armCount++; else if (armCount) { - pistonEndX = x+nxi+nxx; - pistonEndY = y+nyi+nyy; + pistonEndX = x+nxx; + pistonEndY = y+nyy; foundEnd = true; break; } else - pistonCount++; + { + 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++; + } } else { - pistonEndX = x+nxi+nxx; - pistonEndY = y+nyi+nyy; + pistonEndX = x+nxx; + pistonEndY = y+nyy; foundEnd = true; break; }