From 080d39351bdab3aade7c456ff1510f61081486b6 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 29 Apr 2007 04:22:04 +0000 Subject: [PATCH] unwrap to simplify fix assert when no players joined; pretend one player joined --- stepmania/src/GameState.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index cdd60dcfd7..3c9446b839 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -563,23 +563,27 @@ int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() int iNumStagesOfThisSong = 1; if( GAMESTATE->m_pCurSong ) { - const Steps *pSteps = GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber]; - StepsType st; - if( pSteps ) - { - st = pSteps->m_StepsType; - } - else - { - vector vpStyles; - GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), vpStyles ); - ASSERT( !vpStyles.empty() ); - const Style *pStyle = vpStyles[0]; - st = pStyle->m_StepsType; - } const Style *pStyle = GAMESTATE->m_pCurStyle; if( pStyle == NULL ) - pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), st ); + { + const Steps *pSteps = GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber]; + if( pSteps ) + { + /* If a style isn't set, use the style of the selected steps. */ + StepsType st = pSteps->m_StepsType; + pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), st ); + } + else + { + /* If steps aren't set either, pick any style for the number of + * joined players, or one player if no players are joined. */ + vector vpStyles; + int iJoined = max( GAMESTATE->GetNumSidesJoined(), 1 ); + GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, iJoined, vpStyles ); + ASSERT( !vpStyles.empty() ); + pStyle = vpStyles[0]; + } + } iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( GAMESTATE->m_pCurSong, pStyle->m_StyleType ); } else if( GAMESTATE->m_pCurCourse )