continue merging NoteDataWithScoring stuff

This commit is contained in:
Glenn Maynard
2005-01-22 02:10:54 +00:00
parent c321bbe196
commit 46ace22b79
4 changed files with 38 additions and 65 deletions
+16 -44
View File
@@ -12,9 +12,6 @@ NoteDataWithScoring::NoteDataWithScoring()
void NoteDataWithScoring::Init()
{
NoteData::Init();
for( int t=0; t<MAX_NOTE_TRACKS; t++ )
m_TapNoteScores[t].clear();
}
int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float fStartBeat, float fEndBeat ) const
@@ -32,7 +29,8 @@ int NoteDataWithScoring::GetNumTapNotesWithScore( TapNoteScore tns, const float
{
FOREACH_NONEMPTY_ROW_IN_TRACK_RANGE( *this, t, r, iStartIndex, iEndIndex )
{
if( GetTapNoteScore(t, r) >= tns )
const TapNote &tn = GetTapNote(t, r);
if( tn.result.tns >= tns )
iNumSuccessfulTapNotes++;
}
}
@@ -58,12 +56,13 @@ int NoteDataWithScoring::GetNumNWithScore( TapNoteScore tns, int MinTaps, const
TapNoteScore minTapNoteScore = TNS_MARVELOUS;
for( int t=0; t<GetNumTracks(); t++ )
{
switch( GetTapNote(t, i).type )
const TapNote &tn = GetTapNote(t,i);
switch( tn.type )
{
case TapNote::tap:
case TapNote::hold_head:
iNumNotesThisIndex++;
minTapNoteScore = min( minTapNoteScore, GetTapNoteScore(t, i) );
minTapNoteScore = min( minTapNoteScore, tn.result.tns );
}
}
if( iNumNotesThisIndex >= MinTaps && minTapNoteScore >= tns )
@@ -110,7 +109,8 @@ int NoteDataWithScoring::GetSuccessfulMines( float fStartBeat, float fEndBeat )
{
for( int t=0; t<GetNumTracks(); t++ )
{
if( this->GetTapNote(t,i).type == TapNote::mine && GetTapNoteScore(t, i) != TNS_HIT_MINE )
const TapNote &tn = GetTapNote(t,i);
if( tn.type == TapNote::mine && tn.result.tns != TNS_HIT_MINE )
iNumSuccessfulMinesNotes++;
}
}
@@ -145,7 +145,7 @@ int NoteDataWithScoring::GetSuccessfulHands( float fStartBeat, float fEndBeat )
continue;
if( tn.type == TapNote::mine ) // mines don't count
continue;
if( GetTapNoteScore(t, i) <= TNS_BOO )
if( tn.result.tns <= TNS_BOO )
Missed = true;
}
@@ -186,10 +186,10 @@ TapNoteScore NoteDataWithScoring::MinTapNoteScore(unsigned row) const
{
/* Don't coun, or else the score
* will always be TNS_NONE. */
TapNote tn = GetTapNote(t, row);
const TapNote &tn = GetTapNote(t, row);
if( tn.type == TapNote::empty || tn.type == TapNote::mine)
continue;
score = min( score, GetTapNoteScore(t, row) );
score = min( score, tn.result.tns );
}
return score;
@@ -203,6 +203,7 @@ bool NoteDataWithScoring::IsRowCompletelyJudged(unsigned row) const
/* 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. */
/* XXX: this will fill in many empty tap notes due to excess GetTapnote calls */
int NoteDataWithScoring::LastTapNoteScoreTrack(unsigned row) const
{
float scoretime = -9999;
@@ -210,16 +211,17 @@ int NoteDataWithScoring::LastTapNoteScoreTrack(unsigned row) const
for( int t=0; t<GetNumTracks(); t++ )
{
/* Skip empty tracks and mines */
TapNote tn = GetTapNote(t, row);
const TapNote &tn = GetTapNote(t, row);
if( tn.type == TapNote::empty || tn.type == TapNote::mine )
continue;
TapNoteScore tns = GetTapNoteScore(t, row);
TapNoteScore tns = tn.result.tns;
if( tns == TNS_MISS || tns == TNS_NONE )
return t;
float tm = GetTapNoteOffset(t, row);
float tm = tn.result.fTapNoteOffset;
if(tm < scoretime) continue;
scoretime = tm;
@@ -233,7 +235,7 @@ TapNoteScore NoteDataWithScoring::LastTapNoteScore(unsigned row) const
{
int track = LastTapNoteScoreTrack(row);
if(track == -1) return TNS_NONE;
return GetTapNoteScore(track, row);
return GetTapNote(track, row).result.tns;
}
/* From aaroninjapan.com (http://www.aaroninjapan.com/ddr2.html)
@@ -335,36 +337,6 @@ void extend(vector<T> &v, T val, unsigned pos)
}
}
TapNoteScore NoteDataWithScoring::GetTapNoteScore(unsigned track, unsigned row) const
{
if(row >= m_TapNoteScores[track].size())
return TNS_NONE;
return m_TapNoteScores[track][row].tns;
}
void NoteDataWithScoring::SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns)
{
extend(m_TapNoteScores[track], TapNoteResult(), row);
TapNoteResult tnr = m_TapNoteScores[track][row];
tnr.tns = tns;
m_TapNoteScores[track][row] = tnr;
}
float NoteDataWithScoring::GetTapNoteOffset(unsigned track, unsigned row) const
{
if(row >= m_TapNoteScores[track].size())
return 0;
return m_TapNoteScores[track][row].fTapNoteOffset;
}
void NoteDataWithScoring::SetTapNoteOffset(unsigned track, unsigned row, float offset)
{
extend(m_TapNoteScores[track], TapNoteResult(), row);
TapNoteResult tnr = m_TapNoteScores[track][row];
tnr.fTapNoteOffset = offset;
m_TapNoteScores[track][row] = tnr;
}
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved.
+2 -8
View File
@@ -17,9 +17,6 @@ struct RowTrack: public pair<int,int>
class NoteDataWithScoring : public NoteData
{
// maintain this extra data in addition to the NoteData
vector<TapNoteResult> m_TapNoteScores[MAX_NOTE_TRACKS];
public:
NoteDataWithScoring();
void Init();
@@ -30,19 +27,16 @@ public:
int GetNumHoldNotesWithScore( HoldNoteScore hns, const float fStartBeat = 0, const float fEndBeat = -1 ) const;
int GetSuccessfulMines( const float fStartBeat = 0, const float fEndBeat = -1 ) const;
int GetSuccessfulHands( const float fStartBeat = 0, const float fEndBeat = -1 ) const;
TapNoteScore GetTapNoteScore(unsigned track, unsigned row) const;
void SetTapNoteScore(unsigned track, unsigned row, TapNoteScore tns);
float GetTapNoteOffset(unsigned track, unsigned row) const;
void SetTapNoteOffset(unsigned track, unsigned row, float offset);
bool IsRowCompletelyJudged(unsigned row) const;
TapNoteScore MinTapNoteScore(unsigned row) const;
int LastTapNoteScoreTrack(unsigned row) const;
TapNoteScore LastTapNoteScore(unsigned row) const;
void GetActualRadarValues( PlayerNumber pn, float fSongSeconds, RadarValues& out ) const;
private:
int LastTapNoteScoreTrack(unsigned row) const;
float GetActualStreamRadarValue( float fSongSeconds, PlayerNumber pn ) const;
float GetActualVoltageRadarValue( float fSongSeconds, PlayerNumber pn ) const;
float GetActualAirRadarValue( float fSongSeconds, PlayerNumber pn ) const;
+1 -1
View File
@@ -111,7 +111,7 @@ struct TapNote
/* This data is only used and manipulated by NoteDataWithScoring. It's only in
* here for the sake of efficiency. */
TapNoteResult result;
};
const unsigned MAX_NUM_ATTACKS = 2*2*2; // 3 bits to hold the attack index currently
+19 -12
View File
@@ -371,7 +371,7 @@ void Player::Update( float fDeltaTime )
const GameInput GameI = GAMESTATE->GetCurrentStyle()->StyleInputToGameInput( StyleI );
// if they got a bad score or haven't stepped on the corresponding tap yet
const TapNoteScore tns = m_NoteData.GetTapNoteScore( hn.iTrack, hn.iStartRow );
const TapNoteScore tns = m_NoteData.GetTapNote( hn.iTrack, hn.iStartRow ).result.tns;
const bool bSteppedOnTapNote = tns != TNS_NONE && tns != TNS_MISS; // did they step on the start of this hold?
float fLife = hn.result.fLife;
@@ -641,9 +641,10 @@ int Player::GetClosestNoteDirectional( int col, int iStartRow, int iMaxRowsAhead
/* Is iRow the row we want? */
do
{
if( m_NoteData.GetTapNote(col, iRow).type == TapNote::empty )
TapNote tn = m_NoteData.GetTapNote(col, iRow);
if( tn.type == TapNote::empty )
break;
if( !bAllowGraded && m_NoteData.GetTapNoteScore(col, iRow) != TNS_NONE )
if( !bAllowGraded && tn.result.tns != TNS_NONE )
break;
return iRow;
} while(0);
@@ -947,10 +948,12 @@ void Player::Step( int col, RageTimer tm )
score, col, fStepSeconds, fCurrentMusicSeconds, fMusicSeconds, fNoteOffset );
// LOG->Trace("Note offset: %f (fSecondsFromPerfect = %f), Score: %i", fNoteOffset, fSecondsFromPerfect, score);
m_NoteData.SetTapNoteScore(col, iIndexOverlappingNote, score);
tn.result.tns = score;
if( score != TNS_NONE )
m_NoteData.SetTapNoteOffset(col, iIndexOverlappingNote, -fNoteOffset);
tn.result.fTapNoteOffset = -fNoteOffset;
m_NoteData.SetTapNote( col, iIndexOverlappingNote, tn );
if( m_pPlayerState->m_PlayerController == PC_HUMAN &&
score >= TNS_GREAT )
@@ -1129,19 +1132,23 @@ void Player::UpdateTapNotesMissedOlderThan( float fMissIfOlderThanSeconds )
{
/* XXX: cleaner to pick the things we do want to apply misses to, instead of
* the things we don't? */
switch( m_NoteData.GetTapNote(t, r).type )
TapNote tn = m_NoteData.GetTapNote(t, r);
switch( tn.type )
{
case TapNote::empty:
case TapNote::attack:
case TapNote::mine:
continue; /* no note here */
}
if( m_NoteData.GetTapNoteScore(t, r) != TNS_NONE ) /* note here is already hit */
if( tn.result.tns != TNS_NONE ) /* note here is already hit */
continue;
tn.result.tns = TNS_MISS;
// A normal note. Penalize for not stepping on it.
MissedNoteOnThisRow = true;
m_NoteData.SetTapNoteScore( t, r, TNS_MISS );
m_NoteData.SetTapNote( t, r, tn );
if( m_pPlayerStageStats )
{
@@ -1174,9 +1181,9 @@ void Player::CrossedRow( int iNoteRow )
{
for( int t=0; t<m_NoteData.GetNumTracks(); t++ )
{
if( m_NoteData.GetTapNote(t, iNoteRow).type != TapNote::empty )
if( m_NoteData.GetTapNoteScore(t, iNoteRow) == TNS_NONE )
Step( t, now );
TapNote tn = m_NoteData.GetTapNote(t, iNoteRow);
if( tn.type != TapNote::empty && tn.result.tns == TNS_NONE )
Step( t, now );
}
}
}