From d0ec837806dfb4202eb1f18755b8cf9a2c440315 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 5 Apr 2006 01:16:45 +0000 Subject: [PATCH] Prefer the current steps/trail, when possible. --- stepmania/src/ScreenSelectMusic.cpp | 32 ++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index e7c964d1f7..dc828225ac 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -1244,6 +1244,7 @@ void ScreenSelectMusic::AfterStepsChange( const vector &vpns ) Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]]; GAMESTATE->m_pCurSteps[pn].Set( pSteps ); + GAMESTATE->m_pCurTrail[pn].Set( NULL ); int iScore = 0; if( pSteps ) @@ -1288,6 +1289,7 @@ void ScreenSelectMusic::AfterTrailChange( const vector &vpns ) Course* pCourse = GAMESTATE->m_pCurCourse; Trail* pTrail = m_vpTrails.empty()? NULL: m_vpTrails[m_iSelection[pn]]; + GAMESTATE->m_pCurSteps[pn].Set( NULL ); GAMESTATE->m_pCurTrail[pn].Set( pTrail ); int iScore = 0; @@ -1337,18 +1339,26 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty() { /* Find the closest match to the user's preferred difficulty. */ int iCurDifference = -1; + int &iSelection = m_iSelection[pn]; for( unsigned i=0; im_pCurSteps[pn] == m_vpSteps[i] ) + { + iSelection = i; + break; + } + int iDiff = abs(m_vpSteps[i]->GetDifficulty() - GAMESTATE->m_PreferredDifficulty[pn]); if( iCurDifference == -1 || iDiff < iCurDifference ) { - m_iSelection[pn] = i; + iSelection = i; iCurDifference = iDiff; } } - CLAMP( m_iSelection[pn], 0, m_vpSteps.size()-1 ); + CLAMP( iSelection, 0, m_vpSteps.size()-1 ); } } else @@ -1357,18 +1367,26 @@ void ScreenSelectMusic::SwitchToPreferredDifficulty() { /* Find the closest match to the user's preferred difficulty. */ int iCurDifference = -1; + int &iSelection = m_iSelection[pn]; for( unsigned i=0; im_pCurTrail[pn] == m_vpTrails[i] ) + { + iSelection = i; + break; + } + int iDiff = abs(m_vpTrails[i]->m_CourseDifficulty - GAMESTATE->m_PreferredCourseDifficulty[pn]); if( iCurDifference == -1 || iDiff < iCurDifference ) { - m_iSelection[pn] = i; + iSelection = i; iCurDifference = iDiff; } } - CLAMP( m_iSelection[pn], 0, m_vpTrails.size()-1 ); + CLAMP( iSelection, 0, m_vpTrails.size()-1 ); } } } @@ -1422,12 +1440,6 @@ void ScreenSelectMusic::AfterMusicChange() if( pCourse ) GAMESTATE->m_pPreferredCourse = pCourse; - FOREACH_PlayerNumber( p ) - { - GAMESTATE->m_pCurSteps[p].Set( NULL ); - GAMESTATE->m_pCurTrail[p].Set( NULL ); - } - m_vpSteps.clear(); m_vpTrails.clear();