Merge branch 'master' of git@github.com:FacialTurd/The-Powder-Toy.git
This commit is contained in:
commit
de6bb6a960
@ -944,6 +944,9 @@ void GameSave::readOPS(char * data, int dataLength)
|
|||||||
particles[newIndex].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
|
particles[newIndex].ctype = (((unsigned char)(firw_data[caddress]))<<16) | (((unsigned char)(firw_data[caddress+1]))<<8) | ((unsigned char)(firw_data[caddress+2]));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PT_PSTN:
|
||||||
|
if (savedVersion < 87 && particles[newIndex].ctype)
|
||||||
|
particles[newIndex].life = 1;
|
||||||
}
|
}
|
||||||
newIndex++;
|
newIndex++;
|
||||||
}
|
}
|
||||||
|
@ -2849,10 +2849,10 @@ int Simulation::create_part(int p, int x, int y, int tv)
|
|||||||
parts[pmap[y][x]>>8].ctype = t;
|
parts[pmap[y][x]>>8].ctype = t;
|
||||||
if (t == PT_LIFE && v < NGOLALT && drawOn != PT_STOR) parts[pmap[y][x]>>8].tmp = v;
|
if (t == PT_LIFE && v < NGOLALT && drawOn != PT_STOR) parts[pmap[y][x]>>8].tmp = v;
|
||||||
}
|
}
|
||||||
else if (drawOn == PT_DTEC && drawOn != t)
|
else if ((drawOn == PT_DTEC || (drawOn == PT_PSTN && t != PT_FRME)) && drawOn != t)
|
||||||
{
|
{
|
||||||
parts[pmap[y][x]>>8].ctype = t;
|
parts[pmap[y][x]>>8].ctype = t;
|
||||||
if (t==PT_LIFE && v<NGOLALT)
|
if (drawOn == PT_DTEC && t==PT_LIFE && v<NGOLALT)
|
||||||
parts[pmap[y][x]>>8].tmp = v;
|
parts[pmap[y][x]>>8].tmp = v;
|
||||||
}
|
}
|
||||||
else if (drawOn == PT_CRAY && drawOn != t && drawOn != PT_PSCN && drawOn != PT_INST && drawOn != PT_METL)
|
else if (drawOn == PT_CRAY && drawOn != t && drawOn != PT_PSCN && drawOn != PT_INST && drawOn != PT_METL)
|
||||||
|
@ -48,10 +48,11 @@ Element_FRME::Element_FRME()
|
|||||||
//#TPT-Directive ElementHeader Element_FRME static int graphics(GRAPHICS_FUNC_ARGS)
|
//#TPT-Directive ElementHeader Element_FRME static int graphics(GRAPHICS_FUNC_ARGS)
|
||||||
int Element_FRME::graphics(GRAPHICS_FUNC_ARGS)
|
int Element_FRME::graphics(GRAPHICS_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
if(cpart->ctype)
|
if(cpart->tmp)
|
||||||
{
|
{
|
||||||
*colr -= 60;
|
*colr += 30;
|
||||||
*colg -= 60;
|
*colg += 30;
|
||||||
|
*colb += 30;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ Element_PSTN::Element_PSTN()
|
|||||||
Description = "Piston, extends and pushes particles";
|
Description = "Piston, extends and pushes particles";
|
||||||
|
|
||||||
State = ST_SOLID;
|
State = ST_SOLID;
|
||||||
Properties = TYPE_SOLID|PROP_LIFE_DEC;
|
Properties = TYPE_SOLID;
|
||||||
|
|
||||||
LowPressure = IPL;
|
LowPressure = IPL;
|
||||||
LowPressureTransition = NT;
|
LowPressureTransition = NT;
|
||||||
@ -62,14 +62,14 @@ int Element_PSTN::tempPartAmount[128];
|
|||||||
//#TPT-Directive ElementHeader Element_PSTN static int update(UPDATE_FUNC_ARGS)
|
//#TPT-Directive ElementHeader Element_PSTN static int update(UPDATE_FUNC_ARGS)
|
||||||
int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
if(parts[i].ctype)
|
if(parts[i].life)
|
||||||
return 0;
|
return 0;
|
||||||
int maxSize = parts[i].tmp ? parts[i].tmp : DEFAULT_LIMIT;
|
int maxSize = parts[i].tmp ? parts[i].tmp : DEFAULT_LIMIT;
|
||||||
int armLimit = parts[i].tmp2 ? parts[i].tmp2 : DEFAULT_ARM_LIMIT;
|
int armLimit = parts[i].tmp2 ? parts[i].tmp2 : DEFAULT_ARM_LIMIT;
|
||||||
int state = 0;
|
int state = 0;
|
||||||
int r, nxx, nyy, nxi, nyi, rx, ry;
|
int r, nxx, nyy, nxi, nyi, rx, ry;
|
||||||
int directionX = 0, directionY = 0;
|
int directionX = 0, directionY = 0;
|
||||||
if (parts[i].life==0 && state == PISTON_INACTIVE) {
|
if (state == PISTON_INACTIVE) {
|
||||||
for (rx=-2; rx<3; rx++)
|
for (rx=-2; rx<3; rx++)
|
||||||
for (ry=-2; ry<3; ry++)
|
for (ry=-2; ry<3; ry++)
|
||||||
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry) && (!rx || !ry))
|
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry) && (!rx || !ry))
|
||||||
@ -109,7 +109,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
|||||||
}
|
}
|
||||||
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
r = pmap[y+nyi+nyy][x+nxi+nxx];
|
||||||
if((r&0xFF)==PT_PSTN) {
|
if((r&0xFF)==PT_PSTN) {
|
||||||
if(parts[r>>8].ctype)
|
if(parts[r>>8].life)
|
||||||
armCount++;
|
armCount++;
|
||||||
else if (armCount)
|
else if (armCount)
|
||||||
{
|
{
|
||||||
@ -132,13 +132,13 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
|||||||
if(armCount+pistonCount > armLimit)
|
if(armCount+pistonCount > armLimit)
|
||||||
pistonCount = armLimit-armCount;
|
pistonCount = armLimit-armCount;
|
||||||
if(pistonCount > 0) {
|
if(pistonCount > 0) {
|
||||||
newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false);
|
newSpace = MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, false, parts[i].ctype, true);
|
||||||
if(newSpace) {
|
if(newSpace) {
|
||||||
//Create new piston section
|
//Create new piston section
|
||||||
for(int j = 0; j < newSpace; j++) {
|
for(int j = 0; j < newSpace; j++) {
|
||||||
int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
|
int nr = sim->create_part(-3, pistonEndX+(nxi*j), pistonEndY+(nyi*j), PT_PSTN);
|
||||||
if (nr!=-1) {
|
if (nr > -1) {
|
||||||
parts[nr].ctype = 1;
|
parts[nr].life = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
movedPiston = true;
|
movedPiston = true;
|
||||||
@ -148,7 +148,7 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
|||||||
if(pistonCount > armCount)
|
if(pistonCount > armCount)
|
||||||
pistonCount = armCount;
|
pistonCount = armCount;
|
||||||
if(armCount) {
|
if(armCount) {
|
||||||
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true);
|
MoveStack(sim, pistonEndX, pistonEndY, directionX, directionY, maxSize, pistonCount, true, parts[i].ctype, true);
|
||||||
movedPiston = true;
|
movedPiston = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,18 +162,18 @@ int Element_PSTN::update(UPDATE_FUNC_ARGS)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#TPT-Directive ElementHeader Element_PSTN static int CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int size, int amount, bool retract)
|
//#TPT-Directive ElementHeader Element_PSTN static int CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block)
|
||||||
int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int size, int amount, bool retract)
|
int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block)
|
||||||
{
|
{
|
||||||
int posX, posY, r, spaces = 0, currentPos = 0;
|
int posX, posY, r, spaces = 0, currentPos = 0;
|
||||||
if (amount == 0)
|
if (amount == 0)
|
||||||
return 0;
|
return 0;
|
||||||
for(posX = stackX, posY = stackY; currentPos < size + amount; posX += directionX, posY += directionY) {
|
for(posX = stackX, posY = stackY; currentPos < maxSize + amount; posX += directionX, posY += directionY) {
|
||||||
if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) {
|
if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r = sim->pmap[posY][posX];
|
r = sim->pmap[posY][posX];
|
||||||
if (sim->IsWallBlocking(posX, posY, 0)/* || (r&0xFF) == PT_INSL*/)
|
if (sim->IsWallBlocking(posX, posY, 0) || (block && (r&0xFF) == block))
|
||||||
break;
|
break;
|
||||||
if(!r) {
|
if(!r) {
|
||||||
spaces++;
|
spaces++;
|
||||||
@ -181,7 +181,7 @@ int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int dir
|
|||||||
if(spaces >= amount)
|
if(spaces >= amount)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if(currentPos < size && !retract)
|
if(currentPos < maxSize && !retract)
|
||||||
tempParts[currentPos++] = r>>8;
|
tempParts[currentPos++] = r>>8;
|
||||||
else
|
else
|
||||||
return spaces;
|
return spaces;
|
||||||
@ -193,8 +193,8 @@ int Element_PSTN::CanMoveStack(Simulation * sim, int stackX, int stackY, int dir
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#TPT-Directive ElementHeader Element_PSTN static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int size, int amount, bool retract, int callDepth = 0)
|
//#TPT-Directive ElementHeader Element_PSTN static int MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth = 0)
|
||||||
int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int size, int amount, bool retract, int callDepth)
|
int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int directionX, int directionY, int maxSize, int amount, bool retract, int block, bool sticky, int callDepth)
|
||||||
{
|
{
|
||||||
bool foundParts = false;
|
bool foundParts = false;
|
||||||
int posX, posY, r, spaces = 0, currentPos = 0;
|
int posX, posY, r, spaces = 0, currentPos = 0;
|
||||||
@ -210,7 +210,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
posY = stackY + (c*newY);
|
posY = stackY + (c*newY);
|
||||||
posX = stackX + (c*newX);
|
posX = stackX + (c*newX);
|
||||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
||||||
int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, size, amount, retract);
|
int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, maxSize, amount, retract, block);
|
||||||
if(val < amount)
|
if(val < amount)
|
||||||
amount = val;
|
amount = val;
|
||||||
} else {
|
} else {
|
||||||
@ -222,7 +222,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
posY = stackY - (c*newY);
|
posY = stackY - (c*newY);
|
||||||
posX = stackX - (c*newX);
|
posX = stackX - (c*newX);
|
||||||
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
if (posX < XRES && posY < YRES && posX >= 0 && posY >= 0 && (sim->pmap[posY][posX]&0xFF) == PT_FRME) {
|
||||||
int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, size, amount, retract);
|
int val = CanMoveStack(sim, posX+realDirectionX, posY+realDirectionY, realDirectionX, realDirectionY, maxSize, amount, retract, block);
|
||||||
if(val < amount)
|
if(val < amount)
|
||||||
amount = val;
|
amount = val;
|
||||||
} else {
|
} else {
|
||||||
@ -235,19 +235,19 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
for(int c = 1; c < maxRight; c++) {
|
for(int c = 1; c < maxRight; c++) {
|
||||||
posY = stackY + (c*newY);
|
posY = stackY + (c*newY);
|
||||||
posX = stackX + (c*newX);
|
posX = stackX + (c*newX);
|
||||||
MoveStack(sim, posX, posY, directionX, directionY, size, amount, retract, 1);
|
MoveStack(sim, posX, posY, directionX, directionY, maxSize, amount, retract, block, !sim->parts[sim->pmap[posY][posX]>>8].tmp, 1);
|
||||||
}
|
}
|
||||||
for(int c = 1; c < maxLeft; c++) {
|
for(int c = 1; c < maxLeft; c++) {
|
||||||
posY = stackY - (c*newY);
|
posY = stackY - (c*newY);
|
||||||
posX = stackX - (c*newX);
|
posX = stackX - (c*newX);
|
||||||
MoveStack(sim, posX, posY, directionX, directionY, size, amount, retract, 1);
|
MoveStack(sim, posX, posY, directionX, directionY, maxSize, amount, retract, block, !sim->parts[sim->pmap[posY][posX]>>8].tmp, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove arm section if retracting with FRME
|
//Remove arm section if retracting with FRME
|
||||||
if (retract)
|
if (retract)
|
||||||
for(int j = 1; j <= amount; j++)
|
for(int j = 1; j <= amount; j++)
|
||||||
sim->kill_part(sim->pmap[stackY+(directionY*-j)][stackX+(directionX*-j)]>>8);
|
sim->kill_part(sim->pmap[stackY+(directionY*-j)][stackX+(directionX*-j)]>>8);
|
||||||
return MoveStack(sim, stackX, stackY, directionX, directionY, size, amount, retract, 1);
|
return MoveStack(sim, stackX, stackY, directionX, directionY, maxSize, amount, retract, block, !sim->parts[sim->pmap[stackY][stackX]>>8].tmp, 1);
|
||||||
}
|
}
|
||||||
if(retract){
|
if(retract){
|
||||||
//Remove arm section if retracting without FRME
|
//Remove arm section if retracting without FRME
|
||||||
@ -255,12 +255,12 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
for(int j = 1; j <= amount; j++)
|
for(int j = 1; j <= amount; j++)
|
||||||
sim->kill_part(sim->pmap[stackY+(directionY*-j)][stackX+(directionX*-j)]>>8);
|
sim->kill_part(sim->pmap[stackY+(directionY*-j)][stackX+(directionX*-j)]>>8);
|
||||||
bool foundEnd = false;
|
bool foundEnd = false;
|
||||||
for(posX = stackX, posY = stackY; currentPos < size; posX += directionX, posY += directionY) {
|
for(posX = stackX, posY = stackY; currentPos < maxSize; posX += directionX, posY += directionY) {
|
||||||
if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) {
|
if (!(posX < XRES && posY < YRES && posX >= 0 && posY >= 0)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
r = sim->pmap[posY][posX];
|
r = sim->pmap[posY][posX];
|
||||||
if(!r) {
|
if(!r || (r&0xFF) == block || (!sticky && (r&0xFF) != PT_FRME)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
foundParts = true;
|
foundParts = true;
|
||||||
@ -281,13 +281,13 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
if(!foundParts && foundEnd)
|
if(!foundParts && foundEnd)
|
||||||
return amount;
|
return amount;
|
||||||
} else {
|
} else {
|
||||||
currentPos = CanMoveStack(sim, stackX, stackY, directionX, directionY, size, amount, retract);
|
currentPos = CanMoveStack(sim, stackX, stackY, directionX, directionY, maxSize, amount, retract, block);
|
||||||
if(currentPos){
|
if(currentPos){
|
||||||
//Move particles
|
//Move particles
|
||||||
int possibleMovement = 0;
|
int possibleMovement = 0;
|
||||||
for(int j = currentPos-1; j >= 0; j--) {
|
for(int j = currentPos-1; j >= 0; j--) {
|
||||||
int jP = tempParts[j];
|
int jP = tempParts[j];
|
||||||
if(jP == -1) {
|
if(jP < 0) {
|
||||||
possibleMovement++;
|
possibleMovement++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ int Element_PSTN::MoveStack(Simulation * sim, int stackX, int stackY, int direct
|
|||||||
//#TPT-Directive ElementHeader Element_PSTN static int graphics(GRAPHICS_FUNC_ARGS)
|
//#TPT-Directive ElementHeader Element_PSTN static int graphics(GRAPHICS_FUNC_ARGS)
|
||||||
int Element_PSTN::graphics(GRAPHICS_FUNC_ARGS)
|
int Element_PSTN::graphics(GRAPHICS_FUNC_ARGS)
|
||||||
{
|
{
|
||||||
if(cpart->ctype)
|
if(cpart->life)
|
||||||
{
|
{
|
||||||
*colr -= 60;
|
*colr -= 60;
|
||||||
*colg -= 60;
|
*colg -= 60;
|
||||||
|
Reference in New Issue
Block a user