Use a PlayerStageStats rather than indexing into STATSMAN with a PlayerNumber.
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "NoteDataWithScoring.h"
|
#include "NoteDataWithScoring.h"
|
||||||
#include "NoteData.h"
|
#include "NoteData.h"
|
||||||
#include "StageStats.h"
|
#include "PlayerStageStats.h"
|
||||||
#include "StatsManager.h"
|
|
||||||
#include <float.h>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@@ -193,7 +191,7 @@ bool NoteDataWithScoring::IsRowCompletelyJudged( const NoteData &in, unsigned ro
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
/* Return the ratio of actual to possible Bs. */
|
/* 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();
|
int iTotalSteps = in.GetNumTapNotes();
|
||||||
if( iTotalSteps == 0 )
|
if( iTotalSteps == 0 )
|
||||||
@@ -204,19 +202,19 @@ float GetActualStreamRadarValue( const NoteData &in, float fSongSeconds, PlayerN
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return the ratio of actual combo to max combo. */
|
/* 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
|
/* 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
|
* 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
|
* 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. */
|
* 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();
|
const PlayerStageStats::Combo_t MaxCombo = pss.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 );
|
float fComboPercent = SCALE( MaxCombo.fSizeSeconds, 0, pss.fLastSecond-pss.fFirstSecond, 0.0f, 1.0f );
|
||||||
return clamp( fComboPercent, 0.0f, 1.0f );
|
return clamp( fComboPercent, 0.0f, 1.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the ratio of actual to possible W2s on jumps. */
|
/* 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();
|
const int iTotalDoubles = in.GetNumJumps();
|
||||||
if( iTotalDoubles == 0 )
|
if( iTotalDoubles == 0 )
|
||||||
@@ -228,18 +226,18 @@ float GetActualAirRadarValue( const NoteData &in, float fSongSeconds, PlayerNumb
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Return the ratio of actual to possible dance points. */
|
/* 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 )
|
if ( iPossibleDP == 0 )
|
||||||
return 1;
|
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 clamp( float(ActualDP)/iPossibleDP, 0.0f, 1.0f );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the ratio of actual to possible successful holds. */
|
/* 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
|
// number of hold steps
|
||||||
const int iTotalHolds = in.GetNumHoldNotes();
|
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
|
// The for loop and the assert are used to ensure that all fields of
|
||||||
// RadarValue get set in here.
|
// RadarValue get set in here.
|
||||||
@@ -263,11 +261,11 @@ void NoteDataWithScoring::GetActualRadarValues( const NoteData &in, PlayerNumber
|
|||||||
{
|
{
|
||||||
switch( rc )
|
switch( rc )
|
||||||
{
|
{
|
||||||
case RadarCategory_Stream: out[rc] = GetActualStreamRadarValue( in, fSongSeconds, pn ); break;
|
case RadarCategory_Stream: out[rc] = GetActualStreamRadarValue( in, fSongSeconds ); break;
|
||||||
case RadarCategory_Voltage: out[rc] = GetActualVoltageRadarValue( in, fSongSeconds, pn ); break;
|
case RadarCategory_Voltage: out[rc] = GetActualVoltageRadarValue( in, fSongSeconds, pss ); break;
|
||||||
case RadarCategory_Air: out[rc] = GetActualAirRadarValue( in, fSongSeconds, pn ); break;
|
case RadarCategory_Air: out[rc] = GetActualAirRadarValue( in, fSongSeconds ); break;
|
||||||
case RadarCategory_Freeze: out[rc] = GetActualFreezeRadarValue( in, fSongSeconds, pn ); break;
|
case RadarCategory_Freeze: out[rc] = GetActualFreezeRadarValue( in, fSongSeconds ); break;
|
||||||
case RadarCategory_Chaos: out[rc] = GetActualChaosRadarValue( in, fSongSeconds, pn ); 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_TapsAndHolds: out[rc] = (float) GetNumNWithScore( in, TNS_W4, 1 ); break;
|
||||||
case RadarCategory_Jumps: out[rc] = (float) GetNumNWithScore( in, TNS_W4, 2 ); 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;
|
case RadarCategory_Holds: out[rc] = (float) GetNumHoldNotesWithScore( in, TapNote::hold_head_hold, HNS_Held ); break;
|
||||||
|
|||||||
@@ -3,20 +3,18 @@
|
|||||||
#ifndef NOTEDATAWITHSCORING_H
|
#ifndef NOTEDATAWITHSCORING_H
|
||||||
#define NOTEDATAWITHSCORING_H
|
#define NOTEDATAWITHSCORING_H
|
||||||
|
|
||||||
#include "GameConstantsAndTypes.h"
|
|
||||||
#include "PlayerNumber.h"
|
|
||||||
#include "NoteTypes.h"
|
#include "NoteTypes.h"
|
||||||
#include <map>
|
|
||||||
|
|
||||||
struct RadarValues;
|
struct RadarValues;
|
||||||
class NoteData;
|
class NoteData;
|
||||||
|
class PlayerStageStats;
|
||||||
namespace NoteDataWithScoring
|
namespace NoteDataWithScoring
|
||||||
{
|
{
|
||||||
bool IsRowCompletelyJudged( const NoteData &in, unsigned iRow );
|
bool IsRowCompletelyJudged( const NoteData &in, unsigned iRow );
|
||||||
TapNoteScore MinTapNoteScore( const NoteData &in, unsigned iRow );
|
TapNoteScore MinTapNoteScore( const NoteData &in, unsigned iRow );
|
||||||
TapNoteResult LastTapNoteResult( 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
|
#endif
|
||||||
|
|||||||
@@ -2223,18 +2223,20 @@ void ScreenGameplay::Input( const InputEventPlus &input )
|
|||||||
*/
|
*/
|
||||||
void ScreenGameplay::SongFinished()
|
void ScreenGameplay::SongFinished()
|
||||||
{
|
{
|
||||||
|
float fMusicLen = GAMESTATE->m_pCurSong->m_fMusicLengthSeconds;
|
||||||
// save any statistics
|
// save any statistics
|
||||||
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
|
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
|
||||||
{
|
{
|
||||||
/* Note that adding stats is only meaningful for the counters (eg. RadarCategory_Jumps),
|
/* Note that adding stats is only meaningful for the counters (eg. RadarCategory_Jumps),
|
||||||
* not for the percentages (RadarCategory_Air). */
|
* 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 );
|
NoteDataUtil::CalculateRadarValues( pi->m_pPlayer->m_NoteData, fMusicLen, rv );
|
||||||
pi->GetPlayerStageStats()->radarPossible += v;
|
pss.radarPossible += rv;
|
||||||
|
|
||||||
NoteDataWithScoring::GetActualRadarValues( pi->m_pPlayer->m_NoteData, pi->m_pn, GAMESTATE->m_pCurSong->m_fMusicLengthSeconds, v );
|
NoteDataWithScoring::GetActualRadarValues( pi->m_pPlayer->m_NoteData, pss, fMusicLen, rv );
|
||||||
pi->GetPlayerStageStats()->radarActual += v;
|
pss.radarActual += rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extremely important: if we don't remove attacks before moving on to the next
|
/* Extremely important: if we don't remove attacks before moving on to the next
|
||||||
|
|||||||
Reference in New Issue
Block a user