From 6072fb29cc65273c1100731592b2c183fa2be20c Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 5 May 2007 11:08:50 +0000 Subject: [PATCH] Functions in singletons that depend on the singleton having been created should not be static. Removed uses of GAMESTATE inside GameState member functions. --- stepmania/src/GameState.cpp | 26 +++++++++++++------------- stepmania/src/GameState.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 3c9446b839..6a7d75419d 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -336,10 +336,10 @@ void GameState::JoinPlayer( PlayerNumber pn ) } // Set the current style to something appropriate for the new number of joined players. - if( ALLOW_LATE_JOIN && GAMESTATE->m_pCurStyle != NULL ) + if( ALLOW_LATE_JOIN && m_pCurStyle != NULL ) { const Style *pStyle = GAMEMAN->GetFirstCompatibleStyle( m_pCurGame, GetNumSidesJoined(), m_pCurStyle->m_StepsType ); - GAMESTATE->m_pCurStyle.Set( pStyle ); + m_pCurStyle.Set( pStyle ); } Message msg( MessageIDToString(Message_PlayerJoined) ); @@ -357,7 +357,7 @@ void GameState::UnjoinPlayer( PlayerNumber pn ) ResetPlayer( pn ); if( m_MasterPlayerNumber == pn ) - m_MasterPlayerNumber = GAMESTATE->GetFirstHumanPlayer(); + m_MasterPlayerNumber = GetFirstHumanPlayer(); STATSMAN->UnjoinPlayer( pn ); @@ -558,35 +558,35 @@ int GameState::GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st return iNumStages; } -int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() +int GameState::GetNumStagesForCurrentSongAndStepsOrCourse() const { int iNumStagesOfThisSong = 1; - if( GAMESTATE->m_pCurSong ) + if( m_pCurSong ) { - const Style *pStyle = GAMESTATE->m_pCurStyle; + const Style *pStyle = m_pCurStyle; if( pStyle == NULL ) { - const Steps *pSteps = GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber]; + const Steps *pSteps = m_pCurSteps[m_MasterPlayerNumber]; if( pSteps ) { /* If a style isn't set, use the style of the selected steps. */ StepsType st = pSteps->m_StepsType; - pStyle = GAMEMAN->GetFirstCompatibleStyle( GAMESTATE->m_pCurGame, GAMESTATE->GetNumSidesJoined(), st ); + pStyle = GAMEMAN->GetFirstCompatibleStyle( m_pCurGame, GetNumSidesJoined(), st ); } else { /* If steps aren't set either, pick any style for the number of * joined players, or one player if no players are joined. */ vector vpStyles; - int iJoined = max( GAMESTATE->GetNumSidesJoined(), 1 ); - GAMEMAN->GetCompatibleStyles( GAMESTATE->m_pCurGame, iJoined, vpStyles ); + int iJoined = max( GetNumSidesJoined(), 1 ); + GAMEMAN->GetCompatibleStyles( m_pCurGame, iJoined, vpStyles ); ASSERT( !vpStyles.empty() ); pStyle = vpStyles[0]; } } - iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( GAMESTATE->m_pCurSong, pStyle->m_StyleType ); + iNumStagesOfThisSong = GameState::GetNumStagesForSongAndStyleType( m_pCurSong, pStyle->m_StyleType ); } - else if( GAMESTATE->m_pCurCourse ) + else if( m_pCurCourse ) iNumStagesOfThisSong = PREFSMAN->m_iSongsPerPlay; else return -1; @@ -2179,7 +2179,7 @@ public: lua_pushboolean(L, bUsingMemoryCard ); return 1; } - static int GetNumStagesForCurrentSongAndStepsOrCourse( T* p, lua_State *L ) { lua_pushnumber(L, GameState::GetNumStagesForCurrentSongAndStepsOrCourse() ); return 1; } + static int GetNumStagesForCurrentSongAndStepsOrCourse( T* p, lua_State *L ) { lua_pushnumber(L, GAMESTATE->GetNumStagesForCurrentSongAndStepsOrCourse() ); return 1; } static int GetNumStagesLeft( T* p, lua_State *L ) { PlayerNumber pn = Enum::Check(L, 1); diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index f45b9e97f9..5f19e44e86 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -130,7 +130,7 @@ public: static int GetNumStagesMultiplierForSong( const Song* pSong ); static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st ); - static int GetNumStagesForCurrentSongAndStepsOrCourse(); + int GetNumStagesForCurrentSongAndStepsOrCourse() const; void BeginStage(); void CancelStage();