From 6f75a3d920a3861bf394e265282904d3c5240338 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 24 May 2004 06:07:59 +0000 Subject: [PATCH] review uses of GetTrail --- stepmania/src/BPMDisplay.cpp | 3 ++- stepmania/src/PaneDisplay.cpp | 21 ++++++++++----------- stepmania/src/PlayerOptions.cpp | 1 + stepmania/src/Profile.cpp | 3 ++- stepmania/src/ProfileHtml.cpp | 2 +- stepmania/src/ScreenEvaluation.cpp | 2 +- stepmania/src/ScreenGameplay.cpp | 1 + stepmania/src/TrailUtil.cpp | 2 ++ 8 files changed, 20 insertions(+), 15 deletions(-) diff --git a/stepmania/src/BPMDisplay.cpp b/stepmania/src/BPMDisplay.cpp index e09625423b..c5e4386f01 100644 --- a/stepmania/src/BPMDisplay.cpp +++ b/stepmania/src/BPMDisplay.cpp @@ -203,7 +203,8 @@ void BPMDisplay::SetBPM( const Course* pCourse ) { ASSERT( pCourse ); - Trail *pTrail = pCourse->GetTrail( GAMESTATE->GetCurrentStyleDef()->m_StepsType, COURSE_DIFFICULTY_REGULAR ); + StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; + Trail *pTrail = pCourse->GetTrail( st, COURSE_DIFFICULTY_REGULAR ); ASSERT( pTrail->m_vEntries.size() ); diff --git a/stepmania/src/PaneDisplay.cpp b/stepmania/src/PaneDisplay.cpp index 43ed666237..880dbcd954 100644 --- a/stepmania/src/PaneDisplay.cpp +++ b/stepmania/src/PaneDisplay.cpp @@ -151,17 +151,6 @@ void PaneDisplay::SetContent( PaneContents c ) if( (g_Contents[c].req&NEED_PROFILE) && !PROFILEMAN->IsUsingProfile( m_PlayerNumber ) ) return; - RadarValues rv; - - if( g_Contents[c].req&NEED_NOTES ) - rv = GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetRadarValues(); - else if( g_Contents[c].req&NEED_COURSE ) - { - CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber]; - StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; - rv = GAMESTATE->m_pCurCourse->GetTrail(st,cd)->GetRadarValues(); - } - const Song *pSong = GAMESTATE->m_pCurSong; const Steps *pSteps = GAMESTATE->m_pCurNotes[m_PlayerNumber]; StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; @@ -169,6 +158,16 @@ void PaneDisplay::SetContent( PaneContents c ) const CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[m_PlayerNumber]; const Trail *pTrail = pCourse ? pCourse->GetTrail(st,cd) : NULL; + RadarValues rv; + + if( g_Contents[c].req&NEED_NOTES ) + rv = GAMESTATE->m_pCurNotes[m_PlayerNumber]->GetRadarValues(); + else if( g_Contents[c].req&NEED_COURSE ) + { + ASSERT( pCourse ); + rv = pTrail->GetRadarValues(); + } + float val = 0; CString str; switch( c ) diff --git a/stepmania/src/PlayerOptions.cpp b/stepmania/src/PlayerOptions.cpp index 5691ce78e4..3ec6adba26 100644 --- a/stepmania/src/PlayerOptions.cpp +++ b/stepmania/src/PlayerOptions.cpp @@ -574,6 +574,7 @@ bool PlayerOptions::IsEasierForSongAndSteps( Song* pSong, Steps* pSteps ) bool PlayerOptions::IsEasierForCourse( Course* pCourse, StepsType st, CourseDifficulty cd ) { + ASSERT( pCourse ); Trail *pTrail = pCourse->GetTrail( st, cd ); FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 61b2b5727e..9181aa231d 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -308,7 +308,8 @@ int Profile::GetPossibleCourseDancePointsForStepsType( StepsType st ) const if( !pCourse->HasCourseDifficulty(st,cd) ) continue; - const RadarValues& fRadars = pCourse->GetTrail(st,cd)->GetRadarValues(); + Trail* pTrail = pCourse->GetTrail(st,cd); + const RadarValues& fRadars = pTrail->GetRadarValues(); iTotal += ScoreKeeperMAX2::GetPossibleDancePoints( fRadars ); } } diff --git a/stepmania/src/ProfileHtml.cpp b/stepmania/src/ProfileHtml.cpp index ec37644a14..36b035028a 100644 --- a/stepmania/src/ProfileHtml.cpp +++ b/stepmania/src/ProfileHtml.cpp @@ -733,7 +733,7 @@ bool PrintHighScoresForCourse( RageFile &f, const Profile *pProfile, Course* pCo { bool bPrintedAny = false; - for( StepsType st=(StepsType)0; stm_pCurCourse; + ASSERT( pCourse ); CourseDifficulty cd = GAMESTATE->m_PreferredCourseDifficulty[p]; Trail *pTrail = pCourse->GetTrail( st, cd ); - ASSERT( pCourse ); ASSERT( pTrail ); pHSL = &pProfile->GetCourseHighScoreList( pCourse, pTrail ); } diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 9519963972..38826aeea7 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -184,6 +184,7 @@ void ScreenGameplay::Init() if( GAMESTATE->IsCourseMode() ) { Course* pCourse = GAMESTATE->m_pCurCourse; + ASSERT( pCourse ); const StepsType st = GAMESTATE->GetCurrentStyleDef()->m_StepsType; /* Increment the play count. */ diff --git a/stepmania/src/TrailUtil.cpp b/stepmania/src/TrailUtil.cpp index e1cbfe3bfe..99d49b3f4c 100644 --- a/stepmania/src/TrailUtil.cpp +++ b/stepmania/src/TrailUtil.cpp @@ -33,6 +33,8 @@ void TrailID::FromTrail( const Trail *p ) Trail *TrailID::ToTrail( const Course *p, bool bAllowNull ) const { + ASSERT( p ); + if( st == STEPS_TYPE_INVALID || cd == COURSE_DIFFICULTY_INVALID ) return NULL;