From 7de6bd605c35fc6418c3f3ec2609ce8724bd1001 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 24 Apr 2007 00:44:51 +0000 Subject: [PATCH] revert IsStagePossible; not sure yet --- stepmania/src/GameState.cpp | 28 ++++++++++++++++++++++++++++ stepmania/src/GameState.h | 1 + 2 files changed, 29 insertions(+) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 00a2b06802..eee1422f7d 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -946,6 +946,32 @@ Stage GameState::GetCurrentStage() const else return (Stage)(STAGE_1+GetLargestCurrentStageIndexForAnyHumanPlayer()); } +// Return true if it's possible for GetCurrentStage() to return the given stage. +bool GameState::IsStagePossible( Stage s ) const +{ + /* HACK: Find out what the stage would be without long or marathon. + * This should never change during a screen. */ + Song *pSong = m_pCurSong; + // XXX: Using GAMESTATE to get around const is potentially dangerous. + GAMESTATE->m_pCurSong.SetWithoutBroadcast( NULL ); + Stage actual = GAMESTATE->GetCurrentStage(); + GAMESTATE->m_pCurSong.SetWithoutBroadcast( pSong ); + + /* Check long/marathon, which can change the stage to FINAL. */ + if( s == STAGE_FINAL && actual >= STAGE_1 && actual <= STAGE_FINAL ) + { + Stage max_actual = actual; + + // For long/marathon songs: + enum_add( max_actual, +2 ); + + if( max_actual >= STAGE_FINAL ) + return true; + } + + return s == actual; +} + int GameState::GetCourseSongIndex() const { int iSongIndex = 0; @@ -2164,6 +2190,7 @@ public: DEFINE_METHOD( IsExtraStage, IsExtraStage() ) DEFINE_METHOD( IsExtraStage2, IsExtraStage2() ) DEFINE_METHOD( GetCurrentStage, GetCurrentStage() ) + DEFINE_METHOD( IsStagePossible, IsStagePossible( Enum::Check(L, 1)) ) DEFINE_METHOD( HasEarnedExtraStage, HasEarnedExtraStage() ) DEFINE_METHOD( GetEasiestStepsDifficulty, GetEasiestStepsDifficulty() ) DEFINE_METHOD( IsEventMode, IsEventMode() ) @@ -2332,6 +2359,7 @@ public: ADD_METHOD( IsExtraStage ); ADD_METHOD( IsExtraStage2 ); ADD_METHOD( GetCurrentStage ); + ADD_METHOD( IsStagePossible ); ADD_METHOD( HasEarnedExtraStage ); ADD_METHOD( GetEasiestStepsDifficulty ); ADD_METHOD( IsEventMode ); diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index b27c7ea82b..2db922d303 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -143,6 +143,7 @@ public: bool IsExtraStage() const; bool IsExtraStage2() const; Stage GetCurrentStage() const; + bool IsStagePossible( Stage s ) const; int GetCourseSongIndex() const; RString GetPlayerDisplayName( PlayerNumber pn ) const;