From 3cb06243426d742ff23354b8fe5cc087d70a2cc0 Mon Sep 17 00:00:00 2001 From: SpaceViking Date: Sat, 2 May 2009 05:44:25 +0000 Subject: [PATCH] Change to use vector for pre-RNG array git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2792 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- SaveLoadGame.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/SaveLoadGame.cpp b/SaveLoadGame.cpp index 34b4ddcd..2074c987 100644 --- a/SaveLoadGame.cpp +++ b/SaveLoadGame.cpp @@ -6409,11 +6409,19 @@ BOOLEAN SavePreRandomNumbersToSaveGameFile( HWFILE hFile ) } //Save the Prerandom number index - FileWrite( hFile, guiPreRandomNums, sizeof( UINT32 ) * MAX_PREGENERATED_NUMS, &uiNumBytesWritten ); - if( uiNumBytesWritten != sizeof( UINT32 ) * MAX_PREGENERATED_NUMS ) + for (std::vector::iterator iter = guiPreRandomNums.begin(); + iter != guiPreRandomNums.end(); ++iter) { + FileWrite( hFile, &*iter, sizeof( UINT32 ), &uiNumBytesWritten ); + if( uiNumBytesWritten != sizeof( UINT32 ) ) { return( FALSE ); } + } + //FileWrite( hFile, guiPreRandomNums, sizeof( UINT32 ) * MAX_PREGENERATED_NUMS, &uiNumBytesWritten ); + //if( uiNumBytesWritten != sizeof( UINT32 ) * MAX_PREGENERATED_NUMS ) + //{ + // return( FALSE ); + //} return( TRUE ); } @@ -6430,11 +6438,19 @@ BOOLEAN LoadPreRandomNumbersFromSaveGameFile( HWFILE hFile ) } //Load the Prerandom number index - FileRead( hFile, guiPreRandomNums, sizeof( UINT32 ) * MAX_PREGENERATED_NUMS, &uiNumBytesRead ); - if( uiNumBytesRead != sizeof( UINT32 ) * MAX_PREGENERATED_NUMS ) + for (std::vector::iterator iter = guiPreRandomNums.begin(); + iter != guiPreRandomNums.end(); ++iter) { + FileRead( hFile, &*iter, sizeof( UINT32 ), &uiNumBytesRead ); + if( uiNumBytesRead != sizeof( UINT32 ) ) { return( FALSE ); } + } +// FileRead( hFile, guiPreRandomNums, sizeof( UINT32 ) * MAX_PREGENERATED_NUMS, &uiNumBytesRead ); +// if( uiNumBytesRead != sizeof( UINT32 ) * MAX_PREGENERATED_NUMS ) +// { +// return( FALSE ); +// } return( TRUE ); }