New NoteDataUtil to count hold ticks in a NoteData. Significant overhaul to make PossibleDancePoints consider hold ticks, using said function.

This commit is contained in:
Ben "root" Anderson
2013-12-19 23:46:01 -06:00
parent 53d80a8ceb
commit 6dcc227327
5 changed files with 75 additions and 40 deletions
+23
View File
@@ -9,6 +9,7 @@
#include "GameState.h" #include "GameState.h"
#include "RadarValues.h" #include "RadarValues.h"
#include "Foreach.h" #include "Foreach.h"
#include "TimingData.h"
#include <utility> #include <utility>
// TODO: Remove these constants that aren't time signature-aware // TODO: Remove these constants that aren't time signature-aware
@@ -2612,6 +2613,28 @@ void NoteDataUtil::SetHopoPossibleFlags( const Song *pSong, NoteData& ndInOut )
} }
} }
unsigned int NoteDataUtil::GetTotalHoldTicks( NoteData* nd, const TimingData* td )
{
unsigned int ret = 0;
int end = nd->GetLastRow();
vector<TimingSegment*> segments = td->GetTimingSegments( SEGMENT_TICKCOUNT );
// We start with the LAST TimingSegment and work our way backwards.
// This way we can continually update end instead of having to lookup when
// the next segment starts.
for(int i = segments.size() - 1; i >= 0; i--)
{
TickcountSegment *ts = (TickcountSegment*) segments[i];
if( ts->GetTicks() > 0)
{
// Jump to each point where holds would tick and add the number of holds there to ret.
// XXX: Assuming each segment starts on the beat
for(int j = ts->GetRow(); j < end; j += ROWS_PER_BEAT / ts->GetTicks() )
ret += nd->GetNumTracksHeldAtRow(j);
}
end = ts->GetRow();
}
return ret;
}
/* /*
* (c) 2001-2004 Chris Danford, Glenn Maynard * (c) 2001-2004 Chris Danford, Glenn Maynard
+5
View File
@@ -9,6 +9,7 @@ struct RadarValues;
class NoteData; class NoteData;
class Song; class Song;
struct AttackArray; struct AttackArray;
class TimingData;
/** @brief A limited selection of the RadarValues. */ /** @brief A limited selection of the RadarValues. */
struct RadarStats struct RadarStats
@@ -196,6 +197,10 @@ namespace NoteDataUtil
bool GetPrevEditorPosition( const NoteData& in, int &rowInOut ); bool GetPrevEditorPosition( const NoteData& in, int &rowInOut );
void SetHopoPossibleFlags( const Song *pSong, NoteData& ndInOut ); void SetHopoPossibleFlags( const Song *pSong, NoteData& ndInOut );
/** @brief Count the number of hold ticks that will fire, assuming that tickholds are on.
* @param td The TimingData from the relevant Steps. */
unsigned int GetTotalHoldTicks( NoteData* nd, const TimingData* td );
}; };
#endif #endif
+39 -34
View File
@@ -115,16 +115,13 @@ void ScoreKeeperNormal::Load(
pSteps->Compress(); pSteps->Compress();
const Style* pStyle = GAMESTATE->GetCurrentStyle(); const Style* pStyle = GAMESTATE->GetCurrentStyle();
NoteData nd; NoteData ndPre;
pStyle->GetTransformedNoteDataForStyle( m_pPlayerState->m_PlayerNumber, ndTemp, nd ); pStyle->GetTransformedNoteDataForStyle( m_pPlayerState->m_PlayerNumber, ndTemp, ndPre );
/* Compute RadarValues before applying any user-selected mods. Apply /* Compute RadarValues before applying any user-selected mods. Apply
* Course mods and count them in the "pre" RadarValues because they're * Course mods and count them in the "pre" RadarValues because they're
* forced and not chosen by the user. */ * forced and not chosen by the user. */
NoteDataUtil::TransformNoteData( nd, aa, pSteps->m_StepsType, pSong ); NoteDataUtil::TransformNoteData( ndPre, aa, pSteps->m_StepsType, pSong );
RadarValues rvPre;
GAMESTATE->SetProcessedTimingData(pSteps->GetTimingData());
NoteDataUtil::CalculateRadarValues( nd, pSong->m_fMusicLengthSeconds, rvPre );
/* Apply user transforms to find out how the notes will really look. /* Apply user transforms to find out how the notes will really look.
* *
@@ -133,13 +130,13 @@ void ScoreKeeperNormal::Load(
* have eg. GAMESTATE->GetOptionsForCourse(po,so,pn) to get options based on * have eg. GAMESTATE->GetOptionsForCourse(po,so,pn) to get options based on
* the last call to StoreSelectedOptions and the modifiers list, but that'd * the last call to StoreSelectedOptions and the modifiers list, but that'd
* mean moving the queues in ScreenGameplay to GameState ... */ * mean moving the queues in ScreenGameplay to GameState ... */
NoteDataUtil::TransformNoteData( nd, m_pPlayerState->m_PlayerOptions.GetStage(), pSteps->m_StepsType ); NoteData ndPost = ndPre;
RadarValues rvPost; NoteDataUtil::TransformNoteData( ndPost, m_pPlayerState->m_PlayerOptions.GetStage(), pSteps->m_StepsType );
NoteDataUtil::CalculateRadarValues( nd, pSong->m_fMusicLengthSeconds, rvPost );
GAMESTATE->SetProcessedTimingData(NULL);
iTotalPossibleDancePoints += this->GetPossibleDancePoints( rvPre, rvPost ); GAMESTATE->SetProcessedTimingData(pSteps->GetTimingData()); // XXX: Not sure why but NoteDataUtil::CalculateRadarValues segfaults without this
iTotalPossibleGradePoints += this->GetPossibleGradePoints( rvPre, rvPost ); iTotalPossibleDancePoints += this->GetPossibleDancePoints( &ndPre, &ndPost, pSteps->GetTimingData(), pSong->m_fMusicLengthSeconds );
iTotalPossibleGradePoints += this->GetPossibleGradePoints( &ndPre, &ndPost, pSteps->GetTimingData(), pSong->m_fMusicLengthSeconds );
GAMESTATE->SetProcessedTimingData(NULL);
} }
m_pPlayerStageStats->m_iPossibleDancePoints = iTotalPossibleDancePoints; m_pPlayerStageStats->m_iPossibleDancePoints = iTotalPossibleDancePoints;
@@ -653,52 +650,60 @@ void ScoreKeeperNormal::HandleHoldScore( const TapNote &tn )
} }
int ScoreKeeperNormal::GetPossibleDancePoints( const RadarValues& radars ) int ScoreKeeperNormal::GetPossibleDancePoints( NoteData* nd, const TimingData* td, float fSongSeconds )
{ {
/* Note: If W1 timing is disabled or not active (not course mode), /* Note: If W1 timing is disabled or not active (not course mode),
* W2 will be used instead. */ * W2 will be used instead. */
// XXX: That's not actually implemented!
RadarValues radars;
NoteDataUtil::CalculateRadarValues( *nd, fSongSeconds, radars );
int NumTaps = int(radars[RadarCategory_TapsAndHolds]); int ret = 0;
int NumHolds = int(radars[RadarCategory_Holds]);
int NumRolls = int(radars[RadarCategory_Rolls]); ret += int(radars[RadarCategory_TapsAndHolds]) * TapNoteScoreToDancePoints(TNS_W1, false);
return if( GAMESTATE->GetCurrentGame()->m_bTickHolds ) ret += NoteDataUtil::GetTotalHoldTicks( nd, td ) * g_iPercentScoreWeight[SE_CheckpointHit];
NumTaps*TapNoteScoreToDancePoints(TNS_W1, false) + ret += int(radars[RadarCategory_Holds]) * HoldNoteScoreToDancePoints(HNS_Held, false);
NumHolds*HoldNoteScoreToDancePoints(HNS_Held, false) + ret += int(radars[RadarCategory_Rolls]) * HoldNoteScoreToDancePoints(HNS_Held, false);
NumRolls*HoldNoteScoreToDancePoints(HNS_Held, false);
return ret;
} }
int ScoreKeeperNormal::GetPossibleDancePoints( const RadarValues& fOriginalRadars, const RadarValues& fPostRadars ) int ScoreKeeperNormal::GetPossibleDancePoints( NoteData* ndPre, NoteData* ndPost, const TimingData* td, float fSongSeconds )
{ {
/* The logic here is that if you use a modifier that adds notes, you should /* The logic here is that if you use a modifier that adds notes, you should
* have to hit the new notes to get a high grade. However, if you use one * have to hit the new notes to get a high grade. However, if you use one
* that removes notes, they should simply be counted as misses. */ * that removes notes, they should simply be counted as misses. */
return max( return max(
GetPossibleDancePoints(fOriginalRadars), GetPossibleDancePoints(ndPre, td, fSongSeconds),
GetPossibleDancePoints(fPostRadars) ); GetPossibleDancePoints(ndPost, td, fSongSeconds) );
} }
int ScoreKeeperNormal::GetPossibleGradePoints( const RadarValues& radars ) int ScoreKeeperNormal::GetPossibleGradePoints( NoteData* nd, const TimingData* td, float fSongSeconds )
{ {
/* Note: if W1 timing is disabled or not active (not course mode), /* Note: if W1 timing is disabled or not active (not course mode),
* W2 will be used instead. */ * W2 will be used instead. */
// XXX: That's not actually implemented!
RadarValues radars;
NoteDataUtil::CalculateRadarValues( *nd, fSongSeconds, radars );
int NumTaps = int(radars[RadarCategory_TapsAndHolds]); int ret = 0;
int NumHolds = int(radars[RadarCategory_Holds]);
int NumRolls = int(radars[RadarCategory_Rolls]); ret += int(radars[RadarCategory_TapsAndHolds]) * TapNoteScoreToGradePoints(TNS_W1, false);
return if( GAMESTATE->GetCurrentGame()->m_bTickHolds ) ret += NoteDataUtil::GetTotalHoldTicks( nd, td ) * g_iGradeWeight[SE_CheckpointHit];
NumTaps*TapNoteScoreToGradePoints(TNS_W1, false) + ret += int(radars[RadarCategory_Holds]) * HoldNoteScoreToGradePoints(HNS_Held, false);
NumHolds*HoldNoteScoreToGradePoints(HNS_Held, false) + ret += int(radars[RadarCategory_Rolls]) * HoldNoteScoreToGradePoints(HNS_Held, false);
NumRolls*HoldNoteScoreToGradePoints(HNS_Held, false);
return ret;
} }
int ScoreKeeperNormal::GetPossibleGradePoints( const RadarValues& fOriginalRadars, const RadarValues& fPostRadars ) int ScoreKeeperNormal::GetPossibleGradePoints( NoteData* ndPre, NoteData* ndPost, const TimingData* td, float fSongSeconds )
{ {
/* The logic here is that if you use a modifier that adds notes, you should /* The logic here is that if you use a modifier that adds notes, you should
* have to hit the new notes to get a high grade. However, if you use one * have to hit the new notes to get a high grade. However, if you use one
* that removes notes, they should simply be counted as misses. */ * that removes notes, they should simply be counted as misses. */
return max( return max(
GetPossibleGradePoints(fOriginalRadars), GetPossibleGradePoints( ndPre, td, fSongSeconds ),
GetPossibleGradePoints(fPostRadars) ); GetPossibleGradePoints( ndPost, td, fSongSeconds ) );
} }
int ScoreKeeperNormal::TapNoteScoreToDancePoints( TapNoteScore tns ) const int ScoreKeeperNormal::TapNoteScoreToDancePoints( TapNoteScore tns ) const
+5 -4
View File
@@ -10,6 +10,7 @@
class Steps; class Steps;
class Song; class Song;
struct RadarValues; struct RadarValues;
class TimingData;
AutoScreenMessage( SM_PlayToasty ); AutoScreenMessage( SM_PlayToasty );
@@ -76,10 +77,10 @@ public:
// This must be calculated using only cached radar values so that we can // This must be calculated using only cached radar values so that we can
// do it quickly. // do it quickly.
static int GetPossibleDancePoints( const RadarValues& fRadars ); static int GetPossibleDancePoints( NoteData* nd, const TimingData* td, float fSongSeconds );
static int GetPossibleDancePoints( const RadarValues& fOriginalRadars, const RadarValues& fPostRadars ); static int GetPossibleDancePoints( NoteData* ndPre, NoteData* ndPost, const TimingData* td, float fSongSeconds );
static int GetPossibleGradePoints( const RadarValues& fRadars ); static int GetPossibleGradePoints( NoteData* nd, const TimingData* td, float fSongSeconds );
static int GetPossibleGradePoints( const RadarValues& fOriginalRadars, const RadarValues& fPostRadars ); static int GetPossibleGradePoints( NoteData* ndPre, NoteData* ndPost, const TimingData* td, float fSongSeconds );
int TapNoteScoreToDancePoints( TapNoteScore tns ) const; int TapNoteScoreToDancePoints( TapNoteScore tns ) const;
int HoldNoteScoreToDancePoints( HoldNoteScore hns ) const; int HoldNoteScoreToDancePoints( HoldNoteScore hns ) const;
+2 -1
View File
@@ -9,7 +9,8 @@
#include "XmlFile.h" #include "XmlFile.h"
#include "UnlockManager.h" #include "UnlockManager.h"
#include "SongUtil.h" #include "SongUtil.h"
#include "NoteData.h"
#include "NoteTypes.h" // ROWS_PER_BEAT
bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const bool StepsCriteria::Matches( const Song *pSong, const Steps *pSteps ) const
{ {