Simplify. We shouldn't use the global GAMESTATE inside the GameState class itself. It hides the fact that we may be calling nonconst member functions from const member functions.

This commit is contained in:
Steve Checkoway
2006-08-06 02:58:46 +00:00
parent a6cd1ace09
commit 3689f73596
+68 -67
View File
@@ -150,7 +150,7 @@ void GameState::ApplyCmdline()
if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS ) if( !IsAnInt( sPlayer ) || pn < 0 || pn >= NUM_PLAYERS )
RageException::Throw( "Invalid argument \"--player=%s\"", sPlayer.c_str() ); RageException::Throw( "Invalid argument \"--player=%s\"", sPlayer.c_str() );
this->JoinPlayer( (PlayerNumber) pn ); JoinPlayer( (PlayerNumber) pn );
} }
RString sMode; RString sMode;
@@ -196,7 +196,7 @@ void GameState::Reset()
m_iNumStagesOfThisSong = 0; m_iNumStagesOfThisSong = 0;
m_bLoadingNextSong = false; m_bLoadingNextSong = false;
NOTESKIN->RefreshNoteSkinData( this->m_pCurGame ); NOTESKIN->RefreshNoteSkinData( m_pCurGame );
m_iGameSeed = rand(); m_iGameSeed = rand();
m_iStageSeed = rand(); m_iStageSeed = rand();
@@ -233,7 +233,7 @@ void GameState::Reset()
STATSMAN->Reset(); STATSMAN->Reset();
SongOptions so; SongOptions so;
GAMESTATE->GetDefaultSongOptions( so ); GetDefaultSongOptions( so );
m_SongOptions.Assign( ModsLevel_Preferred, so ); m_SongOptions.Assign( ModsLevel_Preferred, so );
FOREACH_PlayerNumber(p) FOREACH_PlayerNumber(p)
@@ -247,8 +247,8 @@ void GameState::Reset()
// affect demo, and other non-gameplay things ...) -glenn // affect demo, and other non-gameplay things ...) -glenn
PlayerOptions po; PlayerOptions po;
GAMESTATE->GetDefaultPlayerOptions( po ); GetDefaultPlayerOptions( po );
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.Assign( ModsLevel_Preferred, po ); m_pPlayerState[p]->m_PlayerOptions.Assign( ModsLevel_Preferred, po );
} }
FOREACH_PlayerNumber(p) FOREACH_PlayerNumber(p)
@@ -278,27 +278,27 @@ void GameState::Reset()
void GameState::JoinPlayer( PlayerNumber pn ) void GameState::JoinPlayer( PlayerNumber pn )
{ {
this->m_bSideIsJoined[pn] = true; m_bSideIsJoined[pn] = true;
MESSAGEMAN->Broadcast( (Message)(Message_SideJoinedP1+pn) ); MESSAGEMAN->Broadcast( (Message)(Message_SideJoinedP1+pn) );
if( this->m_MasterPlayerNumber == PLAYER_INVALID ) if( m_MasterPlayerNumber == PLAYER_INVALID )
this->m_MasterPlayerNumber = pn; m_MasterPlayerNumber = pn;
// if first player to join, set start time // if first player to join, set start time
if( this->GetNumSidesJoined() == 1 ) if( GetNumSidesJoined() == 1 )
this->BeginGame(); BeginGame();
} }
int GameState::GetCoinsNeededToJoin() const int GameState::GetCoinsNeededToJoin() const
{ {
int iCoinsToCharge = 0; int iCoinsToCharge = 0;
if( GAMESTATE->GetCoinMode() == COIN_MODE_PAY ) if( GetCoinMode() == COIN_MODE_PAY )
iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit; iCoinsToCharge = PREFSMAN->m_iCoinsPerCredit;
// If joint premium don't take away a credit for the 2nd join. // If joint premium don't take away a credit for the 2nd join.
if( GAMESTATE->GetPremium() == PREMIUM_JOINT && if( GetPremium() == PREMIUM_JOINT &&
GAMESTATE->GetNumSidesJoined() == 1 ) GetNumSidesJoined() == 1 )
iCoinsToCharge = 0; iCoinsToCharge = 0;
return iCoinsToCharge; return iCoinsToCharge;
@@ -363,14 +363,14 @@ void GameState::PlayersFinalized()
Profile* pProfile = PROFILEMAN->GetProfile(pn); Profile* pProfile = PROFILEMAN->GetProfile(pn);
RString sModifiers; RString sModifiers;
if( pProfile->GetDefaultModifiers( this->m_pCurGame, sModifiers ) ) if( pProfile->GetDefaultModifiers( m_pCurGame, sModifiers ) )
{ {
/* We don't save negative preferences (eg. "no reverse"). If the theme /* We don't save negative preferences (eg. "no reverse"). If the theme
* sets a default of "reverse", and the player turns it off, we should * sets a default of "reverse", and the player turns it off, we should
* set it off. However, don't reset modifiers that aren't saved by the * set it off. However, don't reset modifiers that aren't saved by the
* profile, so we don't ignore unsaved modifiers when a profile is in use. */ * profile, so we don't ignore unsaved modifiers when a profile is in use. */
PO_GROUP_CALL( GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Preferred, ResetSavedPrefs ); PO_GROUP_CALL( m_pPlayerState[pn]->m_PlayerOptions, ModsLevel_Preferred, ResetSavedPrefs );
GAMESTATE->ApplyPreferredModifiers( pn, sModifiers ); ApplyPreferredModifiers( pn, sModifiers );
} }
// Only set the sort order if it wasn't already set by a GameCommand (or by an earlier profile) // Only set the sort order if it wasn't already set by a GameCommand (or by an earlier profile)
if( m_PreferredSortOrder == SORT_INVALID && pProfile->m_SortOrder != SORT_INVALID ) if( m_PreferredSortOrder == SORT_INVALID && pProfile->m_SortOrder != SORT_INVALID )
@@ -482,7 +482,7 @@ void GameState::BeginStage()
* have, for some reason, gone from gameplay to evaluation straight back to gameplay.) */ * have, for some reason, gone from gameplay to evaluation straight back to gameplay.) */
FinishStage(); FinishStage();
GAMESTATE->ResetStageStatistics(); ResetStageStatistics();
FOREACH_PlayerNumber( p ) FOREACH_PlayerNumber( p )
m_pPlayerState[p]->m_PlayerOptions.Assign( ModsLevel_Stage, m_pPlayerState[p]->m_PlayerOptions.GetPreferred() ); m_pPlayerState[p]->m_PlayerOptions.Assign( ModsLevel_Stage, m_pPlayerState[p]->m_PlayerOptions.GetPreferred() );
@@ -495,7 +495,7 @@ void GameState::BeginStage()
void GameState::CancelStage() void GameState::CancelStage()
{ {
m_iNumStagesOfThisSong = 0; m_iNumStagesOfThisSong = 0;
GAMESTATE->ResetStageStatistics(); ResetStageStatistics();
} }
void GameState::CommitStageStats() void GameState::CommitStageStats()
@@ -531,12 +531,12 @@ void GameState::FinishStage()
m_iNumStagesOfThisSong = 0; m_iNumStagesOfThisSong = 0;
// necessary so that bGaveUp is reset // necessary so that bGaveUp is reset
GAMESTATE->ResetStageStatistics(); ResetStageStatistics();
if( m_bDemonstrationOrJukebox ) if( m_bDemonstrationOrJukebox )
return; return;
if( GAMESTATE->IsEventMode() ) if( IsEventMode() )
{ {
const int iSaveProfileEvery = 3; const int iSaveProfileEvery = 3;
if( iOldStageIndex/iSaveProfileEvery < m_iCurrentStageIndex/iSaveProfileEvery ) if( iOldStageIndex/iSaveProfileEvery < m_iCurrentStageIndex/iSaveProfileEvery )
@@ -556,7 +556,7 @@ void GameState::SaveCurrentSettingsToProfile( PlayerNumber pn )
Profile* pProfile = PROFILEMAN->GetProfile(pn); Profile* pProfile = PROFILEMAN->GetProfile(pn);
pProfile->SetDefaultModifiers( this->m_pCurGame, m_pPlayerState[pn]->m_PlayerOptions.GetPreferred().GetSavedPrefsString() ); pProfile->SetDefaultModifiers( m_pCurGame, m_pPlayerState[pn]->m_PlayerOptions.GetPreferred().GetSavedPrefsString() );
if( IsSongSort(m_PreferredSortOrder) ) if( IsSongSort(m_PreferredSortOrder) )
pProfile->m_SortOrder = m_PreferredSortOrder; pProfile->m_SortOrder = m_PreferredSortOrder;
if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID ) if( m_PreferredDifficulty[pn] != DIFFICULTY_INVALID )
@@ -652,7 +652,7 @@ void GameState::ResetStageStatistics()
// Reset the round seed. Do this here and not in FinishStage so that players // Reset the round seed. Do this here and not in FinishStage so that players
// get new shuffle patterns if they Back out of gameplay and play again. // get new shuffle patterns if they Back out of gameplay and play again.
GAMESTATE->m_iStageSeed = rand(); m_iStageSeed = rand();
AdjustSync::ResetOriginalSyncData(); AdjustSync::ResetOriginalSyncData();
} }
@@ -690,17 +690,17 @@ int GameState::GetNumStagesLeft() const
{ {
if( IsAnExtraStage() ) if( IsAnExtraStage() )
return 1; return 1;
if( GAMESTATE->IsEventMode() ) if( IsEventMode() )
return 999; return 999;
return PREFSMAN->m_iSongsPerPlay - m_iCurrentStageIndex; return PREFSMAN->m_iSongsPerPlay - m_iCurrentStageIndex;
} }
bool GameState::IsFinalStage() const bool GameState::IsFinalStage() const
{ {
if( GAMESTATE->IsEventMode() ) if( IsEventMode() )
return false; return false;
if( this->IsCourseMode() ) if( IsCourseMode() )
return true; return true;
/* This changes dynamically on ScreenSelectMusic as the wheel turns. */ /* This changes dynamically on ScreenSelectMusic as the wheel turns. */
@@ -729,7 +729,7 @@ Stage GameState::GetCurrentStage() const
{ {
if( m_bDemonstrationOrJukebox ) return STAGE_DEMO; if( m_bDemonstrationOrJukebox ) return STAGE_DEMO;
// "event" has precedence // "event" has precedence
else if( GAMESTATE->IsEventMode() ) return STAGE_EVENT; else if( IsEventMode() ) return STAGE_EVENT;
else if( m_PlayMode == PLAY_MODE_ONI ) return STAGE_ONI; else if( m_PlayMode == PLAY_MODE_ONI ) return STAGE_ONI;
else if( m_PlayMode == PLAY_MODE_NONSTOP ) return STAGE_NONSTOP; else if( m_PlayMode == PLAY_MODE_NONSTOP ) return STAGE_NONSTOP;
else if( m_PlayMode == PLAY_MODE_ENDLESS ) return STAGE_ENDLESS; else if( m_PlayMode == PLAY_MODE_ENDLESS ) return STAGE_ENDLESS;
@@ -744,9 +744,10 @@ bool GameState::IsStagePossible( Stage s ) const
{ {
/* HACK: Find out what the stage would be without long or marathon. /* HACK: Find out what the stage would be without long or marathon.
* This should never change during a screen. */ * This should never change during a screen. */
Song *pSong = GAMESTATE->m_pCurSong; Song *pSong = m_pCurSong;
// XXX: Using GAMESTATE to get around const is potentially dangerous.
GAMESTATE->m_pCurSong.SetWithoutBroadcast( NULL ); GAMESTATE->m_pCurSong.SetWithoutBroadcast( NULL );
Stage actual = GetCurrentStage(); Stage actual = GAMESTATE->GetCurrentStage();
GAMESTATE->m_pCurSong.SetWithoutBroadcast( pSong ); GAMESTATE->m_pCurSong.SetWithoutBroadcast( pSong );
/* Check long/marathon, which can change the stage to FINAL. */ /* Check long/marathon, which can change the stage to FINAL. */
@@ -806,7 +807,7 @@ RString GameState::GetPlayerDisplayName( PlayerNumber pn ) const
bool GameState::PlayersCanJoin() const bool GameState::PlayersCanJoin() const
{ {
return GetNumSidesJoined() == 0 || this->m_pCurStyle == NULL; // selecting a style finalizes the players return GetNumSidesJoined() == 0 || m_pCurStyle == NULL; // selecting a style finalizes the players
} }
int GameState::GetNumSidesJoined() const int GameState::GetNumSidesJoined() const
@@ -867,7 +868,7 @@ int GameState::GetNumPlayersEnabled() const
bool GameState::PlayerUsingBothSides() const bool GameState::PlayerUsingBothSides() const
{ {
ASSERT( this->GetCurrentStyle() != NULL ); ASSERT( GetCurrentStyle() != NULL );
switch( GetCurrentStyle()->m_StyleType ) switch( GetCurrentStyle()->m_StyleType )
{ {
case ONE_PLAYER_TWO_SIDES: case ONE_PLAYER_TWO_SIDES:
@@ -882,7 +883,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
{ {
if( m_pCurStyle == NULL ) // no style chosen if( m_pCurStyle == NULL ) // no style chosen
{ {
if( this->PlayersCanJoin() ) if( PlayersCanJoin() )
return m_bSideIsJoined[pn]; // only allow input from sides that have already joined return m_bSideIsJoined[pn]; // only allow input from sides that have already joined
else else
return true; // if we can't join, then we're on a screen like MusicScroll or GameOver return true; // if we can't join, then we're on a screen like MusicScroll or GameOver
@@ -954,7 +955,7 @@ bool GameState::IsCourseMode() const
bool GameState::IsBattleMode() const bool GameState::IsBattleMode() const
{ {
switch( this->m_PlayMode ) switch( m_PlayMode )
{ {
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
return true; return true;
@@ -965,13 +966,13 @@ bool GameState::IsBattleMode() const
bool GameState::HasEarnedExtraStage() const bool GameState::HasEarnedExtraStage() const
{ {
if( GAMESTATE->IsEventMode() ) if( IsEventMode() )
return false; return false;
if( !PREFSMAN->m_bAllowExtraStage ) if( !PREFSMAN->m_bAllowExtraStage )
return false; return false;
if( this->m_PlayMode != PLAY_MODE_REGULAR ) if( m_PlayMode != PLAY_MODE_REGULAR )
return false; return false;
if( m_bBackedOutOfFinalStage ) if( m_bBackedOutOfFinalStage )
@@ -984,8 +985,8 @@ bool GameState::HasEarnedExtraStage() const
FOREACH_EnabledPlayer( pn ) FOREACH_EnabledPlayer( pn )
{ {
if( this->m_pCurSteps[pn]->GetDifficulty() != DIFFICULTY_HARD && if( m_pCurSteps[pn]->GetDifficulty() != DIFFICULTY_HARD &&
this->m_pCurSteps[pn]->GetDifficulty() != DIFFICULTY_CHALLENGE ) m_pCurSteps[pn]->GetDifficulty() != DIFFICULTY_CHALLENGE )
continue; /* not hard enough! */ continue; /* not hard enough! */
if( STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= Grade_Tier03 ) if( STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= Grade_Tier03 )
@@ -999,11 +1000,11 @@ bool GameState::HasEarnedExtraStage() const
return false; return false;
/* If PickExtraStage, allow EX2 if the chosen song was correct. */ /* If PickExtraStage, allow EX2 if the chosen song was correct. */
if( PREFSMAN->m_bPickExtraStage && this->IsExtraStage() ) if( PREFSMAN->m_bPickExtraStage && IsExtraStage() )
{ {
Song* pSong; Song* pSong;
Steps* pSteps; Steps* pSteps;
SONGMAN->GetExtraStageInfo( false, GAMESTATE->GetCurrentStyle(), pSong, pSteps, NULL, NULL ); SONGMAN->GetExtraStageInfo( false, GetCurrentStyle(), pSong, pSteps, NULL, NULL );
ASSERT(pSong); ASSERT(pSong);
const StageStats &stats = STATSMAN->m_CurStageStats; const StageStats &stats = STATSMAN->m_CurStageStats;
@@ -1023,7 +1024,7 @@ PlayerNumber GameState::GetBestPlayer() const
StageResult GameState::GetStageResult( PlayerNumber pn ) const StageResult GameState::GetStageResult( PlayerNumber pn ) const
{ {
switch( this->m_PlayMode ) switch( m_PlayMode )
{ {
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
case PLAY_MODE_RAVE: case PLAY_MODE_RAVE:
@@ -1102,7 +1103,7 @@ bool GameState::IsDisqualified( PlayerNumber pn )
if( !PREFSMAN->m_bDisqualification ) if( !PREFSMAN->m_bDisqualification )
return false; return false;
if( !GAMESTATE->IsHumanPlayer(pn) ) if( !IsHumanPlayer(pn) )
return false; return false;
if( STATSMAN->m_CurStageStats.bGaveUp ) if( STATSMAN->m_CurStageStats.bGaveUp )
@@ -1113,14 +1114,14 @@ bool GameState::IsDisqualified( PlayerNumber pn )
return true; return true;
#endif //DEBUG #endif //DEBUG
const PlayerOptions &po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetPreferred(); const PlayerOptions &po = m_pPlayerState[pn]->m_PlayerOptions.GetPreferred();
// Check the stored player options for disqualify. Don't disqualify because // Check the stored player options for disqualify. Don't disqualify because
// of mods that were forced. // of mods that were forced.
if( GAMESTATE->IsCourseMode() ) if( IsCourseMode() )
return po.IsEasierForCourseAndTrail( GAMESTATE->m_pCurCourse, GAMESTATE->m_pCurTrail[pn] ); return po.IsEasierForCourseAndTrail( m_pCurCourse, m_pCurTrail[pn] );
else else
return po.IsEasierForSongAndSteps( GAMESTATE->m_pCurSong, GAMESTATE->m_pCurSteps[pn], pn); return po.IsEasierForSongAndSteps( m_pCurSong, m_pCurSteps[pn], pn);
} }
void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
@@ -1130,9 +1131,9 @@ void GameState::GetAllUsedNoteSkins( vector<RString> &out ) const
out.push_back( m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_sNoteSkin ); out.push_back( m_pPlayerState[pn]->m_PlayerOptions.GetCurrent().m_sNoteSkin );
/* Add note skins that are used in courses. */ /* Add note skins that are used in courses. */
if( this->IsCourseMode() ) if( IsCourseMode() )
{ {
const Trail *pTrail = this->m_pCurTrail[pn]; const Trail *pTrail = m_pCurTrail[pn];
ASSERT( pTrail ); ASSERT( pTrail );
FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e ) FOREACH_CONST( TrailEntry, pTrail->m_vEntries, e )
@@ -1174,12 +1175,12 @@ SongOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayerSt
SongOptions::FailType ft = m_SongOptions.GetCurrent().m_FailType; SongOptions::FailType ft = m_SongOptions.GetCurrent().m_FailType;
/* If the player changed the fail mode explicitly, leave it alone. */ /* If the player changed the fail mode explicitly, leave it alone. */
if( this->m_bChangedFailTypeOnScreenSongOptions ) if( m_bChangedFailTypeOnScreenSongOptions )
return ft; return ft;
if( GAMESTATE->IsCourseMode() ) if( IsCourseMode() )
{ {
if( PREFSMAN->m_bMinimum1FullSongInCourses && GAMESTATE->GetCourseSongIndex()==0 ) if( PREFSMAN->m_bMinimum1FullSongInCourses && GetCourseSongIndex()==0 )
ft = max( ft, SongOptions::FAIL_END_OF_SONG ); // take the least harsh of the two FailTypes ft = max( ft, SongOptions::FAIL_END_OF_SONG ); // take the least harsh of the two FailTypes
} }
else else
@@ -1188,7 +1189,7 @@ SongOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayerSt
if( m_pCurSteps[pn] ) if( m_pCurSteps[pn] )
dc = m_pCurSteps[pn]->GetDifficulty(); dc = m_pCurSteps[pn]->GetDifficulty();
bool bFirstStage = !GAMESTATE->IsEventMode() && m_iCurrentStageIndex == 0; bool bFirstStage = !IsEventMode() && m_iCurrentStageIndex == 0;
/* Easy and beginner are never harder than FAIL_END_OF_SONG. */ /* Easy and beginner are never harder than FAIL_END_OF_SONG. */
if( dc <= DIFFICULTY_EASY ) if( dc <= DIFFICULTY_EASY )
@@ -1229,8 +1230,8 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
// Check for feats even if the PlayMode is rave or battle because the player may have // Check for feats even if the PlayMode is rave or battle because the player may have
// made high scores then switched modes. // made high scores then switched modes.
CHECKPOINT_M(ssprintf("PlayMode %i", int(this->m_PlayMode))); CHECKPOINT_M( ssprintf("PlayMode %i", int(m_PlayMode)) );
switch( this->m_PlayMode ) switch( m_PlayMode )
{ {
case PLAY_MODE_REGULAR: case PLAY_MODE_REGULAR:
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
@@ -1238,7 +1239,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
{ {
CHECKPOINT; CHECKPOINT;
StepsType st = this->GetCurrentStyle()->m_StepsType; StepsType st = GetCurrentStyle()->m_StepsType;
// //
// Find unique Song and Steps combinations that were played. // Find unique Song and Steps combinations that were played.
@@ -1589,11 +1590,11 @@ void GameState::VisitAttractScreen( const RString sScreenName )
bool GameState::DifficultiesLocked() bool GameState::DifficultiesLocked()
{ {
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE ) if( m_PlayMode == PLAY_MODE_RAVE )
return true; return true;
if( IsCourseMode() ) if( IsCourseMode() )
return PREFSMAN->m_bLockCourseDifficulties; return PREFSMAN->m_bLockCourseDifficulties;
if( GAMESTATE->GetCurrentStyle()->m_bLockDifficulties ) if( GetCurrentStyle()->m_bLockDifficulties )
return true; return true;
return false; return false;
} }
@@ -1616,7 +1617,7 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
{ {
const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); const vector<Difficulty> &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue();
Difficulty d = GAMESTATE->GetClosestShownDifficulty(pn); Difficulty d = GetClosestShownDifficulty(pn);
while( 1 ) while( 1 )
{ {
d = (Difficulty)(d+dir); d = (Difficulty)(d+dir);
@@ -1666,7 +1667,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficul
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
{ {
/* If we have a course selected, only choose among difficulties available in the course. */ /* If we have a course selected, only choose among difficulties available in the course. */
const Course *pCourse = this->m_pCurCourse; const Course *pCourse = m_pCurCourse;
const vector<CourseDifficulty> &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); const vector<CourseDifficulty> &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue();
@@ -1678,7 +1679,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
return false; return false;
if( find(v.begin(),v.end(),cd) == v.end() ) if( find(v.begin(),v.end(),cd) == v.end() )
continue; /* not available */ continue; /* not available */
if( !pCourse || pCourse->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType, cd ) ) if( !pCourse || pCourse->GetTrail( GetCurrentStyle()->m_StepsType, cd ) )
break; break;
} }
@@ -1696,12 +1697,12 @@ Difficulty GameState::GetEasiestStepsDifficulty() const
Difficulty dc = DIFFICULTY_INVALID; Difficulty dc = DIFFICULTY_INVALID;
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
if( this->m_pCurSteps[p] == NULL ) if( m_pCurSteps[p] == NULL )
{ {
LOG->Warn( "GetEasiestNotesDifficulty called but p%i hasn't chosen notes", p+1 ); LOG->Warn( "GetEasiestNotesDifficulty called but p%i hasn't chosen notes", p+1 );
continue; continue;
} }
dc = min( dc, this->m_pCurSteps[p]->GetDifficulty() ); dc = min( dc, m_pCurSteps[p]->GetDifficulty() );
} }
return dc; return dc;
} }
@@ -1711,7 +1712,7 @@ bool GameState::IsEventMode() const
return m_bTemporaryEventMode || PREFSMAN->m_bEventMode; return m_bTemporaryEventMode || PREFSMAN->m_bEventMode;
} }
CoinMode GameState::GetCoinMode() CoinMode GameState::GetCoinMode() const
{ {
if( IsEventMode() && PREFSMAN->m_CoinMode == COIN_MODE_PAY ) if( IsEventMode() && PREFSMAN->m_CoinMode == COIN_MODE_PAY )
return COIN_MODE_FREE; return COIN_MODE_FREE;
@@ -1719,7 +1720,7 @@ CoinMode GameState::GetCoinMode()
return PREFSMAN->m_CoinMode; return PREFSMAN->m_CoinMode;
} }
Premium GameState::GetPremium() Premium GameState::GetPremium() const
{ {
if( IsEventMode() ) if( IsEventMode() )
return PREMIUM_NONE; return PREMIUM_NONE;
@@ -1729,7 +1730,7 @@ Premium GameState::GetPremium()
bool GameState::IsPlayerInDanger( const PlayerState *pPlayerState ) const bool GameState::IsPlayerInDanger( const PlayerState *pPlayerState ) const
{ {
if( GAMESTATE->GetPlayerFailType(pPlayerState) == SongOptions::FAIL_OFF ) if( GetPlayerFailType(pPlayerState) == SongOptions::FAIL_OFF )
return false; return false;
if( !PREFSMAN->m_bShowDanger ) if( !PREFSMAN->m_bShowDanger )
return false; return false;
@@ -1738,7 +1739,7 @@ bool GameState::IsPlayerInDanger( const PlayerState *pPlayerState ) const
bool GameState::IsPlayerDead( const PlayerState *pPlayerState ) const bool GameState::IsPlayerDead( const PlayerState *pPlayerState ) const
{ {
if( GAMESTATE->GetPlayerFailType(pPlayerState) == SongOptions::FAIL_OFF ) if( GetPlayerFailType(pPlayerState) == SongOptions::FAIL_OFF )
return false; return false;
return pPlayerState->m_HealthState == PlayerState::DEAD; return pPlayerState->m_HealthState == PlayerState::DEAD;
} }
@@ -1776,12 +1777,12 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn )
bool GameState::PlayerIsUsingModifier( PlayerNumber pn, const RString &sModifier ) bool GameState::PlayerIsUsingModifier( PlayerNumber pn, const RString &sModifier )
{ {
PlayerOptions po = GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetCurrent(); PlayerOptions po = m_pPlayerState[pn]->m_PlayerOptions.GetCurrent();
SongOptions so = GAMESTATE->m_SongOptions.GetCurrent(); SongOptions so = m_SongOptions.GetCurrent();
po.FromString( sModifier ); po.FromString( sModifier );
so.FromString( sModifier ); so.FromString( sModifier );
return po == GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.GetCurrent() && so == GAMESTATE->m_SongOptions.GetCurrent(); return po == m_pPlayerState[pn]->m_PlayerOptions.GetCurrent() && so == m_SongOptions.GetCurrent();
} }
Profile* GameState::GetEditLocalProfile() Profile* GameState::GetEditLocalProfile()