From 2bf92c7301ba62d7e5e48330ece1c13e3c405123 Mon Sep 17 00:00:00 2001 From: Flugente Date: Fri, 24 May 2013 14:25:47 +0000 Subject: [PATCH] Vehicle data is no longer saved and loaded into savegames, as it was externalised to xml a long time ago git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6093 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameVersion.h | 3 ++- SaveLoadGame.cpp | 19 ++----------------- Tactical/Vehicles.cpp | 24 +++++++----------------- Tactical/Vehicles.h | 1 - 4 files changed, 11 insertions(+), 36 deletions(-) diff --git a/GameVersion.h b/GameVersion.h index 356eb1f5..ed1213d8 100644 --- a/GameVersion.h +++ b/GameVersion.h @@ -21,6 +21,7 @@ extern CHAR16 zTrackingNumber[16]; // Keeps track of the saved game version. Increment the saved game version whenever // you will invalidate the saved game file +#define NO_VEHICLE_SAVE 144 // Flugente: vehicle data isn't saved anymore, as it has long been externalised #define SOLDIER_PROFILES 143 // Flugente: profiles for enemy and militia (possibly any non-NPC/RPC character) #define DYNAMIC_FLASHLIGHTS 142 // Flugente: had to add variables to LIGHTEFFECT-struct #define ENLARGED_OPINIONS 141 // Flugente: increased numberof merc opinions to 255, thus need to change savegame reading @@ -62,7 +63,7 @@ extern CHAR16 zTrackingNumber[16]; #define AP100_SAVEGAME_DATATYPE_CHANGE 105 // Before this, we didn't have the 100AP structure changes #define NIV_SAVEGAME_DATATYPE_CHANGE 102 // Before this, we used the old structure system -#define SAVE_GAME_VERSION SOLDIER_PROFILES +#define SAVE_GAME_VERSION NO_VEHICLE_SAVE //#define RUSSIANGOLD #ifdef __cplusplus diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index f8f120a3..487f66c8 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -3886,22 +3886,7 @@ BOOLEAN SaveGame( int ubSaveGameID, STR16 pGameDesc ) #ifdef JA2BETAVERSION SaveGameFilePosition( FileGetPos( hFile ), "Lua global" ); #endif - - //New vehicles by Jazz - if( !SaveNewVehiclesToSaveGameFile( hFile ) ) - { - ScreenMsg( FONT_MCOLOR_WHITE, MSG_ERROR, L"ERROR writing new vehicles"); - goto FAILED_TO_SAVE; - - #ifdef JA2BETAVERSION - SaveGameFilePosition( FileGetPos( hFile ), "New Vehicles" ); - #endif - - } - - - - + if( !SaveDataSaveToSaveGameFile( hFile ) ) { ScreenMsg( FONT_MCOLOR_WHITE, MSG_ERROR, L"ERROR writing save data"); @@ -5444,7 +5429,7 @@ BOOLEAN LoadSavedGame( int ubSavedGameID ) LoadGameFilePosition( FileGetPos( hFile ), "Lua Global System" ); #endif - if( guiCurrentSaveGameVersion >= VEHICLES_DATATYPE_CHANGE) + if( guiCurrentSaveGameVersion >= VEHICLES_DATATYPE_CHANGE && guiCurrentSaveGameVersion < NO_VEHICLE_SAVE) { uiRelEndPerc += 1; SetRelativeStartAndEndPercentage( 0, uiRelStartPerc, uiRelEndPerc, L"Load New Vehicles..." ); diff --git a/Tactical/Vehicles.cpp b/Tactical/Vehicles.cpp index bad42bb6..b30e8729 100644 --- a/Tactical/Vehicles.cpp +++ b/Tactical/Vehicles.cpp @@ -55,7 +55,8 @@ extern INT8 SquadMovementGroups[ ]; NEW_CAR gNewVehicle[NUM_PROFILES]; -BOOLEAN SaveNewVehiclesToSaveGameFile( HWFILE hFile ); + +// Flugente 2013-05-12: saving and loading an array that is read from xml is utterly pointless. The loading function has to remain for compatibility reasons - please remove the next time savegame compatibility is broken BOOLEAN LoadNewVehiclesToSaveGameFile( HWFILE hFile ); //ATE: These arrays below should all be in a large LUT which contains @@ -182,26 +183,15 @@ void SetDriver( INT32 iID, UINT8 ubID ); void TeleportVehicleToItsClosestSector( INT32 iVehicleId, UINT8 ubGroupID ); - -BOOLEAN SaveNewVehiclesToSaveGameFile( HWFILE hFile ) -{ - UINT32 uiNumBytesWritten; - - FileWrite( hFile, &gNewVehicle, sizeof( gNewVehicle), &uiNumBytesWritten ); - if( uiNumBytesWritten != sizeof( gNewVehicle ) ) - { - return( FALSE ); - } - - return( TRUE ); -} - +// Flugente 2013-05-12: saving and loading an array that is read from xml is utterly pointless. The loading function has to remain for compatibility reasons - please remove the next time savegame compatibility is broken BOOLEAN LoadNewVehiclesToSaveGameFile( HWFILE hFile ) { UINT32 uiNumBytesRead; - FileRead( hFile, &gNewVehicle, sizeof( gNewVehicle), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( gNewVehicle ) ) + NEW_CAR tmp[NUM_PROFILES]; + + FileRead( hFile, &tmp, sizeof( tmp), &uiNumBytesRead ); + if( uiNumBytesRead != sizeof( tmp ) ) { return( FALSE ); } diff --git a/Tactical/Vehicles.h b/Tactical/Vehicles.h index 7d63939d..c9d63fc5 100644 --- a/Tactical/Vehicles.h +++ b/Tactical/Vehicles.h @@ -35,7 +35,6 @@ typedef struct extern NEW_CAR gNewVehicle[NUM_PROFILES]; -extern BOOLEAN SaveNewVehiclesToSaveGameFile( HWFILE hFile ); extern BOOLEAN LoadNewVehiclesToSaveGameFile( HWFILE hFile ); // type of vehicles