From 81046111f42604b84cb06e839324c87fc794d00e Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Mon, 10 Jul 2006 05:18:35 +0000 Subject: [PATCH] Implement SaveStats and direct all input to the master player. --- stepmania/src/ScreenGameplayShared.cpp | 57 +++++++++++++++----------- stepmania/src/ScreenGameplayShared.h | 1 + 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/stepmania/src/ScreenGameplayShared.cpp b/stepmania/src/ScreenGameplayShared.cpp index b45b5cbdd3..5dc11d5e9e 100644 --- a/stepmania/src/ScreenGameplayShared.cpp +++ b/stepmania/src/ScreenGameplayShared.cpp @@ -2,44 +2,51 @@ #include "ScreenGameplayShared.h" #include "GameState.h" #include "Player.h" +#include "NoteDataUtil.h" +#include "NoteDataWithScoring.h" +#include "ActiveAttackList.h" REGISTER_SCREEN_CLASS( ScreenGameplayShared ); void ScreenGameplayShared::FillPlayerInfo( vector &vPlayerInfoOut ) { - //PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; - + PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; vPlayerInfoOut.resize( NUM_PLAYERS ); FOREACH_PlayerNumber( pn ) - vPlayerInfoOut[pn].Load( pn, MultiPlayer_INVALID, true ); + vPlayerInfoOut[pn].Load( pn, MultiPlayer_INVALID, pn == mpn ); } PlayerInfo &ScreenGameplayShared::GetPlayerInfoForInput( const InputEventPlus& iep ) { -#if 0 - const float fPositionSeconds = GAMESTATE->m_fMusicSeconds - iep.DeviceI.ts.Ago(); - const float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds ); - const int row = BeatToNoteRow( fSongBeat ); - const int col = iep.StyleI.col; - int distance = INT_MAX; - size_t index = 0; - - for( size_t i = 0; i < m_vPlayerInfo.size(); ++i ) - { - if( !m_vPlayerInfo[i].IsEnabled() ) - continue; - int d = m_vPlayerInfo[i].m_pPlayer->GetClosestNoteDistance( col, row ); - if( d == -1 || d >= distance) - continue; - distance = d; - index = i; - } - return m_vPlayerInfo[index]; -#else - return ScreenGameplay::GetPlayerInfoForInput( iep ); -#endif + return m_vPlayerInfo[GAMESTATE->m_MasterPlayerNumber]; } +void ScreenGameplayShared::SaveStats() +{ + vector vParts; + PlayerNumber mpn = GAMESTATE->m_MasterPlayerNumber; + float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds; + + NoteDataUtil::SplitCompositeNoteData( m_vPlayerInfo[mpn].m_pPlayer->m_NoteData, vParts ); + for( size_t i = 0; i < min(vParts.size(), m_vPlayerInfo.size()); ++i ) + { + PlayerInfo &pi = m_vPlayerInfo[i]; + + if( !pi.IsEnabled() ) + continue; + NoteData &nd = vParts[i]; + RadarValues rv; + PlayerStageStats &pss = *pi.GetPlayerStageStats(); + + NoteDataUtil::CalculateRadarValues( nd, fMusicLen, rv ); + pss.radarPossible += rv; + + NoteDataWithScoring::GetActualRadarValues( nd, pss, fMusicLen, rv ); + pss.radarActual += rv; + } +} + + /* * (c) 2006 Steve Checkoway * All rights reserved. diff --git a/stepmania/src/ScreenGameplayShared.h b/stepmania/src/ScreenGameplayShared.h index 3d8eae6a7c..beaf3d78dd 100644 --- a/stepmania/src/ScreenGameplayShared.h +++ b/stepmania/src/ScreenGameplayShared.h @@ -8,6 +8,7 @@ class ScreenGameplayShared : public ScreenGameplay protected: virtual void FillPlayerInfo( vector &vPlayerInfoOut ); virtual PlayerInfo &GetPlayerInfoForInput( const InputEventPlus& iep ); + virtual void SaveStats(); }; #endif