From b9846497870aa9643f5915b1a64a4ae67ba1fe87 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 19 Jan 2008 20:02:38 +0000 Subject: [PATCH] Fix editor crash with more than one Edit Steps. There's no need for a map here. The saved Song will have the Steps in the same order as they were when the they were saved in CopyToLastSave(). --- stepmania/src/ScreenEdit.cpp | 18 ++++++------------ stepmania/src/ScreenEdit.h | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index e85d1e1de7..c57e74b7f5 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -3506,12 +3506,10 @@ void ScreenEdit::CopyToLastSave() ASSERT( GAMESTATE->m_pCurSong ); ASSERT( GAMESTATE->m_pCurSteps[PLAYER_1] ); m_SongLastSave = *GAMESTATE->m_pCurSong; - m_mStepsLastSave.clear(); + m_vStepsLastSave.clear(); const vector &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType ); - for( vector::const_iterator it = vSteps.begin(); it != vSteps.end(); ++it ) - { - m_mStepsLastSave[(*it)->GetDifficulty()] = **it; - } + FOREACH_CONST( Steps*, vSteps, it ) + m_vStepsLastSave.push_back( **it ); } void ScreenEdit::CopyFromLastSave() @@ -3521,13 +3519,9 @@ void ScreenEdit::CopyFromLastSave() // 2) No steps can be deleted by ScreenEdit (except possibly when we exit) *GAMESTATE->m_pCurSong = m_SongLastSave; const vector &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType ); - ASSERT( vSteps.size() == m_mStepsLastSave.size() ); - for( vector::const_iterator it = vSteps.begin(); it != vSteps.end(); ++it ) - { - map< Difficulty, Steps >::const_iterator itOldSteps = m_mStepsLastSave.find( (*it)->GetDifficulty() ); - ASSERT( itOldSteps != m_mStepsLastSave.end() ); - **it = itOldSteps->second; - } + ASSERT_M( vSteps.size() == m_vStepsLastSave.size(), ssprintf("Step sizes don't match: %d, %d", int(vSteps.size()), int(m_vStepsLastSave.size())) ); + for( unsigned i = 0; i < vSteps.size(); ++i ) + *vSteps[i] = m_vStepsLastSave[i]; } void ScreenEdit::RevertFromDisk() diff --git a/stepmania/src/ScreenEdit.h b/stepmania/src/ScreenEdit.h index 80587316df..dbf2542efc 100644 --- a/stepmania/src/ScreenEdit.h +++ b/stepmania/src/ScreenEdit.h @@ -256,7 +256,7 @@ protected: void RevertFromDisk(); Song m_SongLastSave; - map< Difficulty, Steps > m_mStepsLastSave; + vector m_vStepsLastSave; // for MODE_RECORD