From 507493e92843b463a346c32ec9f942e1e39ed18c Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 18 Mar 2005 07:36:59 +0000 Subject: [PATCH] separate Load() call to give queues to ScoreKeepers (do expensive init in ctor) --- stepmania/src/ScoreKeeper.h | 7 +++++++ stepmania/src/ScoreKeeperMAX2.cpp | 22 ++++++++++++++-------- stepmania/src/ScoreKeeperMAX2.h | 10 ++++++---- stepmania/src/ScreenGameplay.cpp | 11 ++++++++--- 4 files changed, 35 insertions(+), 15 deletions(-) diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index 151d1de6f7..079b743b3a 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -12,9 +12,11 @@ */ #include "Actor.h" +#include "Attack.h" #include "GameConstantsAndTypes.h" // for TapNoteScore and HoldNoteScore class NoteData; class Inventory; +class Song; class Steps; struct PlayerState; struct PlayerStageStats; @@ -34,6 +36,11 @@ protected: public: ScoreKeeper(PlayerState* pPlayerState,PlayerStageStats* pPlayerStageStats) { m_pPlayerState=pPlayerState; m_pPlayerStageStats=pPlayerStageStats; } + virtual void Load( + const vector& apSongs, + const vector& apSteps, + const vector &asModifiers ) { } + virtual void DrawPrimitives() { } virtual void Update( float fDelta ) { } diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 814c724332..9d9e2c52f2 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -19,15 +19,21 @@ #include "song.h" ScoreKeeperMAX2::ScoreKeeperMAX2( - const vector& apSongs, - const vector& apSteps_, - const vector &asModifiers, PlayerState* pPlayerState, PlayerStageStats* pPlayerStageStats ): - ScoreKeeper(pPlayerState,pPlayerStageStats), apSteps(apSteps_) + ScoreKeeper(pPlayerState,pPlayerStageStats) { - ASSERT( apSongs.size() == apSteps_.size() ); +} + +void ScoreKeeperMAX2::Load( + const vector& apSongs, + const vector& apSteps, + const vector &asModifiers ) +{ + m_apSteps = apSteps; + ASSERT( apSongs.size() == apSteps.size() ); ASSERT( apSongs.size() == asModifiers.size() ); + // // Fill in STATSMAN->m_CurStageStats, calculate multiplier // @@ -47,7 +53,7 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const Style* pStyle = GAMESTATE->GetCurrentStyle(); NoteData nd; - pStyle->GetTransformedNoteDataForStyle( pPlayerState->m_PlayerNumber, ndTemp, nd ); + pStyle->GetTransformedNoteDataForStyle( m_pPlayerState->m_PlayerNumber, ndTemp, nd ); /* Compute RadarValues before applying any user-selected mods. Apply * Course mods and count them in the "pre" RadarValues because they're @@ -64,7 +70,7 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( * have eg. GAMESTATE->GetOptionsForCourse(po,so,pn) to get options based on * the last call to StoreSelectedOptions and the modifiers list, but that'd * mean moving the queues in ScreenGameplay to GameState ... */ - NoteDataUtil::TransformNoteData( nd, pPlayerState->m_PlayerOptions, pSteps->m_StepsType ); + NoteDataUtil::TransformNoteData( nd, m_pPlayerState->m_PlayerOptions, pSteps->m_StepsType ); RadarValues rvPost; NoteDataUtil::GetRadarValues( nd, pSong->m_fMusicLengthSeconds, rvPost ); @@ -126,7 +132,7 @@ void ScoreKeeperMAX2::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, c m_iMaxPossiblePoints = 0; if( GAMESTATE->IsCourseMode() ) { - const int numSongsInCourse = apSteps.size(); + const int numSongsInCourse = m_apSteps.size(); ASSERT( numSongsInCourse != 0 ); const int iIndex = iSongInCourseIndex % numSongsInCourse; diff --git a/stepmania/src/ScoreKeeperMAX2.h b/stepmania/src/ScoreKeeperMAX2.h index 61de4e7095..5fe1cd6591 100644 --- a/stepmania/src/ScoreKeeperMAX2.h +++ b/stepmania/src/ScoreKeeperMAX2.h @@ -21,7 +21,7 @@ class ScoreKeeperMAX2: public ScoreKeeper int m_iCurToastyCombo; bool m_bIsLastSongInCourse; - const vector& apSteps; + vector m_apSteps; void AddScore( TapNoteScore score ); @@ -32,12 +32,14 @@ class ScoreKeeperMAX2: public ScoreKeeper public: ScoreKeeperMAX2( - const vector& apSongs, - const vector& apSteps, - const vector &asModifiers, PlayerState* pPlayerState, PlayerStageStats* pPlayerStageStats ); + void Load( + const vector& apSongs, + const vector& apSteps, + const vector &asModifiers ); + // before a song plays (called multiple times if course) void OnNextSong( int iSongInCourseIndex, const Steps* pSteps, const NoteData* pNoteData ); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index a03d96ac8f..7224fb4c76 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -199,9 +199,6 @@ void ScreenGameplay::Init() case PrefsManager::SCORING_MAX2: case PrefsManager::SCORING_5TH: m_pPrimaryScoreKeeper[p] = new ScoreKeeperMAX2( - m_apSongsQueue, - m_vpStepsQueue[p], - m_asModifiersQueue[p], GAMESTATE->m_pPlayerState[p], &STATSMAN->m_CurStageStats.m_player[p] ); break; @@ -218,6 +215,14 @@ void ScreenGameplay::Init() } } + FOREACH_EnabledPlayer(pn) + { + if( m_pPrimaryScoreKeeper[pn] ) + m_pPrimaryScoreKeeper[pn]->Load( m_apSongsQueue, m_vpStepsQueue[pn], m_asModifiersQueue[pn] ); + if( m_pSecondaryScoreKeeper[pn] ) + m_pSecondaryScoreKeeper[pn]->Load( m_apSongsQueue, m_vpStepsQueue[pn], m_asModifiersQueue[pn] ); + } + m_bChangedOffsetOrBPM = GAMESTATE->m_SongOptions.m_bAutoSync; m_DancingState = STATE_INTRO;