Encapsulate extra stage logic. The condition of HasEarnedExtraStage() remains true (if it was earned) after the call to FinishStage() until the next BeginStage().

I still don't completely like this because after FinishStage(), if an extra stage has been earned, it is immediately in that stage which is sort of strange for SEval. Even worse, if an extra stage was earned in the past but not for the current stage, then the stage doesn't change. (E.g., earn extra stage but not second extra stage, or earn second extra stage.) So once an extra stage has been earned, SEval will be called twice for the same stage. A per-player  m_iExtraStagesPlayed could be added to fix this, but it doesn't seem worth it.
This commit is contained in:
Steve Checkoway
2007-08-11 20:43:01 +00:00
parent 62ae7f5417
commit a5b9861532
3 changed files with 21 additions and 12 deletions
+12 -6
View File
@@ -316,7 +316,7 @@ void GameState::Reset()
m_sEditLocalProfileID.Set( "" );
m_bBackedOutOfFinalStage = false;
m_bEarnedExtraStage = false;
ApplyCmdline();
}
@@ -642,6 +642,7 @@ void GameState::BeginStage()
FOREACH_HumanPlayer( pn )
if( CurrentOptionsDisqualifyPlayer(pn) )
STATSMAN->m_CurStageStats.m_player[pn].m_bDisqualified = true;
m_bEarnedExtraStage = false;
}
void GameState::CancelStage()
@@ -684,7 +685,7 @@ void GameState::FinishStage()
m_iNumStagesOfThisSong = 0;
if( HasEarnedExtraStage() )
if( HasEarnedExtraStageInternal() )
{
LOG->Trace( "awarded extra stage" );
FOREACH_HumanPlayer( p )
@@ -693,6 +694,7 @@ void GameState::FinishStage()
{
++m_iAwardedExtraStages[p];
++m_iPlayerStageTokens[p];
m_bEarnedExtraStage = true;
}
}
}
@@ -1125,9 +1127,9 @@ bool GameState::IsBattleMode() const
default:
return false;
}
}
}
bool GameState::HasEarnedExtraStage() const
bool GameState::HasEarnedExtraStageInternal() const
{
if( IsEventMode() )
return false;
@@ -1153,8 +1155,12 @@ bool GameState::HasEarnedExtraStage() const
m_pCurSteps[pn]->GetDifficulty() != Difficulty_Challenge )
continue; /* not hard enough! */
if( (IsExtraStage() && STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_1) ||
(IsExtraStage2() && STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_2) )
if( IsExtraStage() )
{
if( STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_2 )
return true;
}
else if( STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_1 )
{
return true;
}
+8 -2
View File
@@ -129,7 +129,6 @@ public:
int m_iCurrentStageIndex;
// Num stages available for player. Resets when player joins/continues.
int m_iPlayerStageTokens[NUM_PLAYERS];
int m_iAwardedExtraStages[NUM_PLAYERS];
static int GetNumStagesMultiplierForSong( const Song* pSong );
static int GetNumStagesForSongAndStyleType( const Song* pSong, StyleType st );
@@ -245,7 +244,7 @@ public:
Character* m_pCurCharacters[NUM_PLAYERS];
bool HasEarnedExtraStage() const;
bool HasEarnedExtraStage() const { return m_bEarnedExtraStage; }
//
@@ -319,6 +318,13 @@ public:
// Lua
void PushSelf( lua_State *L );
// Keep extra stage logic internal to GameState.
private:
bool HasEarnedExtraStageInternal() const;
int m_iAwardedExtraStages[NUM_PLAYERS];
bool m_bEarnedExtraStage;
};
PlayerNumber GetNextHumanPlayer( PlayerNumber pn );
+1 -4
View File
@@ -656,10 +656,7 @@ void ScreenEvaluation::Init()
FOREACH_PlayerNumber( p )
best_grade = min( best_grade, grade[p] );
if( PREFSMAN->m_bAllowExtraStage &&
GAMESTATE->IsAnExtraStage() &&
!GAMESTATE->IsCourseMode() &&
!SUMMARY )
if( !SUMMARY && GAMESTATE->HasEarnedExtraStage() )
{
m_sprTryExtraStage.Load( THEME->GetPathG(m_sName,GAMESTATE->IsExtraStage2()?"try extra2":"try extra1") );
m_sprTryExtraStage->SetName( "TryExtraStage" );