#include "global.h" /* ----------------------------------------------------------------------------- Class: NoteDataWithScoring Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford ----------------------------------------------------------------------------- */ #include "NoteDataWithScoring.h" #include "GameState.h" #include "RageUtil.h" NoteDataWithScoring::NoteDataWithScoring() { Init(); } void NoteDataWithScoring::Init() { NoteData::Init(); for( int t=0; tGetTapNote(t, i) != TAP_EMPTY && GetTapNoteScore(t, i) == tns ) iNumSuccessfulTapNotes++; } } return iNumSuccessfulTapNotes; } int NoteDataWithScoring::GetNumDoublesWithScore( TapNoteScore tns, const float fStartBeat, float fEndBeat ) const { int iNumSuccessfulDoubles = 0; if(fEndBeat == -1) fEndBeat = GetMaxBeat()+1; unsigned iStartIndex = BeatToNoteRow( fStartBeat ); unsigned iEndIndex = BeatToNoteRow( fEndBeat ); for( unsigned i=iStartIndex; i= 2 && minTapNoteScore == tns ) iNumSuccessfulDoubles++; } return iNumSuccessfulDoubles; } int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const float fStartBeat, float fEndBeat ) const { int iNumSuccessfulHolds = 0; if(fEndBeat == -1) fEndBeat = GetMaxBeat()+1; for( int i=0; i= TNS_MISS; } /* Return the last tap score of a row: the grade of the tap that completed * the row. If the row has no tap notes, return -1. If any tap notes aren't * graded (any tap is TNS_NONE) or are missed (TNS_MISS), return it. */ int NoteDataWithScoring::LastTapNoteScoreTrack(unsigned row) const { float scoretime = -9999; int best_track = -1; for( int t=0; tm_CurStageStats.GetMaxCombo( pn ); return clamp( MaxCombo.size, 0.0f, 1.0f ); } float NoteDataWithScoring::GetActualAirRadarValue( float fSongSeconds, PlayerNumber pn ) const { const int iTotalDoubles = GetNumDoubles(); if (iTotalDoubles == 0) return 1; // no jumps in song // number of doubles const int iNumDoubles = GetNumDoublesWithScore(TNS_MARVELOUS) + GetNumDoublesWithScore(TNS_PERFECT); return clamp( (float)iNumDoubles / iTotalDoubles, 0.0f, 1.0f ); } float NoteDataWithScoring::GetActualChaosRadarValue( float fSongSeconds, PlayerNumber pn ) const { const int PossibleDP = GAMESTATE->m_CurStageStats.iPossibleDancePoints[pn]; if ( PossibleDP == 0 ) return 1; const int ActualDP = GAMESTATE->m_CurStageStats.iActualDancePoints[pn]; return clamp( float(ActualDP)/PossibleDP, 0.0f, 1.0f ); } float NoteDataWithScoring::GetActualFreezeRadarValue( float fSongSeconds, PlayerNumber pn ) const { // number of hold steps const int TotalHolds = GetNumHoldNotes(); if ( TotalHolds == 0 ) return 1.0f; const int ActualHolds = GetNumHoldNotesWithScore(HNS_OK); return clamp( float(ActualHolds) / TotalHolds, 0.0f, 1.0f ); } template void extend(vector &v, T val, unsigned pos) { int needed = pos - v.size() + 1; if(needed > 0) { needed += 100; /* optimization: give it a little more than it needs */ v.insert(v.end(), needed, val); } } TapNoteScore NoteDataWithScoring::GetTapNoteScore(unsigned track, unsigned row) const { if(row >= m_TapNoteScores[track].size()) return TNS_NONE; return m_TapNoteScores[track][row]; } void NoteDataWithScoring::SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns) { extend(m_TapNoteScores[track], TNS_NONE, row); m_TapNoteScores[track][row] = tns; } float NoteDataWithScoring::GetTapNoteOffset(unsigned track, unsigned row) const { if(row >= m_TapNoteOffset[track].size()) return 0; return m_TapNoteOffset[track][row]; } void NoteDataWithScoring::SetTapNoteOffset(unsigned track, unsigned row, float offset) { extend(m_TapNoteOffset[track], 0.f, row); m_TapNoteOffset[track][row] = offset; } HoldNoteScore NoteDataWithScoring::GetHoldNoteScore(unsigned h) const { if(h >= m_HoldNoteScores.size()) return HNS_NONE; return m_HoldNoteScores[h]; } void NoteDataWithScoring::SetHoldNoteScore(unsigned h, HoldNoteScore hns) { extend(m_HoldNoteScores, HNS_NONE, h); m_HoldNoteScores[h] = hns; } void NoteDataWithScoring::SetHoldNoteLife(unsigned h, float f) { extend(m_fHoldNoteLife, 1.0f, h); m_fHoldNoteLife[h] = f; } float NoteDataWithScoring::GetHoldNoteLife(unsigned h) const { // start with full life if(h >= m_fHoldNoteLife.size()) return 1.0f; return m_fHoldNoteLife[h]; }