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().

This commit is contained in:
Steve Checkoway
2008-01-19 20:02:38 +00:00
parent c49fb47d05
commit b984649787
2 changed files with 7 additions and 13 deletions
+6 -12
View File
@@ -3506,12 +3506,10 @@ void ScreenEdit::CopyToLastSave()
ASSERT( GAMESTATE->m_pCurSong ); ASSERT( GAMESTATE->m_pCurSong );
ASSERT( GAMESTATE->m_pCurSteps[PLAYER_1] ); ASSERT( GAMESTATE->m_pCurSteps[PLAYER_1] );
m_SongLastSave = *GAMESTATE->m_pCurSong; m_SongLastSave = *GAMESTATE->m_pCurSong;
m_mStepsLastSave.clear(); m_vStepsLastSave.clear();
const vector<Steps*> &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType ); const vector<Steps*> &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType );
for( vector<Steps*>::const_iterator it = vSteps.begin(); it != vSteps.end(); ++it ) FOREACH_CONST( Steps*, vSteps, it )
{ m_vStepsLastSave.push_back( **it );
m_mStepsLastSave[(*it)->GetDifficulty()] = **it;
}
} }
void ScreenEdit::CopyFromLastSave() void ScreenEdit::CopyFromLastSave()
@@ -3521,13 +3519,9 @@ void ScreenEdit::CopyFromLastSave()
// 2) No steps can be deleted by ScreenEdit (except possibly when we exit) // 2) No steps can be deleted by ScreenEdit (except possibly when we exit)
*GAMESTATE->m_pCurSong = m_SongLastSave; *GAMESTATE->m_pCurSong = m_SongLastSave;
const vector<Steps*> &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType ); const vector<Steps*> &vSteps = GAMESTATE->m_pCurSong->GetStepsByStepsType( GAMESTATE->m_pCurSteps[PLAYER_1]->m_StepsType );
ASSERT( vSteps.size() == m_mStepsLastSave.size() ); ASSERT_M( vSteps.size() == m_vStepsLastSave.size(), ssprintf("Step sizes don't match: %d, %d", int(vSteps.size()), int(m_vStepsLastSave.size())) );
for( vector<Steps*>::const_iterator it = vSteps.begin(); it != vSteps.end(); ++it ) for( unsigned i = 0; i < vSteps.size(); ++i )
{ *vSteps[i] = m_vStepsLastSave[i];
map< Difficulty, Steps >::const_iterator itOldSteps = m_mStepsLastSave.find( (*it)->GetDifficulty() );
ASSERT( itOldSteps != m_mStepsLastSave.end() );
**it = itOldSteps->second;
}
} }
void ScreenEdit::RevertFromDisk() void ScreenEdit::RevertFromDisk()
+1 -1
View File
@@ -256,7 +256,7 @@ protected:
void RevertFromDisk(); void RevertFromDisk();
Song m_SongLastSave; Song m_SongLastSave;
map< Difficulty, Steps > m_mStepsLastSave; vector<Steps> m_vStepsLastSave;
// for MODE_RECORD // for MODE_RECORD