From 341715fdc72a5bb0e1f773a7bb571c6ae23f7815 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 27 Feb 2004 01:54:55 +0000 Subject: [PATCH] fix 5th scoring eval crash cleanup --- stepmania/src/ScreenEvaluation.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index d04fc7c83d..ebfe709406 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -210,11 +210,14 @@ void ScreenEvaluation::Init() else grade[p] = GRADE_FAILED; - if (PREFSMAN->m_iScoringType == PrefsManager::SCORING_5TH) + if( PREFSMAN->m_iScoringType == PrefsManager::SCORING_5TH ) { - int ScoreBonuses[9] = {0, 0, 100, 1000, 10000, 100000, 1000000, 10000000, 10000000}; - g_CurStageStats.iBonus[p] += ScoreBonuses[(int)grade[p] ]; - stageStats.iBonus[p] += ScoreBonuses[(int)grade[p] ]; + const int ScoreBonuses[] = { 10000000, 10000000, 1000000, 100000, 10000, 1000, 100 }; + if( grade[p] < ARRAYSIZE(ScoreBonuses) ) + { + g_CurStageStats.iBonus[p] += ScoreBonuses[(int)grade[p] ]; + stageStats.iBonus[p] += ScoreBonuses[(int)grade[p] ]; + } } } @@ -1230,19 +1233,23 @@ void ScreenEvaluation::Update( float fDeltaTime ) for( int p=0; pIsPlayerEnabled(p) ) continue; - if (GAMESTATE->IsCourseMode()) + if( g_CurStageStats.iBonus[p] == 0 ) + continue; + + if( GAMESTATE->IsCourseMode() ) continue; // wait a few seconds before adding bonus - if ( RageTimer::GetTimeSinceStart() - m_fScreenCreateTime < 1.5f) + if( RageTimer::GetTimeSinceStart() - m_fScreenCreateTime < 1.5f ) continue; int increment = g_CurStageStats.iBonus[p]/10; - if (increment < 1) - increment = min(1024, g_CurStageStats.iBonus[p]); + /* XXX: What's this supposed to do? If i < 1, then min(i, 1024) is i ... */ + if( increment < 1 ) + increment = min( 1024, g_CurStageStats.iBonus[p] ); g_CurStageStats.iBonus[p] -= increment; g_CurStageStats.iScore[p] += increment;