summaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-09-12 00:41:43 (GMT)
committer jacob1 <jfu614@gmail.com>2013-09-12 00:41:43 (GMT)
commit332aa25bf6aa938fe3217a7a6622bf5f4c2f3201 (patch)
tree910075200d0eb324641f6df3e46b9a7cdd594756 /src/client
parent09c54b596bfaa13ae5009bbe4d5e6a0131ba50d2 (diff)
downloadpowder-332aa25bf6aa938fe3217a7a6622bf5f4c2f3201.zip
powder-332aa25bf6aa938fe3217a7a6622bf5f4c2f3201.tar.gz
save pavg[] in saves, for VIRS, PIPE, and STOR
Diffstat (limited to 'src/client')
-rw-r--r--src/client/GameSave.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index ddb4ef4..9f52440 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -924,6 +924,19 @@ void GameSave::readOPS(char * data, int dataLength)
}
}
+ //Read pavg
+ if(fieldDescriptor & 0x2000)
+ {
+ if(i+3 >= partsDataLen) goto fail;
+ int pavg;
+ pavg = partsData[i++];
+ pavg |= (((unsigned)partsData[i++]) << 8);
+ particles[newIndex].pavg[0] = (float)pavg;
+ pavg = partsData[i++];
+ pavg |= (((unsigned)partsData[i++]) << 8);
+ particles[newIndex].pavg[1] = (float)pavg;
+ }
+
//Particle specific parsing:
switch(particles[newIndex].type)
{
@@ -1814,7 +1827,7 @@ char * GameSave::serialiseOPS(int & dataLength)
//Copy parts data
/* Field descriptor format:
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
- | tmp2[2] | tmp2 | ctype[2] | vy | vx | dcololour | ctype[1] | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len|
+ | pavg | tmp[3+4] | tmp2[2] | tmp2 | ctype[2] | vy | vx | dcololour | ctype[1] | tmp[2] | tmp[1] | life[2] | life[1] | temp dbl len|
life[2] means a second byte (for a 16 bit field) if life[1] is present
*/
partsData = (unsigned char *)malloc(NPART * (sizeof(Particle)+1));
@@ -1875,7 +1888,7 @@ char * GameSave::serialiseOPS(int & dataLength)
}
}
- //Tmp (optional), 1 to 2 bytes
+ //Tmp (optional), 1, 2, or 4 bytes
if(particles[i].tmp)
{
fieldDesc |= 1 << 3;
@@ -1949,6 +1962,16 @@ char * GameSave::serialiseOPS(int & dataLength)
}
}
+ //Don't save pavg for things that break under pressure, because then they will break when the save is loaded, since pressure isn't also loaded
+ if ((particles[i].pavg[0] || particles[i].pavg[1]) && !(particles[i].type == PT_QRTZ || particles[i].type == PT_GLAS || particles[i].type == PT_TUNG))
+ {
+ fieldDesc |= 1 << 13;
+ partsData[partsDataLen++] = (int)particles[i].pavg[0];
+ partsData[partsDataLen++] = ((int)particles[i].pavg[0])>>8;
+ partsData[partsDataLen++] = (int)particles[i].pavg[1];
+ partsData[partsDataLen++] = ((int)particles[i].pavg[1])>>8;
+ }
+
//Write the field descriptor;
partsData[fieldDescLoc] = fieldDesc;
partsData[fieldDescLoc+1] = fieldDesc>>8;