- savegames prior to r5471 (Sandro's new features) are now compatible with the current version

- fix: incorrect group deletion caused crash when switching from assignment to truck

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5474 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2012-08-15 19:54:36 +00:00
parent cddfbcb9f9
commit 50b849997b
2 changed files with 37 additions and 14 deletions
+29 -12
View File
@@ -1740,24 +1740,41 @@ BOOLEAN SOLDIERTYPE::Load(HWFILE hFile)
numBytesRead = ReadFieldByField(hFile, &this->bTargetCubeLevel, sizeof(bTargetCubeLevel), sizeof(INT8), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->sLastTarget, sizeof(sLastTarget), sizeof(INT32), numBytesRead);
if(guiCurrentSaveGameVersion >= NCTH_DATATYPE_CHANGE){
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetX, sizeof(dPrevMuzzleOffsetX), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetY, sizeof(dPrevMuzzleOffsetY), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceX, sizeof(dPrevCounterForceX), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceY, sizeof(dPrevCounterForceY), sizeof(FLOAT), numBytesRead);
// Flugente: Sandro increased the size of these 4 varisbles to 2 (was 1) when the version got to DUAL_BURST_ADDED.
// So if we load an old game, we set the second value to 0.0f and pretend we read it. This way old savegames will be savegame compatible
if(guiCurrentSaveGameVersion < DUAL_BURST_ADDED)
{
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetX, sizeof(FLOAT), sizeof(FLOAT), numBytesRead);
this->dPrevMuzzleOffsetX[1] = 0.0f;
buffer += sizeof(FLOAT);
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetY, sizeof(FLOAT), sizeof(FLOAT), numBytesRead);
this->dPrevMuzzleOffsetY[1] = 0.0f;
buffer += sizeof(FLOAT);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceX, sizeof(FLOAT), sizeof(FLOAT), numBytesRead);
this->dPrevCounterForceX[1] = 0.0f;
buffer += sizeof(FLOAT);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceY, sizeof(FLOAT), sizeof(FLOAT), numBytesRead);
this->dPrevCounterForceY[1] = 0.0f;
buffer += sizeof(FLOAT);
}
else
{
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetX, sizeof(dPrevMuzzleOffsetX), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevMuzzleOffsetY, sizeof(dPrevMuzzleOffsetY), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceX, sizeof(dPrevCounterForceX), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dPrevCounterForceY, sizeof(dPrevCounterForceY), sizeof(FLOAT), numBytesRead);
}
} else {
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
}
// SANDRO: my attempt at making older save games compatible (usually fails, dunno why)
// with dual bursts, dPrevMuzzleOffsetX,dPrevMuzzleOffsetY,dPrevCounterForceX,dPrevCounterForceY was made dPrevMuzzleOffsetX[2], etc.
if(guiCurrentSaveGameVersion < DUAL_BURST_ADDED) {
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
buffer += sizeof(FLOAT);
}
if(guiCurrentSaveGameVersion >= NCTH_AUTOFIRE_UPDATE){
numBytesRead = ReadFieldByField(hFile, &this->dInitialMuzzleOffsetX, sizeof(dInitialMuzzleOffsetX), sizeof(FLOAT), numBytesRead);
numBytesRead = ReadFieldByField(hFile, &this->dInitialMuzzleOffsetY, sizeof(dInitialMuzzleOffsetY), sizeof(FLOAT), numBytesRead);
+8 -2
View File
@@ -598,9 +598,15 @@ BOOLEAN AddSoldierToVehicle( SOLDIERTYPE *pSoldier, INT32 iId )
}
else if( pSoldier->ubGroupID != 0 )
{
// Flugente 2012-08-15: had very weird behaviour here. The outcommented code below failed, because the group size wasn't 0, which then threw an Assert()-error.
// This happened in r5468 when assinging a merc on repair duty to the truck, switching back and forth between the two
// I'm fixing it by using RemovePlayerFromGroup(), which seems to be intended just for that.
// However, I am at a complete loss as to why this piece of code only throws errors now, seems to me it hasn't changed in ages. Please correct if the error is actually somewhere else
RemovePlayerFromGroup( pSoldier->ubGroupID, pSoldier );
// destroy group and set to zero
RemoveGroup( pSoldier->ubGroupID );
pSoldier->ubGroupID = 0;
//RemoveGroup( pSoldier->ubGroupID );
//pSoldier->ubGroupID = 0;
}
if( ( pSoldier->bAssignment != VEHICLE ) || ( pSoldier->iVehicleId != iId ) )