From 08a504dd8d05c8b5bfb52315e30f2b2dde4df31a Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Wed, 23 Jul 2008 12:27:12 +0000 Subject: [PATCH] Fix extra stage crash on songs with more than one stage. Fixes bugs 1905623, 1906055, and 1879968 (probably). --- stepmania/src/GameState.cpp | 9 ++++++++- stepmania/src/SongUtil.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 627d278f38..fe587396d5 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -633,7 +633,11 @@ int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() const pStyle = vpStyles[0]; } } - iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( m_pCurSong, pStyle->m_StyleType ); + /* Extra stages need to only count as one stage in case a multistage song is chosen. */ + if( IsAnExtraStage() ) + iNumStagesOfThisSong = 1; + else + iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( m_pCurSong, pStyle->m_StyleType ); } else if( m_pCurCourse ) iNumStagesOfThisSong = PREFSMAN->m_iSongsPerPlay; @@ -670,7 +674,10 @@ void GameState::BeginStage() m_iNumStagesOfThisSong = GetNumStagesForCurrentSongAndStepsOrCourse(); ASSERT( m_iNumStagesOfThisSong != -1 ); FOREACH_EnabledPlayer( p ) + { + ASSERT( m_iPlayerStageTokens[p] >= m_iNumStagesOfThisSong ); m_iPlayerStageTokens[p] -= m_iNumStagesOfThisSong; + } FOREACH_HumanPlayer( pn ) if( CurrentOptionsDisqualifyPlayer(pn) ) diff --git a/stepmania/src/SongUtil.cpp b/stepmania/src/SongUtil.cpp index ddd4a03a34..0287551c84 100644 --- a/stepmania/src/SongUtil.cpp +++ b/stepmania/src/SongUtil.cpp @@ -867,7 +867,7 @@ void SongUtil::GetPlayableStepsTypes( const Song *pSong, set &vOut ) iNumPlayers = max( iNumPlayers, 1 ); const Style *pStyle = GameManager::GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, iNumPlayers, *st ); - bool bEnoughStages = GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer() >= GAMESTATE->GetNumStagesForSongAndStyleType(pSong, pStyle->m_StyleType); + bool bEnoughStages = GAMESTATE->IsAnExtraStage() || GAMESTATE->GetSmallestNumStagesLeftForAnyHumanPlayer() >= GAMESTATE->GetNumStagesForSongAndStyleType(pSong, pStyle->m_StyleType); if( bShowThisStepsType && bEnoughStages ) vOut.insert( *st );