unwrap to simplify

fix assert when no players joined; pretend one player joined
This commit is contained in:
Glenn Maynard
2007-04-29 04:22:04 +00:00
parent 8197823fc1
commit 080d39351b
+12 -8
View File
@@ -562,24 +562,28 @@ int GameState::GetNumStagesForCurrentSongAndStepsOrCourse()
{ {
int iNumStagesOfThisSong = 1; int iNumStagesOfThisSong = 1;
if( GAMESTATE->m_pCurSong ) if( GAMESTATE->m_pCurSong )
{
const Style *pStyle = GAMESTATE->m_pCurStyle;
if( pStyle == NULL )
{ {
const Steps *pSteps = GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber]; const Steps *pSteps = GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber];
StepsType st;
if( pSteps ) if( pSteps )
{ {
st = pSteps->m_StepsType; /* 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 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<const Style*> vpStyles; vector<const Style*> vpStyles;
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), vpStyles ); int iJoined = max( GAMESTATE->GetNumSidesJoined(), 1 );
GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, iJoined, vpStyles );
ASSERT( !vpStyles.empty() ); ASSERT( !vpStyles.empty() );
const Style *pStyle = vpStyles[0]; 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 );
iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( GAMESTATE->m_pCurSong, pStyle->m_StyleType ); iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( GAMESTATE->m_pCurSong, pStyle->m_StyleType );
} }
else if( GAMESTATE->m_pCurCourse ) else if( GAMESTATE->m_pCurCourse )