Files
itgmania212121/stepmania/src/NoteDataWithScoring.cpp
T

155 lines
4.0 KiB
C++
Raw Normal View History

2002-06-23 02:50:33 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
Class: NoteDataWithScoring
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "NoteDataWithScoring.h"
NoteDataWithScoring::NoteDataWithScoring()
{
Init();
}
void NoteDataWithScoring::Init()
{
for( int t=0; t<MAX_NOTE_TRACKS; t++ )
for( int i=0; i<MAX_TAP_NOTE_ROWS; i++ )
m_TapNoteScores[t][i] = TNS_NONE;
2002-07-11 19:02:26 +00:00
for( int i=0; i<MAX_HOLD_NOTES; i++ )
2002-08-01 03:15:27 +00:00
{
2002-06-23 02:50:33 +00:00
m_HoldNoteScores[i] = HNS_NONE;
2002-08-01 03:15:27 +00:00
m_fHoldNoteLife[i] = 1.0f;
}
2002-06-23 02:50:33 +00:00
}
int NoteDataWithScoring::GetNumSuccessfulTapNotes( const float fStartBeat, const float fEndBeat )
{
int iNumSuccessfulTapNotes = 0;
int iStartIndex = BeatToNoteRow( fStartBeat );
int iEndIndex = BeatToNoteRow( fEndBeat );
for( int i=iStartIndex; i<min(iEndIndex, MAX_TAP_NOTE_ROWS); i++ )
{
for( int t=0; t<m_iNumTracks; t++ )
{
if( m_TapNotes[t][i] != '0' && m_TapNoteScores[t][i] >= TNS_GREAT )
iNumSuccessfulTapNotes++;
}
}
return iNumSuccessfulTapNotes;
}
int NoteDataWithScoring::GetNumSuccessfulDoubles( const float fStartBeat, const float fEndBeat )
{
int iNumSuccessfulDoubles = 0;
int iStartIndex = BeatToNoteRow( fStartBeat );
int iEndIndex = BeatToNoteRow( fEndBeat );
for( int i=iStartIndex; i<min(iEndIndex, MAX_TAP_NOTE_ROWS); i++ )
{
int iNumNotesThisIndex = 0;
TapNoteScore minTapNoteScore = TNS_PERFECT;
for( int t=0; t<m_iNumTracks; t++ )
{
if( m_TapNotes[t][i] != '0' )
{
iNumNotesThisIndex++;
minTapNoteScore = min( minTapNoteScore, m_TapNoteScores[t][i] );
}
}
if( iNumNotesThisIndex >= 2 && minTapNoteScore >= TNS_GREAT )
iNumSuccessfulDoubles++;
}
return iNumSuccessfulDoubles;
}
int NoteDataWithScoring::GetNumSuccessfulHoldNotes( const float fStartBeat, const float fEndBeat )
{
int iNumSuccessfulHolds = 0;
int iStartIndex = BeatToNoteRow( fStartBeat );
int iEndIndex = BeatToNoteRow( fEndBeat );
for( int i=0; i<m_iNumHoldNotes; i++ )
{
HoldNote &hn = m_HoldNotes[i];
if( iStartIndex <= hn.m_iStartIndex && hn.m_iEndIndex <= iEndIndex && m_HoldNoteScores[i] == HNS_OK )
iNumSuccessfulHolds++;
}
return iNumSuccessfulHolds;
}
float NoteDataWithScoring::GetActualStreamRadarValue( float fSongSeconds )
{
// density of steps
int iNumSuccessfulNotes = GetNumSuccessfulTapNotes() + GetNumSuccessfulHoldNotes();
float fNotesPerSecond = iNumSuccessfulNotes/fSongSeconds;
2002-07-03 21:27:26 +00:00
float fReturn = fNotesPerSecond / 7;
2002-07-03 03:13:13 +00:00
return min( fReturn, 1.0f );
2002-06-23 02:50:33 +00:00
}
float NoteDataWithScoring::GetActualVoltageRadarValue( float fSongSeconds )
{
2002-07-03 21:27:26 +00:00
float fAvgBPS = GetLastBeat() / fSongSeconds;
2002-06-23 02:50:33 +00:00
2002-07-03 21:27:26 +00:00
// peak density of steps
float fMaxDensitySoFar = 0;
2002-06-23 02:50:33 +00:00
2002-07-03 21:27:26 +00:00
const int BEAT_WINDOW = 8;
2002-06-23 02:50:33 +00:00
2002-07-03 21:27:26 +00:00
for( int i=0; i<MAX_BEATS; i+=BEAT_WINDOW )
{
int iNumNotesThisWindow = GetNumSuccessfulTapNotes((float)i,(float)i+BEAT_WINDOW) + GetNumSuccessfulHoldNotes((float)i,(float)i+BEAT_WINDOW);
float fDensityThisWindow = iNumNotesThisWindow/(float)BEAT_WINDOW;
fMaxDensitySoFar = max( fMaxDensitySoFar, fDensityThisWindow );
2002-06-23 02:50:33 +00:00
}
2002-07-03 21:27:26 +00:00
float fReturn = fMaxDensitySoFar*fAvgBPS/10;
2002-07-03 03:13:13 +00:00
return min( fReturn, 1.0f );
2002-06-23 02:50:33 +00:00
}
float NoteDataWithScoring::GetActualAirRadarValue( float fSongSeconds )
{
// number of doubles
int iNumDoubles = GetNumSuccessfulDoubles();
2002-07-03 03:13:13 +00:00
float fReturn = iNumDoubles / fSongSeconds;
return min( fReturn, 1.0f );
2002-06-23 02:50:33 +00:00
}
float NoteDataWithScoring::GetActualChaosRadarValue( float fSongSeconds )
{
2002-07-03 03:13:13 +00:00
// count number of triplets
2002-07-03 21:27:26 +00:00
int iNumChaosNotesCompleted = 0;
2002-07-03 03:13:13 +00:00
for( int r=0; r<MAX_TAP_NOTE_ROWS; r++ )
{
if( !IsRowEmpty(r) && IsRowComplete(r) && GetNoteType(r) >= NOTE_12TH )
iNumChaosNotesCompleted++;
2002-07-03 03:13:13 +00:00
}
2002-07-11 19:02:26 +00:00
float fReturn = iNumChaosNotesCompleted / fSongSeconds * 0.5f;
2002-07-03 03:13:13 +00:00
return min( fReturn, 1.0f );
2002-06-23 02:50:33 +00:00
}
float NoteDataWithScoring::GetActualFreezeRadarValue( float fSongSeconds )
{
// number of hold steps
2002-07-03 03:13:13 +00:00
float fReturn = GetNumSuccessfulHoldNotes() / fSongSeconds;
return min( fReturn, 1.0f );
2002-06-23 02:50:33 +00:00
}