From a08175906de17ec68e1529b3117876827d63fcd1 Mon Sep 17 00:00:00 2001 From: Wanne Date: Thu, 15 Aug 2013 20:20:06 +0000 Subject: [PATCH] - Improvement of M.E.R.C availability (by silversurfer) o Now you can change the MercAvailability.xml file during a game git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6286 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/mercs.cpp | 34 ++++++++++++++++++++++++++++------ Laptop/mercs.h | 1 - 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Laptop/mercs.cpp b/Laptop/mercs.cpp index 443db7f7..85272388 100644 --- a/Laptop/mercs.cpp +++ b/Laptop/mercs.cpp @@ -333,6 +333,7 @@ BOOLEAN AreAnyOfTheNewMercsAvailable(); void ShouldAnyNewMercMercBecomeAvailable(); BOOLEAN CanMercBeAvailableYet( UINT8 ubMercToCheck ); UINT32 CalcMercDaysServed(); +void RevaluateMercArray(); // silversurfer: for better savegame compatibility #ifdef JA2UB void MarkSpeckImportantQuoteUsed( UINT32 uiQuoteNum ); BOOLEAN HasImportantSpeckQuoteBeingSaid( UINT32 uiQuoteNum ); @@ -356,22 +357,43 @@ BOOLEAN SaveNewMercsToSaveGameFile( HWFILE hFile ) BOOLEAN LoadNewMercsFromLoadGameFile( HWFILE hFile ) { UINT32 uiNumBytesRead; + CONTITION_FOR_MERC_AVAILABLE ConditionsForMercAvailabilityLoad[ NUM_PROFILES ]; - FileRead( hFile, &gConditionsForMercAvailability, sizeof( gConditionsForMercAvailability ), &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( gConditionsForMercAvailability ) ) + FileRead( hFile, &ConditionsForMercAvailabilityLoad, sizeof( ConditionsForMercAvailabilityLoad ), &uiNumBytesRead ); + if( uiNumBytesRead != sizeof( ConditionsForMercAvailabilityLoad ) ) { return( FALSE ); } - // make sure that gubMercArray (the list of mercs for M.E.R.C website) is populated with - // the same mercs as gConditionsForMercAvailability that we just read from the savegame + // silversurfer: Now update the true gConditionsForMercAvailability array with the data from the savegame. + // Take every index of gConditionsForMercAvailability array that we initialized in GameInitMercs() and see + // if we can find a matching profile ID in ConditionsForMercAvailabilityLoad array that we loaded from the savegame. + // This prevents some issues when old savegames are loaded with updated MercAvailability.xml. + for ( UINT8 i=0; i