PSTN: allow movement amount to be set by temperature. Requires major version increment.

This commit is contained in:
jacksonmj
2014-11-04 15:38:41 +00:00
parent 57409b0b41
commit fb796c873b
2 changed files with 17 additions and 9 deletions

View File

@@ -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++;

View File

@@ -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<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0)) {
if (!(x+nxx<XRES && y+nyy<YRES && 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;
}