Use one ScoreKeeper per Player (as is normal) but share master player's NoteData with the other Players. Note that this means that multiple Players may be updating the same NoteData. This should not matter as the Player should only deal with notes it owns.

This commit is contained in:
Steve Checkoway
2006-07-17 01:02:31 +00:00
parent 8ab760a346
commit 58847ff1b9
+8 -6
View File
@@ -14,16 +14,18 @@ void ScreenGameplayShared::FillPlayerInfo( vector<PlayerInfo> &vPlayerInfoOut )
{ {
PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber;
vPlayerInfoOut.resize( NUM_PLAYERS ); vPlayerInfoOut.resize( NUM_PLAYERS );
PlayerInfo &mpi = vPlayerInfoOut[mpn];
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
{ {
PlayerInfo &pi = vPlayerInfoOut[pn]; PlayerInfo &pi = vPlayerInfoOut[pn];
pi.m_pn = pn; pi.m_pn = pn;
PlayerState *pPlayerState = pi.GetPlayerState();
PlayerStageStats *pPlayerStageStats = pi.GetPlayerStageStats();
pi.m_pPrimaryScoreDisplay = new ScoreDisplayNormal; pi.m_pPrimaryScoreDisplay = new ScoreDisplayNormal;
pi.m_pPrimaryScoreDisplay->Init( pi.GetPlayerState(), pi.GetPlayerStageStats() ); pi.m_pPrimaryScoreDisplay->Init( pPlayerState, pPlayerStageStats );
if( pn == mpn ) pi.m_pPrimaryScoreKeeper = new ScoreKeeperShared( pPlayerState, pPlayerStageStats );
pi.m_pPrimaryScoreKeeper = new ScoreKeeperShared; pi.m_pPlayer = new Player( mpi.m_NoteData, pn == mpn, pn == mpn );
pi.m_pPlayer = new Player( pn == mpn, pn == mpn );
} }
} }
@@ -38,7 +40,7 @@ void ScreenGameplayShared::SaveStats()
PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber;
float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds; float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds;
NoteDataUtil::SplitCompositeNoteData( m_vPlayerInfo[mpn].m_pPlayer->m_NoteData, vParts ); NoteDataUtil::SplitCompositeNoteData( m_vPlayerInfo[mpn].m_pPlayer->GetNoteData(), vParts );
for( size_t i = 0; i < min(vParts.size(), m_vPlayerInfo.size()); ++i ) for( size_t i = 0; i < min(vParts.size(), m_vPlayerInfo.size()); ++i )
{ {
PlayerInfo &pi = m_vPlayerInfo[i]; PlayerInfo &pi = m_vPlayerInfo[i];