From 7d3247a8aa972f9727c290c9daf6fea92cddd305 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 13 Nov 2007 12:08:29 +0000 Subject: [PATCH] fix 'Load player edits, play one of the player edits, continue, choose Nontop; crash' --- stepmania/src/ScreenContinue.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/stepmania/src/ScreenContinue.cpp b/stepmania/src/ScreenContinue.cpp index 4b89eb6778..cef530a92d 100644 --- a/stepmania/src/ScreenContinue.cpp +++ b/stepmania/src/ScreenContinue.cpp @@ -15,14 +15,24 @@ void ScreenContinue::BeginScreen() { GAMESTATE->SetCurrentStyle( NULL ); - // unjoin all players with 0 stages left - FOREACH_HumanPlayer( p ) + // Unjoin human players with 0 stages left and reset non-human players. + // We need to reset non-human players because data in non-human (CPU) + // players will be filled, and there may be stale pointers to things like + // edit Steps. + FOREACH_ENUM( PlayerNumber, p ) { - bool bPlayerDone = GAMESTATE->m_iPlayerStageTokens[p] <= 0; - if( bPlayerDone ) + if( GAMESTATE->IsHumanPlayer(p) ) { - GAMESTATE->UnjoinPlayer( p ); - MEMCARDMAN->UnlockCard( p ); + bool bPlayerDone = GAMESTATE->m_iPlayerStageTokens[p] <= 0; + if( bPlayerDone ) + { + GAMESTATE->UnjoinPlayer( p ); + MEMCARDMAN->UnlockCard( p ); + } + } + else + { + GAMESTATE->ResetPlayer( p ); } }