diff --git a/stepmania/src/NoteDataWithScoring.cpp b/stepmania/src/NoteDataWithScoring.cpp index 136e312560..a03bbbc4f3 100644 --- a/stepmania/src/NoteDataWithScoring.cpp +++ b/stepmania/src/NoteDataWithScoring.cpp @@ -1,9 +1,7 @@ #include "global.h" #include "NoteDataWithScoring.h" #include "NoteData.h" -#include "StageStats.h" -#include "StatsManager.h" -#include +#include "PlayerStageStats.h" namespace { @@ -193,7 +191,7 @@ bool NoteDataWithScoring::IsRowCompletelyJudged( const NoteData &in, unsigned ro namespace { /* Return the ratio of actual to possible Bs. */ -float GetActualStreamRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) +float GetActualStreamRadarValue( const NoteData &in, float fSongSeconds ) { int iTotalSteps = in.GetNumTapNotes(); if( iTotalSteps == 0 ) @@ -204,19 +202,19 @@ float GetActualStreamRadarValue( const NoteData &in, float fSongSeconds, PlayerN } /* Return the ratio of actual combo to max combo. */ -float GetActualVoltageRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) +float GetActualVoltageRadarValue( const NoteData &in, float fSongSeconds, const PlayerStageStats &pss ) { /* STATSMAN->m_CurStageStats.iMaxCombo is unrelated to GetNumTapNotes: m_bComboContinuesBetweenSongs * might be on, and the way combo is counted varies depending on the mode and score * keeper. Instead, let's use the length of the longest recorded combo. This is * only subtly different: it's the percent of the song the longest combo took to get. */ - const PlayerStageStats::Combo_t MaxCombo = STATSMAN->m_CurStageStats.m_player[pn].GetMaxCombo(); - float fComboPercent = SCALE( MaxCombo.fSizeSeconds, 0, STATSMAN->m_CurStageStats.m_player[pn].fLastSecond-STATSMAN->m_CurStageStats.m_player[pn].fFirstSecond, 0.0f, 1.0f ); + const PlayerStageStats::Combo_t MaxCombo = pss.GetMaxCombo(); + float fComboPercent = SCALE( MaxCombo.fSizeSeconds, 0, pss.fLastSecond-pss.fFirstSecond, 0.0f, 1.0f ); return clamp( fComboPercent, 0.0f, 1.0f ); } /* Return the ratio of actual to possible W2s on jumps. */ -float GetActualAirRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) +float GetActualAirRadarValue( const NoteData &in, float fSongSeconds ) { const int iTotalDoubles = in.GetNumJumps(); if( iTotalDoubles == 0 ) @@ -228,18 +226,18 @@ float GetActualAirRadarValue( const NoteData &in, float fSongSeconds, PlayerNumb } /* Return the ratio of actual to possible dance points. */ -float GetActualChaosRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) +float GetActualChaosRadarValue( const NoteData &in, float fSongSeconds, const PlayerStageStats &pss ) { - const int iPossibleDP = STATSMAN->m_CurStageStats.m_player[pn].iPossibleDancePoints; + const int iPossibleDP = pss.iPossibleDancePoints; if ( iPossibleDP == 0 ) return 1; - const int ActualDP = STATSMAN->m_CurStageStats.m_player[pn].iActualDancePoints; + const int ActualDP = pss.iActualDancePoints; return clamp( float(ActualDP)/iPossibleDP, 0.0f, 1.0f ); } /* Return the ratio of actual to possible successful holds. */ -float GetActualFreezeRadarValue( const NoteData &in, float fSongSeconds, PlayerNumber pn ) +float GetActualFreezeRadarValue( const NoteData &in, float fSongSeconds ) { // number of hold steps const int iTotalHolds = in.GetNumHoldNotes(); @@ -255,7 +253,7 @@ float GetActualFreezeRadarValue( const NoteData &in, float fSongSeconds, PlayerN } -void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, PlayerNumber pn, float fSongSeconds, RadarValues& out ) +void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, const PlayerStageStats &pss, float fSongSeconds, RadarValues& out ) { // The for loop and the assert are used to ensure that all fields of // RadarValue get set in here. @@ -263,11 +261,11 @@ void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, PlayerNumber { switch( rc ) { - case RadarCategory_Stream: out[rc] = GetActualStreamRadarValue( in, fSongSeconds, pn ); break; - case RadarCategory_Voltage: out[rc] = GetActualVoltageRadarValue( in, fSongSeconds, pn ); break; - case RadarCategory_Air: out[rc] = GetActualAirRadarValue( in, fSongSeconds, pn ); break; - case RadarCategory_Freeze: out[rc] = GetActualFreezeRadarValue( in, fSongSeconds, pn ); break; - case RadarCategory_Chaos: out[rc] = GetActualChaosRadarValue( in, fSongSeconds, pn ); break; + case RadarCategory_Stream: out[rc] = GetActualStreamRadarValue( in, fSongSeconds ); break; + case RadarCategory_Voltage: out[rc] = GetActualVoltageRadarValue( in, fSongSeconds, pss ); break; + case RadarCategory_Air: out[rc] = GetActualAirRadarValue( in, fSongSeconds ); break; + case RadarCategory_Freeze: out[rc] = GetActualFreezeRadarValue( in, fSongSeconds ); break; + case RadarCategory_Chaos: out[rc] = GetActualChaosRadarValue( in, fSongSeconds, pss ); break; case RadarCategory_TapsAndHolds: out[rc] = (float) GetNumNWithScore( in, TNS_W4, 1 ); break; case RadarCategory_Jumps: out[rc] = (float) GetNumNWithScore( in, TNS_W4, 2 ); break; case RadarCategory_Holds: out[rc] = (float) GetNumHoldNotesWithScore( in, TapNote::hold_head_hold, HNS_Held ); break; diff --git a/stepmania/src/NoteDataWithScoring.h b/stepmania/src/NoteDataWithScoring.h index 968a4eeed9..6612ddbe4e 100644 --- a/stepmania/src/NoteDataWithScoring.h +++ b/stepmania/src/NoteDataWithScoring.h @@ -3,20 +3,18 @@ #ifndef NOTEDATAWITHSCORING_H #define NOTEDATAWITHSCORING_H -#include "GameConstantsAndTypes.h" -#include "PlayerNumber.h" #include "NoteTypes.h" -#include struct RadarValues; class NoteData; +class PlayerStageStats; namespace NoteDataWithScoring { bool IsRowCompletelyJudged( const NoteData &in, unsigned iRow ); TapNoteScore MinTapNoteScore( const NoteData &in, unsigned iRow ); TapNoteResult LastTapNoteResult( const NoteData &in, unsigned iRow ); - void GetActualRadarValues( const NoteData &in, PlayerNumber pn, float fSongSeconds, RadarValues& out ); + void GetActualRadarValues( const NoteData &in, const PlayerStageStats &pss, float fSongSeconds, RadarValues& out ); }; #endif diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 80273bfc43..04b8d93cac 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2223,18 +2223,20 @@ void ScreenGameplay::Input( const InputEventPlus &input ) */ void ScreenGameplay::SongFinished() { + float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds; // save any statistics FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) { /* Note that adding stats is only meaningful for the counters (eg. RadarCategory_Jumps), * not for the percentages (RadarCategory_Air). */ - RadarValues v; + RadarValues rv; + PlayerStageStats &pss = *pi->GetPlayerStageStats(); - NoteDataUtil::CalculateRadarValues( pi->m_pPlayer->m_NoteData, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); - pi->GetPlayerStageStats()->radarPossible += v; + NoteDataUtil::CalculateRadarValues( pi->m_pPlayer->m_NoteData, fMusicLen, rv ); + pss.radarPossible += rv; - NoteDataWithScoring::GetActualRadarValues( pi->m_pPlayer->m_NoteData, pi->m_pn, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v ); - pi->GetPlayerStageStats()->radarActual += v; + NoteDataWithScoring::GetActualRadarValues( pi->m_pPlayer->m_NoteData, pss, fMusicLen, rv ); + pss.radarActual += rv; } /* Extremely important: if we don't remove attacks before moving on to the next