Store the profile type in the profile structure and remove superfluous code

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8620 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2018-09-24 19:36:28 +00:00
parent 8ae2eacfcd
commit 494dbc6e69
41 changed files with 385 additions and 942 deletions
+23 -12
View File
@@ -1638,6 +1638,15 @@ BOOLEAN MERCPROFILESTRUCT::Load(HWFILE hFile, bool forceLoadOldVersion, bool for
return(FALSE);
}
}
// Flugente: if this is a an case of older file, load from separate structure
if ( guiCurrentSaveGameVersion >= PROFILETYPE_STORED )
{
if ( !FileRead( hFile, &this->Type, sizeof( UINT32 ), &uiNumBytesRead ) )
{
return( FALSE );
}
}
}
if ( this->uiProfileChecksum != this->GetChecksum() )
@@ -1749,6 +1758,11 @@ BOOLEAN MERCPROFILESTRUCT::Save(HWFILE hFile)
{
return(FALSE);
}
if ( !FileWrite( hFile, &this->Type, sizeof( UINT32 ), &uiNumBytesWritten ) )
{
return( FALSE );
}
return TRUE;
}
@@ -4349,16 +4363,6 @@ BOOLEAN SaveGame( int ubSaveGameID, STR16 pGameDesc )
SaveGameFilePosition( FileGetPos( hFile ), "New Mercs Profiles" );
#endif
//New system profiles by Jazz
if( !SaveNewSystemMercsToSaveGameFile( hFile ) )
{
ScreenMsg( FONT_MCOLOR_WHITE, MSG_ERROR, L"ERROR writing new system mercs profiles");
goto FAILED_TO_SAVE;
}
#ifdef JA2BETAVERSION
SaveGameFilePosition( FileGetPos( hFile ), "New system Mercs Profiles" );
#endif
//save lua global
if( !SaveLuaGlobalToSaveGameFile( hFile ) )
{
@@ -5981,7 +5985,8 @@ BOOLEAN LoadSavedGame( int ubSavedGameID )
RenderProgressBar( 0, 100 );
uiRelStartPerc = uiRelEndPerc;
if( guiCurrentSaveGameVersion >= 113 )
// Flugente: we don't need this data anymore, but need to account for older save files
if ( guiCurrentSaveGameVersion >= 113 && guiCurrentSaveGameVersion < PROFILETYPE_STORED )
{
if( !LoadNewSystemMercsToSaveGameFile( hFile ) )
{
@@ -6714,11 +6719,17 @@ BOOLEAN LoadSavedMercProfiles( HWFILE hFile )
if ( gMercProfiles[cnt].bLifeMax <= 0 )
gMercProfiles[cnt] = tempMercProfile;
/// Flugente: until the introduction of a separate varriable for the voiceset, the voice was identical with the slot
// Flugente: until the introduction of a separate varriable for the voiceset, the voice was identical with the slot
if ( guiCurrentSaveGameVersion < SEPARATE_VOICESETS )
{
gMercProfiles[cnt].usVoiceIndex = cnt;
}
// Flugente: if this is an older savefile, load from separate structure
if ( guiCurrentSaveGameVersion < PROFILETYPE_STORED )
{
gMercProfiles[cnt].Type = gProfileType[cnt];
}
}
return( TRUE );