From 42d279926bdf6c22cb10d6c1cf531252e759ec29 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 15 Aug 2006 21:18:23 +0000 Subject: [PATCH] fix crash when selecting course mods in editor --- stepmania/src/NoteField.cpp | 2 ++ stepmania/src/ScreenEdit.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/stepmania/src/NoteField.cpp b/stepmania/src/NoteField.cpp index 11a65b016f..62d07841b4 100644 --- a/stepmania/src/NoteField.cpp +++ b/stepmania/src/NoteField.cpp @@ -542,6 +542,8 @@ void NoteField::DrawPrimitives() const Course *pCourse = GAMESTATE->m_pCurCourse; if( pCourse ) { + ASSERT_M( GAMESTATE->m_iEditCourseEntryIndex > 0 && GAMESTATE->m_iEditCourseEntryIndex < (int)pCourse->m_vEntries.size(), + ssprintf("%i",GAMESTATE->m_iEditCourseEntryIndex.Get()) ); const CourseEntry &ce = pCourse->m_vEntries[GAMESTATE->m_iEditCourseEntryIndex]; FOREACH_CONST( Attack, ce.attacks, a ) { diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index ed6f1e86ec..1d51810ce3 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2406,7 +2406,18 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) { const RString name = g_CourseMode.rows[0].choices[num]; Course *pCourse = SONGMAN->FindCourse( name ); + + int iCourseEntryIndex = -1; + FOREACH_CONST( CourseEntry, pCourse->m_vEntries, i ) + { + if( i->pSong == GAMESTATE->m_pCurSong.Get() ) + iCourseEntryIndex = i - pCourse->m_vEntries.begin(); + } + + ASSERT( iCourseEntryIndex != -1 ); + GAMESTATE->m_pCurCourse.Set( pCourse ); + GAMESTATE->m_iEditCourseEntryIndex.Set( iCourseEntryIndex ); ASSERT( GAMESTATE->m_pCurCourse ); } }