From 4e017b752b3e200c72a1c4e900351c4a10fa6b58 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 23 Jun 2005 01:21:13 +0000 Subject: [PATCH] fix using PLAYER_INVALID as an index when using SSMaster when no players are joined --- stepmania/src/ScreenSelectMaster.cpp | 12 ++++++++++-- stepmania/src/ScreenSelectMaster.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/stepmania/src/ScreenSelectMaster.cpp b/stepmania/src/ScreenSelectMaster.cpp index b3e0ebcdb6..50f1839437 100644 --- a/stepmania/src/ScreenSelectMaster.cpp +++ b/stepmania/src/ScreenSelectMaster.cpp @@ -495,7 +495,7 @@ bool ScreenSelectMaster::ChangePage( int iNewChoice ) if( SHARED_PREVIEW_AND_CURSOR ) { - int iChoice = m_iChoice[GAMESTATE->m_MasterPlayerNumber]; + int iChoice = m_iChoice[GetSharedPlayer()]; for( int i=0; im_MasterPlayerNumber != PLAYER_INVALID ) + return GAMESTATE->m_MasterPlayerNumber; + + return PLAYER_1; +} + ScreenSelectMaster::Page ScreenSelectMaster::GetPage( int iChoiceIndex ) const { return iChoiceIndex < NUM_CHOICES_ON_PAGE_1? PAGE_1:PAGE_2; @@ -644,7 +652,7 @@ ScreenSelectMaster::Page ScreenSelectMaster::GetPage( int iChoiceIndex ) const ScreenSelectMaster::Page ScreenSelectMaster::GetCurrentPage() const { // Both players are guaranteed to be on the same page. - return GetPage( m_iChoice[GAMESTATE->m_MasterPlayerNumber] ); + return GetPage( m_iChoice[GetSharedPlayer()] ); } diff --git a/stepmania/src/ScreenSelectMaster.h b/stepmania/src/ScreenSelectMaster.h index 7cb7c8bf98..37b1d032a4 100644 --- a/stepmania/src/ScreenSelectMaster.h +++ b/stepmania/src/ScreenSelectMaster.h @@ -34,6 +34,7 @@ public: protected: enum Page { PAGE_1, PAGE_2, NUM_PAGES }; // on PAGE_2, cursors are locked together + static PlayerNumber GetSharedPlayer(); Page GetPage( int iChoiceIndex ) const; Page GetCurrentPage() const;