diff --git a/src/client/GameSave.cpp b/src/client/GameSave.cpp index ba78b0d07..892e73121 100644 --- a/src/client/GameSave.cpp +++ b/src/client/GameSave.cpp @@ -2254,14 +2254,37 @@ char * GameSave::serialiseOPS(unsigned 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)) + // save pavg if there's useful pavg to save + // and either we save pressure data too + // or the current particle is not one that cares about pressure + if (particles[i].pavg[0] || particles[i].pavg[1]) { - 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; + float pavg0 = particles[i].pavg[0]; + float pavg1 = particles[i].pavg[1]; + switch (particles[i].type) + { + // List of elements that save pavg with a multiplicative bias of 2**6 + // (or not at all if pressure is not saved). + // If you change this list, change it in Simulation::Load too! + case PT_QRTZ: + case PT_GLAS: + case PT_TUNG: + if (!hasPressure) + { + break; + } + pavg0 *= 64; + pavg1 *= 64; + // fallthrough! + + default: + fieldDesc |= 1 << 13; + partsData[partsDataLen++] = (int)pavg0; + partsData[partsDataLen++] = ((int)pavg0)>>8; + partsData[partsDataLen++] = (int)pavg1; + partsData[partsDataLen++] = ((int)pavg1)>>8; + break; + } } //Write the field descriptor diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 5c2e962b7..89e36b13b 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -233,6 +233,24 @@ int Simulation::Load(int fullX, int fullY, GameSave * save, bool includePressure case PT_SOAP: soapList.insert(std::pair(n, i)); break; + + // List of elements that load pavg with a multiplicative bias of 2**6 + // (or not at all if pressure is not loaded). + // If you change this list, change it in GameSave::serialiseOPS too! + case PT_QRTZ: + case PT_GLAS: + case PT_TUNG: + if (!includePressure) + { + parts[i].pavg[0] = 0; + parts[i].pavg[1] = 0; + } + else + { + parts[i].pavg[0] /= 64; + parts[i].pavg[1] /= 64; + } + break; } } parts_lastActiveIndex = NPART-1; @@ -437,11 +455,14 @@ GameSave * Simulation::Save(int fullX, int fullY, int fullX2, int fullY2, bool i newSave->velocityX[saveBlockY][saveBlockX] = vx[saveBlockY+blockY][saveBlockX+blockX]; newSave->velocityY[saveBlockY][saveBlockX] = vy[saveBlockY+blockY][saveBlockX+blockX]; newSave->ambientHeat[saveBlockY][saveBlockX] = hv[saveBlockY+blockY][saveBlockX+blockX]; - newSave->hasPressure = true; - newSave->hasAmbientHeat = true; } } } + if (includePressure) + { + newSave->hasPressure = true; + newSave->hasAmbientHeat = true; + } newSave->stkm.rocketBoots1 = player.rocketBoots; newSave->stkm.rocketBoots2 = player2.rocketBoots;