#include "global.h" /* ----------------------------------------------------------------------------- Class: NoteDataWithScoring Desc: See header. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Chris Danford Glenn Maynard ----------------------------------------------------------------------------- */ #include "NoteDataWithScoring.h" #include "GameState.h" #include "RageUtil.h" #include "StageStats.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::GetNumNWithScore( TapNoteScore tns, int MinTaps, const float fStartBeat, float fEndBeat ) const { if( fEndBeat == -1 ) fEndBeat = GetMaxBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); iStartIndex = max( iStartIndex, 0 ); iEndIndex = min( iEndIndex, GetMaxRow()-1 ); int iNumSuccessfulDoubles = 0; for( int i=iStartIndex; i<=iEndIndex; i++ ) { int iNumNotesThisIndex = 0; TapNoteScore minTapNoteScore = TNS_MARVELOUS; for( int t=0; t= MinTaps && minTapNoteScore >= tns ) iNumSuccessfulDoubles++; } return iNumSuccessfulDoubles; } int NoteDataWithScoring::GetNumHoldNotesWithScore( HoldNoteScore hns, const float fStartBeat, float fEndBeat ) const { int iNumSuccessfulHolds = 0; if(fEndBeat == -1) fEndBeat = GetMaxBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); for( int i=0; i hn.iStartRow || hn.iEndRow > iEndIndex ) continue; if( GetHoldNoteScore(hn) == hns ) iNumSuccessfulHolds++; } return iNumSuccessfulHolds; } int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat ) const { if( fEndBeat == -1 ) fEndBeat = GetMaxBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); iStartIndex = max( iStartIndex, 0 ); iEndIndex = min( iEndIndex, GetMaxRow()-1 ); int iNumSuccessfulMinesNotes = 0; for( int i=iStartIndex; i<=iEndIndex; i++ ) { for( int t=0; tGetTapNote(t, i) == TAP_MINE && GetTapNoteScore(t, i) != TNS_MISS ) iNumSuccessfulMinesNotes++; } } return iNumSuccessfulMinesNotes; } /* See NoteData::GetNumHands(). */ int NoteDataWithScoring::GetSuccessfulHands( float fStartBeat, float fEndBeat ) const { if( fEndBeat == -1 ) fEndBeat = GetMaxBeat(); int iStartIndex = BeatToNoteRow( fStartBeat ); int iEndIndex = BeatToNoteRow( fEndBeat ); /* Clamp to known-good ranges. */ iStartIndex = max( iStartIndex, 0 ); iEndIndex = min( iEndIndex, GetMaxRow()-1 ); int iNum = 0; for( int i=iStartIndex; i<=iEndIndex; i++ ) { if( !RowNeedsHands(i) ) continue; bool Missed = false; for( int t=0; t= 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; t 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; } /* We use the end row to index hold notes, instead of the start row, because the start row * changes when hold notes are being stepped on, but end rows never change. */ HoldNoteScore NoteDataWithScoring::GetHoldNoteScore( const HoldNote &hn ) const { map::const_iterator it = m_HoldNoteScores.find( RowTrack(hn) ); if( it == m_HoldNoteScores.end() ) return HNS_NONE; return it->second; } void NoteDataWithScoring::SetHoldNoteScore( const HoldNote &hn, HoldNoteScore hns ) { m_HoldNoteScores[RowTrack(hn)] = hns; } void NoteDataWithScoring::SetHoldNoteLife( const HoldNote &hn, float f ) { m_fHoldNoteLife[RowTrack(hn)] = f; } float NoteDataWithScoring::GetHoldNoteLife( const HoldNote &hn ) const { map::const_iterator it = m_fHoldNoteLife.find( RowTrack(hn) ); if( it == m_fHoldNoteLife.end() ) return 1.0f; return it->second; }