summaryrefslogtreecommitdiff
path: root/src/client/GameSave.cpp
diff options
context:
space:
mode:
authorjacob1 <jfu614@gmail.com>2013-09-12 18:35:10 (GMT)
committer jacob1 <jfu614@gmail.com>2013-09-12 18:35:10 (GMT)
commitaa2ec3d1624bb4dd88b276d8ada6aae8073571fc (patch)
treee44ed8634d7dcba0ae41ca515736ec54c0198bf0 /src/client/GameSave.cpp
parent074a2226e168b4860e0e19ff50956752cdb51a77 (diff)
downloadpowder-aa2ec3d1624bb4dd88b276d8ada6aae8073571fc.zip
powder-aa2ec3d1624bb4dd88b276d8ada6aae8073571fc.tar.gz
fix SOAP crashes by making sure particle id's are between 0 and NPART. Also cut off .life to between 0 and 65535 when saving
Diffstat (limited to 'src/client/GameSave.cpp')
-rw-r--r--src/client/GameSave.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp
index 9f52440..e4dc1f7 100644
--- a/src/client/GameSave.cpp
+++ b/src/client/GameSave.cpp
@@ -1879,12 +1879,17 @@ char * GameSave::serialiseOPS(int & dataLength)
//Life (optional), 1 to 2 bytes
if(particles[i].life)
{
+ int life = particles[i].life;
+ if (life > 0xFFFF)
+ life = 0xFFFF;
+ else if (life < 0)
+ life = 0;
fieldDesc |= 1 << 1;
- partsData[partsDataLen++] = particles[i].life;
+ partsData[partsDataLen++] = life;
if(particles[i].life & 0xFF00)
{
fieldDesc |= 1 << 2;
- partsData[partsDataLen++] = particles[i].life >> 8;
+ partsData[partsDataLen++] = life >> 8;
}
}
@@ -1962,6 +1967,7 @@ char * GameSave::serialiseOPS(int & dataLength)
}
}
+ //Pavg, 4 bytes
//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))
{
@@ -1972,7 +1978,7 @@ char * GameSave::serialiseOPS(int & dataLength)
partsData[partsDataLen++] = ((int)particles[i].pavg[1])>>8;
}
- //Write the field descriptor;
+ //Write the field descriptor
partsData[fieldDescLoc] = fieldDesc;
partsData[fieldDescLoc+1] = fieldDesc>>8;