From 376ca1502902546f07b7a05337ce079737f7a4df Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 22 Feb 2004 07:07:03 +0000 Subject: [PATCH] simplify --- stepmania/src/Profile.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 643eedb64e..ba62e9e6de 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -44,6 +44,17 @@ const int SM_390A12_SONG_SCORES_VERSION = 9; const int SM_390A12_COURSE_SCORES_VERSION = 8; +#if defined(WIN32) +#pragma warning (disable : 4706) // assignment within conditional expression +#endif + +#define FOREACH_Node( Node, Var ) \ + XNodes::const_iterator Var##Iter; \ + const XNode *Var = NULL; \ + for( Var##Iter = Node->childs.begin(); \ + (Var##Iter != Node->childs.end() && (Var = *Var##Iter) ), Var##Iter != Node->childs.end(); \ + ++Var##Iter ) + void Profile::InitEditableData() { @@ -575,28 +586,28 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) { XNode* pNumSongsPlayedByStyle = pNode->GetChild("NumSongsPlayedByStyle"); if( pNumSongsPlayedByStyle ) - for( XNodes::const_iterator style = pNumSongsPlayedByStyle->childs.begin(); - style != pNumSongsPlayedByStyle->childs.end(); - style++ ) + { + FOREACH_Node( pNumSongsPlayedByStyle, style ) { - if( (*style)->name != "Style" ) + if( style->name != "Style" ) continue; CString sGame; - if( !(*style)->GetAttrValue( "Game", sGame ) ) + if( !style->GetAttrValue( "Game", sGame ) ) WARN_AND_CONTINUE; Game g = GAMEMAN->StringToGameType( sGame ); if( g == GAME_INVALID ) WARN_AND_CONTINUE; CString sStyle; - if( !(*style)->GetAttrValue( "Style", sStyle ) ) + if( !style->GetAttrValue( "Style", sStyle ) ) WARN_AND_CONTINUE; Style s = GAMEMAN->GameAndStringToStyle( g, sStyle ); - (*style)->GetValue( m_iNumSongsPlayedByStyle[s] ); + style->GetValue( m_iNumSongsPlayedByStyle[s] ); } + } } {