diff --git a/stepmania/src/Grade.cpp b/stepmania/src/Grade.cpp index 43d02633ba..319061465f 100644 --- a/stepmania/src/Grade.cpp +++ b/stepmania/src/Grade.cpp @@ -14,6 +14,18 @@ #include "RageUtil.h" #include "ThemeManager.h" +CString GradeToString( Grade g ) +{ + // string is meant to be human readable + switch( g ) + { + case GRADE_NO_DATA: return "NoData"; + case GRADE_FAILED: return "Failed"; + default: + return ssprintf("Tier%02d",g+1); + } +} + CString GradeToThemedString( Grade g ) { CString s = GradeToString(g); @@ -61,10 +73,9 @@ Grade StringToGrade( const CString &sGrade ) if ( s == "FAILED" ) return GRADE_FAILED; else if( s == "NODATA" ) return GRADE_NO_DATA; -#define MY_IS_DIGIT( c ) (c>='0'&&c<='9') - - if( s.length()==2 && MY_IS_DIGIT(s[0]) && MY_IS_DIGIT(s[1]) ) // if it's a two digit number... - return (Grade)(atoi(s)-1); + int iTier; + if( sscanf(sGrade.c_str(),"TIER%02d",&iTier) == 1 ) // if it's a two digit number... + return (Grade)(iTier-1); ASSERT(0); return GRADE_NO_DATA; diff --git a/stepmania/src/Grade.h b/stepmania/src/Grade.h index 52bb89200b..36f2fcfa66 100644 --- a/stepmania/src/Grade.h +++ b/stepmania/src/Grade.h @@ -43,18 +43,7 @@ enum Grade GRADE_NO_DATA, // ~GRADE_INVALID }; -inline CString GradeToString( Grade g ) -{ - // string is meant to be human readable - switch( g ) - { - case GRADE_NO_DATA: return "NoData"; - case GRADE_FAILED: return "Failed"; - default: - return ssprintf("%02d",g+1); - } -} - +CString GradeToString( Grade g ); CString GradeToOldString( Grade g ); // "AAA", "B", etc for backward compatibility CString GradeToThemedString( Grade g ); Grade StringToGrade( const CString &s ); diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index d7b50c4747..81a8deafd9 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -587,7 +587,7 @@ XNode* Profile::SaveGeneralDataCreateNode() const { XNode* pUnlockedSongs = pGeneralDataNode->AppendChild("UnlockedSongs"); for( set::const_iterator it = m_UnlockedSongs.begin(); it != m_UnlockedSongs.end(); ++it ) - pUnlockedSongs->AppendChild( ssprintf("%i", *it) ); + pUnlockedSongs->AppendChild( ssprintf("Unlock%i", *it) ); } { @@ -726,7 +726,11 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode ) if( pUnlockedSongs ) { FOREACH_Node( pUnlockedSongs, song ) - m_UnlockedSongs.insert( atoi(song->name) ); + { + int iUnlock; + if( sscanf(song->name.c_str(),"Unlock%d",&iUnlock) == 1 ) + m_UnlockedSongs.insert( iUnlock ); + } } } diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 335e87c73e..8b8c5c8ecd 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -409,7 +409,7 @@ void ScreenEvaluation::Init() // if( SHOW_GRADE_AREA ) { - // ugly: Touch all possible grade files to make sure they're all present + // Touch all possible grade files to make sure they're all present for( int g=GRADE_TIER_1; gGetPathToG( "ScreenEvaluation grade "+ GradeToString((Grade)g) );