From f32fdae32600dad1176c43c0ae5c6382937484d9 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 7 Jul 2003 10:51:58 +0000 Subject: [PATCH] simplify Quick 6am (zzzz) tips: If a block is more than a few lines long, always bracket {} it, even if you don't have to. Large unbracketed expressions get hard to follow. Don't do this: while(stuff) { if(x) { do lots of stuff; } } Instead, do this: while(stuff) { if(!x) continue; do lots of stuff; } This simplifies program flow; the former makes me scroll down the page to see if there's anything after the "if" before it comes around the loop again. It also reduces indentation. XXX's are things that I'm not going to try to do at 6am ... --- stepmania/src/ScreenEvaluation.cpp | 52 ++++++++++-------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 962409526e..779a0d7fb2 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -640,42 +640,24 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName, Type type ) : Screen(sCl // If unlocking is enabled, save the dance points for( p=0; pm_bUseUnlockSystem ) - { - switch (m_Grades[p].GetGrade()) - { - case GRADE_AAAA: - PREFSMAN->m_fArcadePointsAccumulated += 10; - PREFSMAN->m_fSongPointsAccumulated += 20; - break; - case GRADE_AAA: - PREFSMAN->m_fArcadePointsAccumulated += 10; - PREFSMAN->m_fSongPointsAccumulated += 10; - break; - case GRADE_AA: - PREFSMAN->m_fArcadePointsAccumulated += 1; - PREFSMAN->m_fSongPointsAccumulated += 5; - break; - case GRADE_A: - PREFSMAN->m_fArcadePointsAccumulated += 1; - PREFSMAN->m_fSongPointsAccumulated += 4; - break; - case GRADE_B: - PREFSMAN->m_fArcadePointsAccumulated += 1; - PREFSMAN->m_fSongPointsAccumulated += 3; - break; - case GRADE_C: - PREFSMAN->m_fArcadePointsAccumulated += 1; - PREFSMAN->m_fSongPointsAccumulated += 2; - break; - case GRADE_D: - // no points PREFSMAN->m_fArcadePointsAccumulated += 0; - PREFSMAN->m_fSongPointsAccumulated += 1; - break; - } - PREFSMAN->SaveGlobalPrefsToDisk(); - } + { + /* XXX: This should be encapsulated in UnlockSystem, eg. + * UnlockSystem::AddStats(const StageStats &stats). */ + if( !PREFSMAN->m_bUseUnlockSystem ) + continue; + if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) + continue; // skip + const float ArcadePoints[NUM_GRADES] = { -1 /* unused */, 0, 0, 1, 1, 1, 1, 10, 10 }; + const float SongPoints[NUM_GRADES] = { -1, 0, 1, 2, 3, 4, 5, 10, 20 }; + /* XXX: This should use stageStats.GetGrade, not m_Grades. */ + const Grade g = m_Grades[p].GetGrade(); + + PREFSMAN->m_fArcadePointsAccumulated += ArcadePoints[g]; + PREFSMAN->m_fSongPointsAccumulated += SongPoints[g]; + + PREFSMAN->SaveGlobalPrefsToDisk(); + } bool bOneHasNewRecord = false; for( p=0; p