From 2ff53582a16d437c58692a2c665714bec625c556 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 4 Mar 2006 02:34:01 +0000 Subject: [PATCH] Fix crashes when using the second player. Use the master player number for everything except setting the current trail which needs to be PLAYER_1 because there are different messages for each player's trail changing. Perhaps that should change at some point. --- stepmania/src/ScreenOptionsEditCourse.cpp | 4 ++-- stepmania/src/ScreenOptionsEditCourseEntry.cpp | 11 +++++------ stepmania/src/ScreenOptionsManageCourses.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/stepmania/src/ScreenOptionsEditCourse.cpp b/stepmania/src/ScreenOptionsEditCourse.cpp index a8ca14a7d4..65008d50e5 100644 --- a/stepmania/src/ScreenOptionsEditCourse.cpp +++ b/stepmania/src/ScreenOptionsEditCourse.cpp @@ -199,12 +199,12 @@ void ScreenOptionsEditCourse::AfterChangeValueInRow( int iRow, PlayerNumber pn ) Course *pCourse = GAMESTATE->m_pCurCourse; // Regenerate Trails so that the new values propagate - GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( NULL ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL ); Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ); // cause overlay elements to refresh by changing the course GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( pTrail ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); } void ScreenOptionsEditCourse::ImportOptions( int iRow, const vector &vpns ) diff --git a/stepmania/src/ScreenOptionsEditCourseEntry.cpp b/stepmania/src/ScreenOptionsEditCourseEntry.cpp index f6ae0eeb10..9085fe2651 100644 --- a/stepmania/src/ScreenOptionsEditCourseEntry.cpp +++ b/stepmania/src/ScreenOptionsEditCourseEntry.cpp @@ -247,12 +247,11 @@ void ScreenOptionsEditCourseEntry::HandleScreenMessage( const ScreenMessage SM ) void ScreenOptionsEditCourseEntry::AfterChangeValueInRow( int iRow, PlayerNumber pn ) { - PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; ScreenOptions::AfterChangeValueInRow( iRow, pn ); Course *pCourse = GAMESTATE->m_pCurCourse; - GAMESTATE->m_pCurTrail[mpn].Set( NULL ); - Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->m_stEdit, GAMESTATE->m_PreferredCourseDifficulty[mpn] ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( NULL ); + Trail *pTrail = pCourse->GetTrailForceRegenCache( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ); int iEntryIndex = GAMESTATE->m_iEditCourseEntryIndex; ASSERT( iEntryIndex >= 0 && iEntryIndex < (int) pCourse->m_vEntries.size() ); CourseEntry &ce = pCourse->m_vEntries[ iEntryIndex ]; @@ -263,7 +262,7 @@ void ScreenOptionsEditCourseEntry::AfterChangeValueInRow( int iRow, PlayerNumber // refresh songs { vector vpns; - vpns.push_back( mpn ); + vpns.push_back( pn ); ExportOptions( ROW_SONG_GROUP, vpns ); m_pSongHandler->m_sSongGroup = ce.sSongGroup; @@ -271,7 +270,7 @@ void ScreenOptionsEditCourseEntry::AfterChangeValueInRow( int iRow, PlayerNumber OptionRow &row = *m_pRows[ROW_SONG]; row.Reload(); ImportOptions( ROW_SONG, vpns ); - row.AfterImportOptions( mpn ); + row.AfterImportOptions( pn ); break; } } @@ -279,7 +278,7 @@ void ScreenOptionsEditCourseEntry::AfterChangeValueInRow( int iRow, PlayerNumber // cause overlay elements to refresh by changing the course GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_pCurTrail[mpn].Set( pTrail ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); } diff --git a/stepmania/src/ScreenOptionsManageCourses.cpp b/stepmania/src/ScreenOptionsManageCourses.cpp index a95916359c..701bcf185e 100644 --- a/stepmania/src/ScreenOptionsManageCourses.cpp +++ b/stepmania/src/ScreenOptionsManageCourses.cpp @@ -21,7 +21,7 @@ static void RefreshTrail() return; GAMESTATE->m_pCurCourse.Set( pCourse ); Trail *pTrail = pCourse->GetTrail( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ); - GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( pTrail ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); } struct StepsTypeAndDifficulty @@ -134,7 +134,7 @@ void ScreenOptionsManageCourses::Init() ScreenOptionsEditCourseSubMenu::Init(); EDIT_MODE.Load( m_sName,"EditMode" ); - GAMESTATE->m_MasterPlayerNumber = PLAYER_1; + GAMESTATE->m_MasterPlayerNumber = GetNextEnabledPlayer( PlayerNumber(-1) ); } void ScreenOptionsManageCourses::BeginScreen() @@ -298,7 +298,7 @@ void ScreenOptionsManageCourses::HandleScreenMessage( const ScreenMessage SM ) Course *pCourse = GetCourseWithFocus(); Trail *pTrail = pCourse->GetTrail( STEPS_TYPE_DANCE_SINGLE ); GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( pTrail ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); ScreenOptions::BeginFadingOut(); break; @@ -334,7 +334,7 @@ void ScreenOptionsManageCourses::AfterChangeRow( PlayerNumber pn ) Trail *pTrail = pCourse ? pCourse->GetTrail( GAMESTATE->m_stEdit, GAMESTATE->m_cdEdit ) : NULL; GAMESTATE->m_pCurCourse.Set( pCourse ); - GAMESTATE->m_pCurTrail[GAMESTATE->m_MasterPlayerNumber].Set( pTrail ); + GAMESTATE->m_pCurTrail[PLAYER_1].Set( pTrail ); ScreenOptions::AfterChangeRow( pn ); }