persist PreferredDifficulty in Profile

This commit is contained in:
Chris Danford
2004-03-13 19:20:24 +00:00
parent 8f10f429ea
commit e4855e627f
3 changed files with 35 additions and 18 deletions
+26 -14
View File
@@ -198,15 +198,18 @@ void GameState::PlayersFinalized()
// apply saved default modifiers if any // apply saved default modifiers if any
FOREACH_HumanPlayer( pn ) FOREACH_HumanPlayer( pn )
{ {
if( PROFILEMAN->IsUsingProfile(pn) ) if( !PROFILEMAN->IsUsingProfile(pn) )
continue; // skip
Profile* pProfile = PROFILEMAN->GetProfile(pn);
if( pProfile->m_bUsingProfileDefaultModifiers )
{ {
Profile* pProfile = PROFILEMAN->GetProfile(pn); GAMESTATE->m_PlayerOptions[pn].Init();
if( pProfile->m_bUsingProfileDefaultModifiers ) GAMESTATE->ApplyModifiers( pn, pProfile->m_sDefaultModifiers );
{
GAMESTATE->m_PlayerOptions[pn].Init();
GAMESTATE->ApplyModifiers( pn, pProfile->m_sDefaultModifiers );
}
} }
if( pProfile->m_PreferredDifficulty != DIFFICULTY_INVALID )
GAMESTATE->m_PreferredDifficulty[pn] = pProfile->m_PreferredDifficulty;
} }
@@ -288,19 +291,28 @@ void GameState::EndGame()
CHECKPOINT; CHECKPOINT;
} }
CHECKPOINT;
MEMCARDMAN->FlushAllDisks();
CHECKPOINT;
BOOKKEEPER->WriteToDisk(); BOOKKEEPER->WriteToDisk();
PROFILEMAN->SaveMachineProfile(); PROFILEMAN->SaveMachineProfile();
for( p=0; p<NUM_PLAYERS; p++ ) FOREACH_HumanPlayer( pn )
{ {
PROFILEMAN->SaveProfile( (PlayerNumber)p ); if( !PROFILEMAN->IsUsingProfile(pn) )
PROFILEMAN->UnloadProfile( (PlayerNumber)p ); continue;
Profile* pProfile = PROFILEMAN->GetProfile(pn);
// persist current settings
pProfile->m_PreferredDifficulty = m_PreferredDifficulty[pn];
PROFILEMAN->SaveProfile( pn );
PROFILEMAN->UnloadProfile( pn );
} }
// Reset the USB storage device numbers -after- saving
CHECKPOINT;
MEMCARDMAN->FlushAllDisks();
CHECKPOINT;
SONGMAN->FreeAllLoadedFromProfiles(); SONGMAN->FreeAllLoadedFromProfiles();
} }
+8 -4
View File
@@ -69,6 +69,7 @@ void Profile::InitGeneralData()
m_bUsingProfileDefaultModifiers = false; m_bUsingProfileDefaultModifiers = false;
m_sDefaultModifiers = ""; m_sDefaultModifiers = "";
m_SortOrder = SORT_INVALID; m_SortOrder = SORT_INVALID;
m_PreferredDifficulty = DIFFICULTY_INVALID;
m_iTotalPlays = 0; m_iTotalPlays = 0;
m_iTotalPlaySeconds = 0; m_iTotalPlaySeconds = 0;
m_iTotalGameplaySeconds = 0; m_iTotalGameplaySeconds = 0;
@@ -567,7 +568,8 @@ XNode* Profile::SaveGeneralDataCreateNode() const
pGeneralDataNode->AppendChild( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pGeneralDataNode->AppendChild( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers ); pGeneralDataNode->AppendChild( "DefaultModifiers", m_sDefaultModifiers );
pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) ); pGeneralDataNode->AppendChild( "SortOrder", SortOrderToString(m_SortOrder) );
pGeneralDataNode->AppendChild( "PreferredDifficulty", DifficultyToString(m_PreferredDifficulty) );
pGeneralDataNode->AppendChild( "TotalPlays", m_iTotalPlays ); pGeneralDataNode->AppendChild( "TotalPlays", m_iTotalPlays );
pGeneralDataNode->AppendChild( "TotalPlaySeconds", m_iTotalPlaySeconds ); pGeneralDataNode->AppendChild( "TotalPlaySeconds", m_iTotalPlaySeconds );
pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pGeneralDataNode->AppendChild( "TotalGameplaySeconds", m_iTotalGameplaySeconds );
@@ -702,9 +704,11 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers ); pNode->GetChildValue( "UsingProfileDefaultModifiers", m_bUsingProfileDefaultModifiers );
pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers ); pNode->GetChildValue( "DefaultModifiers", m_sDefaultModifiers );
CString sSortOrder; CString s;
pNode->GetChildValue( "SortOrder", sSortOrder ); pNode->GetChildValue( "SortOrder", s );
m_SortOrder = StringToSortOrder( sSortOrder ); m_SortOrder = StringToSortOrder( s );
pNode->GetChildValue( "PreferredDifficulty", s );
m_PreferredDifficulty = StringToDifficulty( s );
pNode->GetChildValue( "TotalPlays", m_iTotalPlays ); pNode->GetChildValue( "TotalPlays", m_iTotalPlays );
pNode->GetChildValue( "TotalPlaySeconds", m_iTotalPlaySeconds ); pNode->GetChildValue( "TotalPlaySeconds", m_iTotalPlaySeconds );
pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds ); pNode->GetChildValue( "TotalGameplaySeconds", m_iTotalGameplaySeconds );
+1
View File
@@ -89,6 +89,7 @@ public:
bool m_bUsingProfileDefaultModifiers; bool m_bUsingProfileDefaultModifiers;
CString m_sDefaultModifiers; CString m_sDefaultModifiers;
SortOrder m_SortOrder; SortOrder m_SortOrder;
Difficulty m_PreferredDifficulty;
int m_iTotalPlays; int m_iTotalPlays;
int m_iTotalPlaySeconds; int m_iTotalPlaySeconds;
int m_iTotalGameplaySeconds; int m_iTotalGameplaySeconds;