From e40b06267273b2c24bc0a9e6c668c4276ec802bb Mon Sep 17 00:00:00 2001 From: Sergeant_Kolja Date: Fri, 23 Feb 2007 20:59:37 +0000 Subject: [PATCH] fixed some crashes when loading 4xx built savegames. The game can continue, but You'll probably loose your vehicles. The Team in the Laptop/Personel also consist only of Your AVATAR, but in strategic map the team is complete. This is not a very well finished fix. Only glued some NULL assigned pointers. I recomend to NOT load too old savegames. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@733 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Strategic AI.cpp | 6 ++++++ Strategic/Strategic Pathing.cpp | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Strategic/Strategic AI.cpp b/Strategic/Strategic AI.cpp index 7eee4bcb..cfc21870 100644 --- a/Strategic/Strategic AI.cpp +++ b/Strategic/Strategic AI.cpp @@ -3595,6 +3595,12 @@ BOOLEAN LoadStrategicAI( HWFILE hFile ) } if( ubSAIVersion < 19 ) { + if( !gGarrisonGroup ) /* Sergeant Kolja, 2007-02-20: loading an older Qicksave, I crashed with NULL gGarrisonGroup[] */ + { + gGarrisonGroup = (GARRISON_GROUP*)MemAlloc( sizeof( gOrigGarrisonGroup ) ); + Assert( gGarrisonGroup ); + memcpy( gGarrisonGroup, gOrigGarrisonGroup, sizeof( gOrigGarrisonGroup ) ); + } //Clear the garrison in C5 gArmyComp[ gGarrisonGroup[ SectorInfo[ SEC_C5 ].ubGarrisonID ].ubComposition ].bPriority = 0; gArmyComp[ gGarrisonGroup[ SectorInfo[ SEC_C5 ].ubGarrisonID ].ubComposition ].bDesiredPopulation = 0; diff --git a/Strategic/Strategic Pathing.cpp b/Strategic/Strategic Pathing.cpp index 82924cc9..3d141404 100644 --- a/Strategic/Strategic Pathing.cpp +++ b/Strategic/Strategic Pathing.cpp @@ -1890,7 +1890,18 @@ PathStPtr GetSoldierMercPathPtr( SOLDIERTYPE *pSoldier ) // IS a vehicle? else if( pSoldier->uiStatusFlags & SOLDIER_VEHICLE ) { - pMercPath = pVehicleList[ pSoldier->bVehicleID ].pMercPath; + /* Sergeant_Kolja, 2007-02-20: got an pVehicleList==NULL Exception on loading an older save here... not REALY fixed! */ + if( !pVehicleList ) /*bcause we have no vehicle list at all, we act as we are a person*/ + { + pSoldier->uiStatusFlags &= ~SOLDIER_VEHICLE; + pMercPath = pSoldier->pMercPath; + /* after all, create an empty Vehicle list */ + pVehicleList = (VEHICLETYPE *) MemAlloc( sizeof( VEHICLETYPE ) ); + memset( pVehicleList, 0, sizeof( VEHICLETYPE ) ); + pVehicleList->fValid = 0; + } + else + pMercPath = pVehicleList[ pSoldier->bVehicleID ].pMercPath; } else // a person {