From 555cca6ec2268f5af5089e702ac4fc3e6863c279 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 22 Feb 2004 04:37:58 +0000 Subject: [PATCH] fix NumSongsPlayedByStyle data being written with short style names, eg "Single", which are not unique among games: need to write the game type, too --- stepmania/src/Profile.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index ccfa512e6f..71f8e7902f 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -485,8 +485,14 @@ XNode* Profile::SaveGeneralDataCreateNode() const /* Don't save unplayed styles. */ if( !m_iNumSongsPlayedByStyle[i] ) continue; - CString sStyle = GAMEMAN->GetStyleDefForStyle((Style)i)->m_szName; - pNumSongsPlayedByStyle->AppendChild( sStyle, m_iNumSongsPlayedByStyle[i] ); + + XNode *pStyleNode = pNumSongsPlayedByStyle->AppendChild( "Style", m_iNumSongsPlayedByStyle[i] ); + + const StyleDef *pStyle = GAMEMAN->GetStyleDefForStyle((Style)i); + const GameDef *g = GAMEMAN->GetGameDefForGame( pStyle->m_Game ); + ASSERT( g ); + pStyleNode->AppendAttr( "Game", g->m_szName ); + pStyleNode->AppendAttr( "Style", pStyle->m_szName ); } } @@ -568,10 +574,27 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) { XNode* pNumSongsPlayedByStyle = pNode->GetChild("NumSongsPlayedByStyle"); if( pNumSongsPlayedByStyle ) - for( int i=0; ichilds.begin(); + style != pNumSongsPlayedByStyle->childs.end(); + style++ ) { - CString sStyle = GAMEMAN->GetStyleDefForStyle((Style)i)->m_szName; - pNumSongsPlayedByStyle->GetChildValue( sStyle, m_iNumSongsPlayedByStyle[i] ); + if( (*style)->name != "Style" ) + continue; + + XAttr *TypeAttr = (*style)->GetAttr( "Game" ); + if( TypeAttr == NULL ) + WARN_AND_CONTINUE; + Game g = GAMEMAN->StringToGameType( TypeAttr->value ); + if( g == GAME_INVALID ) + WARN_AND_CONTINUE; + + TypeAttr = (*style)->GetAttr( "Style" ); + if( TypeAttr == NULL ) + WARN_AND_CONTINUE; + + Style s = GAMEMAN->GameAndStringToStyle( g, TypeAttr->value ); + + (*style)->GetValue( m_iNumSongsPlayedByStyle[s] ); } }