Previously, BeginStage was called in SGameplay and FinishStage was called

in each place gameplay exits.  This incremented the stage number in SSM,
and was brittle: FinishStage was sprinkled in many odd places.  Do both
in SGameplay.

This increments the stage number as soon as gameplay ends.  This only
affects evaluation.  Use the stage number from StageStats there, instead
of the current stage, and adjust branches.  During evaluation, the
game is on the upcoming stage and displaying old data for the last
stage, instead of the stage continuing through evaluation.

This also moves a bunch of scoring-related stuff out of SEvaluation,
to the end of gameplay, where it belongs.  Eval is almost const, and things
won't break like they would before if Eval is not used.
This commit is contained in:
Glenn Maynard
2007-04-24 01:35:32 +00:00
parent 2bcd5a644f
commit 5318d0670d
8 changed files with 46 additions and 40 deletions
+4 -8
View File
@@ -910,11 +910,7 @@ bool GameState::IsFinalStage() const
if( IsCourseMode() )
return true;
/* This changes dynamically on ScreenSelectMusic as the wheel turns. */
int iPredictedStageForCurSong = GetNumStagesForCurrentSongAndStepsOrCourse();
if( iPredictedStageForCurSong == -1 )
iPredictedStageForCurSong = 1;
return GetLargestCurrentStageIndexForAnyHumanPlayer() + iPredictedStageForCurSong == PREFSMAN->m_iSongsPerPlay;
return GetLargestCurrentStageIndexForAnyHumanPlayer() == PREFSMAN->m_iSongsPerPlay - 1;
}
bool GameState::IsAnExtraStage() const
@@ -1202,8 +1198,8 @@ bool GameState::HasEarnedExtraStage() const
m_pCurSteps[pn]->GetDifficulty() != Difficulty_Challenge )
continue; /* not hard enough! */
if( (IsFinalStage() && STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_1) ||
(IsExtraStage() && STATSMAN->m_CurStageStats.m_player[pn].GetGrade() <= GRADE_TIER_FOR_EXTRA_2) )
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) )
{
bOnePassed = true;
break;
@@ -1214,7 +1210,7 @@ bool GameState::HasEarnedExtraStage() const
return false;
/* If PickExtraStage, allow EX2 if the chosen song was correct. */
if( PREFSMAN->m_bPickExtraStage && IsExtraStage() )
if( PREFSMAN->m_bPickExtraStage && IsExtraStage2() )
{
Song* pSong;
Steps* pSteps;
-2
View File
@@ -34,8 +34,6 @@ void ScreenContinue::Init()
void ScreenContinue::BeginScreen()
{
GAMESTATE->FinishStage();
GAMESTATE->SetCurrentStyle( NULL );
// unjoin all players with 0 stages left
-4
View File
@@ -76,10 +76,6 @@ ScreenEnding::ScreenEnding() : ScreenAttract( false/*dont reset GAMESTATE*/ )
STATSMAN->m_vPlayedStageStats.clear();
}
// Update final profile stats before we load them for display.
GAMESTATE->FinishStage();
}
void ScreenEnding::Init()
+24 -12
View File
@@ -180,11 +180,7 @@ void ScreenEvaluation::Init()
{
LOG->Trace( "ScreenEvaluation::Init()" );
/* Commit stats to the profile, so any profile stats displayed on this screen
* include the last game. */
GAMESTATE->CommitStageStats();
m_pStageStats = &STATSMAN->m_CurStageStats;
m_pStageStats = &STATSMAN->m_vPlayedStageStats.back();
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
ZERO( m_bSavedScreenshot );
@@ -195,10 +191,12 @@ void ScreenEvaluation::Init()
//
// Figure out which statistics and songs we're going to display
//
STATSMAN->CalcAccumPlayedStageStats();
if( SUMMARY )
STATSMAN->GetFinalEvalStageStats( STATSMAN->m_CurStageStats );
{
STATSMAN->GetFinalEvalStageStats( m_FinalEvalStageStats );
m_pStageStats = &m_FinalEvalStageStats;
}
m_bFailed = m_pStageStats->AllFailed();
@@ -234,11 +232,8 @@ void ScreenEvaluation::Init()
//
// update persistent statistics
//
// XXX
m_pStageStats->CommitScores( SUMMARY );
FOREACH_HumanPlayer( p )
m_pStageStats->m_player[p].CalcAwards( p, m_pStageStats->m_bGaveUp, m_pStageStats->m_bUsedAutoplay );
if( SUMMARY )
m_pStageStats->CommitScores( true );
// Run this here, so STATSMAN->m_CurStageStats is available to overlays.
ScreenWithMenuElements::Init();
@@ -820,6 +815,23 @@ void ScreenEvaluation::HandleMenuStart()
StartTransitioningScreen( SM_GoToNextScreen );
}
// lua start
#include "LuaBinding.h"
class LunaScreenEvaluation: public Luna<ScreenEvaluation>
{
public:
static int GetStageStats( T* p, lua_State *L ) { LuaHelpers::Push( L, p->GetStageStats() ); return 1; }
LunaScreenEvaluation()
{
ADD_METHOD( GetStageStats );
}
};
LUA_REGISTER_DERIVED_CLASS( ScreenEvaluation, ScreenWithMenuElements )
// lua end
/*
* (c) 2001-2004 Chris Danford
* All rights reserved.
+3
View File
@@ -46,6 +46,8 @@ public:
virtual void MenuBack( const InputEventPlus &input );
virtual void MenuStart( const InputEventPlus &input );
virtual void PushSelf( lua_State *L );
StageStats *GetStageStats() { return m_pStageStats; }
protected:
virtual bool GenericTweenOn() const { return true; }
@@ -55,6 +57,7 @@ protected:
bool m_bSummary;
StageStats *m_pStageStats;
StageStats m_FinalEvalStageStats;
// banner area
Banner m_LargeBanner;
+15 -8
View File
@@ -385,10 +385,6 @@ void ScreenGameplay::Init()
GAMESTATE->SaveCurrentSettingsToProfile(pn);
}
/* Finish the last stage, if we havn't already. (For example, we might have
* gone from gameplay to evaluation back to gameplay.) */
GAMESTATE->FinishStage();
/* Called once per stage (single song or single course). */
GAMESTATE->BeginStage();
@@ -2240,9 +2236,22 @@ void ScreenGameplay::StageFinished( bool bBackedOut )
}
}
if( bBackedOut )
{
GAMESTATE->CancelStage();
return;
}
// save current stage stats
if( !bBackedOut )
STATSMAN->m_vPlayedStageStats.push_back( STATSMAN->m_CurStageStats );
STATSMAN->m_vPlayedStageStats.push_back( STATSMAN->m_CurStageStats );
GAMESTATE->CommitStageStats();
STATSMAN->m_CurStageStats.CommitScores( false );
FOREACH_HumanPlayer( pn )
STATSMAN->m_CurStageStats.m_player[pn].CalcAwards( pn, STATSMAN->m_CurStageStats.m_bGaveUp, STATSMAN->m_CurStageStats.m_bUsedAutoplay );
STATSMAN->CalcAccumPlayedStageStats();
GAMESTATE->FinishStage();
}
void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
@@ -2442,8 +2451,6 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
SongFinished();
StageFinished( true );
GAMESTATE->CancelStage();
m_sNextScreen = GetPrevScreen();
if( AdjustSync::IsSyncDataChanged() )
@@ -73,8 +73,6 @@ void ScreenNameEntryTraditional::Init()
void ScreenNameEntryTraditional::BeginScreen()
{
GAMESTATE->FinishStage();
/* Find out if players are entering their name. */
FOREACH_PlayerNumber( pn )
{
-4
View File
@@ -174,10 +174,6 @@ void ScreenSelectMusic::Init()
void ScreenSelectMusic::BeginScreen()
{
/* Finish any previous stage. It's OK to call this when we havn't played a stage yet.
* Do this before anything that might look at GAMESTATE->m_iCurrentStageIndex or GAMESTATE->m_iPlayerCurrentStageIndexForCurrentCredit. */
GAMESTATE->FinishStage();
LIGHTSMAN->SetLightsMode( LIGHTSMODE_MENU );
if( CommonMetrics::AUTO_SET_STYLE )