mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-01 04:01:56 +02:00
PSTN: allow movement amount to be set by temperature. Requires major version increment.
This commit is contained in:
@@ -979,6 +979,8 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
case PT_PSTN:
|
case PT_PSTN:
|
||||||
if (savedVersion < 87 && particles[newIndex].ctype)
|
if (savedVersion < 87 && particles[newIndex].ctype)
|
||||||
particles[newIndex].life = 1;
|
particles[newIndex].life = 1;
|
||||||
|
if (savedVersion < 91)
|
||||||
|
particles[newIndex].temp = 283.15;
|
||||||
break;
|
break;
|
||||||
case PT_STKM:
|
case PT_STKM:
|
||||||
case PT_STKM2:
|
case PT_STKM2:
|
||||||
@@ -1008,6 +1010,7 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
{
|
{
|
||||||
particles[newIndex].flags |= FLAG_PHOTDECO;
|
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
|
//note: PSv was used in version 77.0 and every version before, add something in PSv too if the element is that old
|
||||||
newIndex++;
|
newIndex++;
|
||||||
|
@@ -26,7 +26,7 @@ Element_PSTN::Element_PSTN()
|
|||||||
|
|
||||||
Weight = 100;
|
Weight = 100;
|
||||||
|
|
||||||
Temperature = R_TEMP+0.0f +273.15f;
|
Temperature = 283.15f;
|
||||||
HeatConduct = 0;
|
HeatConduct = 0;
|
||||||
Description = "Piston, extends and pushes particles.";
|
Description = "Piston, extends and pushes particles.";
|
||||||
|
|
||||||
@@ -95,31 +95,36 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
|||||||
bool movedPiston = false;
|
bool movedPiston = false;
|
||||||
bool foundEnd = false;
|
bool foundEnd = false;
|
||||||
int pistonEndX, pistonEndY;
|
int pistonEndX, pistonEndY;
|
||||||
int pistonCount = 0;
|
int pistonCount = -1;// number of PSTN particles minus 1
|
||||||
int newSpace = 0;
|
int newSpace = 0;
|
||||||
int armCount = 0;
|
int armCount = 0;
|
||||||
directionX = rx;
|
directionX = rx;
|
||||||
directionY = ry;
|
directionY = ry;
|
||||||
for (nxx = 0, nyy = 0, nxi = directionX, nyi = directionY; ; 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+nxx<XRES && y+nyy<YRES && x+nxx >= 0 && y+nyy >= 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
r = pmap[y+nyy][x+nxx];
|
||||||
if((r&0xFF)==PT_PSTN) {
|
if((r&0xFF)==PT_PSTN) {
|
||||||
if(parts[r>>8].life)
|
if(parts[r>>8].life)
|
||||||
armCount++;
|
armCount++;
|
||||||
else if (armCount)
|
else if (armCount)
|
||||||
{
|
{
|
||||||
pistonEndX = x+nxi+nxx;
|
pistonEndX = x+nxx;
|
||||||
pistonEndY = y+nyi+nyy;
|
pistonEndY = y+nyy;
|
||||||
foundEnd = true;
|
foundEnd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
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 {
|
} else {
|
||||||
pistonEndX = x+nxi+nxx;
|
pistonEndX = x+nxx;
|
||||||
pistonEndY = y+nyi+nyy;
|
pistonEndY = y+nyy;
|
||||||
foundEnd = true;
|
foundEnd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user