fix "invalid Difficulty value causes garbage calculation"

This commit is contained in:
Chris Danford
2004-08-09 05:00:20 +00:00
parent 1d376f5795
commit 404ed69faf
2 changed files with 11 additions and 6 deletions
+1
View File
@@ -24,6 +24,7 @@ Difficulty StringToDifficulty( const CString& sDC );
typedef Difficulty CourseDifficulty; typedef Difficulty CourseDifficulty;
#define NUM_COURSE_DIFFICULTIES NUM_DIFFICULTIES
#define FOREACH_CourseDifficulty FOREACH_Difficulty #define FOREACH_CourseDifficulty FOREACH_Difficulty
#define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=DIFFICULTY_INVALID; cd=GetNextShownCourseDifficulty(cd) ) #define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=DIFFICULTY_INVALID; cd=GetNextShownCourseDifficulty(cd) )
+10 -6
View File
@@ -40,7 +40,8 @@ CString GetStatsLineTitle( PlayerNumber pn, EndingStatsLine line )
CString sStepsType = GAMEMAN->StepsTypeToThemedString(st); CString sStepsType = GAMEMAN->StepsTypeToThemedString(st);
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
{ {
CourseDifficulty cd = (CourseDifficulty)line; CourseDifficulty cd = (CourseDifficulty)(DIFFICULTY_EASY+line-PERCENT_COMPLETE_EASY);
ASSERT( cd >= 0 && cd < NUM_COURSE_DIFFICULTIES );
if( !GAMESTATE->IsCourseDifficultyShown(cd) ) if( !GAMESTATE->IsCourseDifficultyShown(cd) )
return ""; return "";
CString sDifficulty = CourseDifficultyToThemedString(cd); CString sDifficulty = CourseDifficultyToThemedString(cd);
@@ -48,7 +49,8 @@ CString GetStatsLineTitle( PlayerNumber pn, EndingStatsLine line )
} }
else else
{ {
Difficulty dc = (Difficulty)line; Difficulty dc = (Difficulty)(DIFFICULTY_EASY+line-PERCENT_COMPLETE_EASY);
ASSERT( dc >= 0 && dc < NUM_DIFFICULTIES );
CString sDifficulty = DifficultyToThemedString(dc); CString sDifficulty = DifficultyToThemedString(dc);
return ssprintf( "%s %% Complete", sStepsType.c_str() ); return ssprintf( "%s %% Complete", sStepsType.c_str() );
} }
@@ -76,7 +78,8 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
CString sStepsType = GAMEMAN->StepsTypeToThemedString(st); CString sStepsType = GAMEMAN->StepsTypeToThemedString(st);
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
{ {
CourseDifficulty cd = (CourseDifficulty)line; CourseDifficulty cd = (CourseDifficulty)(DIFFICULTY_EASY+line-PERCENT_COMPLETE_EASY);
ASSERT( cd >= 0 && cd < NUM_COURSE_DIFFICULTIES );
if( !GAMESTATE->IsCourseDifficultyShown(cd) ) if( !GAMESTATE->IsCourseDifficultyShown(cd) )
return ""; return "";
CString sDifficulty = CourseDifficultyToThemedString(cd); CString sDifficulty = CourseDifficultyToThemedString(cd);
@@ -84,7 +87,8 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
} }
else else
{ {
Difficulty dc = (Difficulty)line; Difficulty dc = (Difficulty)(DIFFICULTY_EASY+line-PERCENT_COMPLETE_EASY);
ASSERT( dc >= 0 && dc < NUM_DIFFICULTIES );
CString sDifficulty = DifficultyToThemedString(dc); CString sDifficulty = DifficultyToThemedString(dc);
return ssprintf( "%06.3f%%", pProfile->GetSongsPercentComplete(st,dc)*100 ); return ssprintf( "%06.3f%%", pProfile->GetSongsPercentComplete(st,dc)*100 );
} }
@@ -98,8 +102,8 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa
{ {
if( PREFSMAN->m_bScreenTestMode ) if( PREFSMAN->m_bScreenTestMode )
{ {
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1, false); PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1);
PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2, false); PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2);
GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR;
GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAMEMAN->GetDefaultGame(), "versus" ); GAMESTATE->m_pCurStyle = GAMEMAN->GameAndStringToStyle( GAMEMAN->GetDefaultGame(), "versus" );