Skip to content

Commit

Permalink
make radarvalues ints by killing stream/chaos/whatevergarbge and leav…
Browse files Browse the repository at this point in the history
…ing pure counts
  • Loading branch information
MinaciousGrace committed May 5, 2017
1 parent 23ee2c2 commit b652bd7
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 216 deletions.
5 changes: 0 additions & 5 deletions src/GameConstantsAndTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ extern const vector<RString> RANKING_TO_FILL_IN_MARKER( GenerateRankingToFillInM
extern const RString GROUP_ALL = "---Group All---";

static const char *RadarCategoryNames[] = {
"Stream",
"Voltage",
"Air",
"Freeze",
"Chaos",
"Notes",
"TapsAndHolds",
"Jumps",
Expand Down
11 changes: 1 addition & 10 deletions src/GameConstantsAndTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ const RString& SkillsetToString(Skillset ss);
*
* This is just cached song data. Not all of it may actually be displayed
* in the radar. */
enum RadarCategory
{
RadarCategory_Stream = 0, /**< How much stream is in the song? */
RadarCategory_Voltage, /**< How much voltage is in the song? */
RadarCategory_Air, /**< How much air is in the song? */
RadarCategory_Freeze, /**< How much freeze (holds) is in the song? */
RadarCategory_Chaos, /**< How much chaos is in the song? */
enum RadarCategory {
RadarCategory_Notes, /**< How many notes are in the song? */
RadarCategory_TapsAndHolds, /**< How many taps and holds are in the song? */
RadarCategory_Jumps, /**< How many jumps are in the song? */
Expand All @@ -57,9 +51,6 @@ enum RadarCategory
RadarCategory_Rolls, /**< How many rolls are in the song? */
RadarCategory_Lifts, /**< How many lifts are in the song? */
RadarCategory_Fakes, /**< How many fakes are in the song? */
// If you add another radar category, make sure you update
// NoteDataUtil::CalculateRadarValues to calculate it.
// Also update NoteDataWithScoring::GetActualRadarValues. -Kyz
NUM_RadarCategory, /**< The number of radar categories. */
RadarCategory_Invalid
};
Expand Down
2 changes: 1 addition & 1 deletion src/GrooveRadar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void GrooveRadar::SetFromSteps( PlayerNumber pn, Steps* pSteps ) // NULL means n
return;
}

const RadarValues &rv = pSteps->GetRadarValues( pn );
const RadarValues &rv = pSteps->GetRadarValues();
m_GrooveRadarValueMap[pn].SetFromSteps( rv );
}

Expand Down
4 changes: 1 addition & 3 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ HighScoreImpl::HighScoreImpl()
XNode *HighScoreImpl::CreateNode() const
{
XNode *pNode = new XNode( "HighScore" );
const bool bWriteSimpleValues = RadarValues::WRITE_SIMPLE_VALIES;
const bool bWriteComplexValues = RadarValues::WRITE_COMPLEX_VALIES;

// TRICKY: Don't write "name to fill in" markers.
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? RString("") : sName );
Expand Down Expand Up @@ -293,7 +291,7 @@ XNode *HighScoreImpl::CreateNode() const
pSkillsetSSRs->AppendChild(SkillsetToString(ss), fSkillsetSSRs[ss]);
}

pNode->AppendChild( radarValues.CreateNode(bWriteSimpleValues, bWriteComplexValues) );
pNode->AppendChild( radarValues.CreateNode() );
pNode->AppendChild( "LifeRemainingSeconds", fLifeRemainingSeconds );
pNode->AppendChild( "Disqualified", bDisqualified);
return pNode;
Expand Down
2 changes: 1 addition & 1 deletion src/LifeMeterTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void LifeMeterTime::OnLoadSong()
float song_len = song->m_fMusicLengthSeconds;
Steps* steps = GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber];
ASSERT(steps != NULL);
RadarValues radars = steps->GetRadarValues(m_pPlayerState->m_PlayerNumber);
RadarValues radars = steps->GetRadarValues();
float scorable_things = radars[RadarCategory_TapsAndHolds] +
radars[RadarCategory_Lifts];
if (g_fTimeMeterSecondsChange[SE_Held] > 0.0f)
Expand Down
41 changes: 0 additions & 41 deletions src/NoteDataWithScoring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,32 +152,6 @@ bool NoteDataWithScoring::IsRowCompletelyJudged( const NoteData &in, unsigned ro
return MinTapNoteScore( in, row, plnum ) >= TNS_Miss;
}

namespace
{
// Return the ratio of actual combo to max combo.
float GetActualVoltageRadarValue( const NoteData &in, float fSongSeconds, const PlayerStageStats &pss )
{
/* STATSMAN->m_CurStageStats.iMaxCombo is unrelated to GetNumTapNotes:
* m_bComboContinuesBetweenSongs might be on, and the way combo is counted
* varies depending on the mode and score keeper. Instead, let's use the
* length of the longest recorded combo. This is only subtly different:
* it's the percent of the song the longest combo took to get. */
const PlayerStageStats::Combo_t MaxCombo = pss.GetMaxCombo();
float fComboPercent = SCALE(MaxCombo.m_fSizeSeconds, 0, fSongSeconds, 0.0f, 1.0f);
return clamp( fComboPercent, 0.0f, 1.0f );
}

// Return the ratio of actual to possible dance points.
float GetActualChaosRadarValue( const NoteData &in, float fSongSeconds, const PlayerStageStats &pss )
{
const int iPossibleDP = pss.m_iPossibleDancePoints;
if ( iPossibleDP == 0 )
return 1;

const int ActualDP = pss.m_iActualDancePoints;
return clamp( float(ActualDP)/iPossibleDP, 0.0f, 1.0f );
}
}

struct hold_status
{
Expand Down Expand Up @@ -399,21 +373,6 @@ void NoteDataWithScoring::GetActualRadarValues(const NoteData &in,
{
switch(rc)
{
case RadarCategory_Stream:
out[rc]= clamp(float(state.notes_hit_for_stream) / note_count, 0.0f, 1.0f);
break;
case RadarCategory_Voltage:
out[rc]= GetActualVoltageRadarValue(in, hittable_steps_length, pss);
break;
case RadarCategory_Air:
out[rc]= clamp(float(state.jumps_hit_for_air) / jump_count, 0.0f, 1.0f);
break;
case RadarCategory_Freeze:
out[rc]= clamp(float(state.holds_held) / hold_count, 0.0f, 1.0f);
break;
case RadarCategory_Chaos:
out[rc]= GetActualChaosRadarValue(in, song_seconds, pss);
break;
case RadarCategory_TapsAndHolds:
out[rc]= state.taps_hit;
break;
Expand Down
7 changes: 2 additions & 5 deletions src/NotesLoaderJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,8 @@ static void Deserialize( Steps &o, const Json::Value &root )
o.SetDifficulty( StringToDifficulty(root["Difficulty"].asString()) );
o.SetMeter( root["Meter"].asInt() );

RadarValues rv[NUM_PLAYERS];
FOREACH_PlayerNumber( pn )
{
Deserialize( rv[pn], root["RadarValues"] );
}
RadarValues rv;
Deserialize( rv, root["RadarValues"] );
o.SetCachedRadarValues( rv );
}

Expand Down
20 changes: 6 additions & 14 deletions src/NotesLoaderSSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,11 @@ void SetRadarValues(StepsTagInfo& info)
{
vector<RString> values;
split((*info.params)[1], ",", values, true);
// Instead of trying to use the version to figure out how many
// categories to expect, look at the number of values and split them
// evenly. -Kyz
size_t cats_per_player= values.size() / NUM_PlayerNumber;
RadarValues v[NUM_PLAYERS];
FOREACH_PlayerNumber(pn)
{
for(size_t i= 0; i < cats_per_player; ++i)
{
v[pn][i]= StringToInt(values[pn * cats_per_player + i]);
}
}
info.steps->SetCachedRadarValues(v);
RadarValues rv;
rv.Zero();
for (size_t i = 0; i < NUM_RadarCategory; ++i)
rv[i] = StringToInt(values[i]);
info.steps->SetCachedRadarValues(rv);
}
else
{
Expand Down Expand Up @@ -530,7 +522,7 @@ vector<float> msdsplit(const RString& s) {
int numrates = static_cast<int>(nchar / 5.f);

for (size_t i = 0; i < numrates; ++i)
o.emplace_back(StringToFloat(s.substr(i * 5, 5)));
o.emplace_back(StringToFloat(s.substr(i * 4, 4)));
return o;
}

Expand Down
2 changes: 1 addition & 1 deletion src/NotesWriterJson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void Serialize( const Steps &o, Json::Value &root )
root["Description"] = o.GetDescription();
root["Difficulty"] = DifficultyToString(o.GetDifficulty());
root["Meter"] = o.GetMeter();
Serialize( o.GetRadarValues( PLAYER_1 ), root["RadarValues"] );
//Serialize( o.GetRadarValues(), root["RadarValues"] );
}


Expand Down
11 changes: 3 additions & 8 deletions src/NotesWriterSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,13 @@ static RString GetSMNotesTag( const Song &song, const Steps &in )
lines.push_back( ssprintf( " %d:", in.GetMeter() ) );

vector<RString> asRadarValues;
// OpenITG simfiles use 11 radar categories.
int categories = 11;
FOREACH_PlayerNumber( pn )
{
const RadarValues &rv = in.GetRadarValues( pn );
// Can't use the foreach anymore due to flexible radar lines.
for( RadarCategory rc = (RadarCategory)0; rc < categories;
const RadarValues &rv = in.GetRadarValues();
for( RadarCategory rc = (RadarCategory)0; rc < categories;
enum_add<RadarCategory>( rc, 1 ) )
{
asRadarValues.push_back( ssprintf("%.6f", rv[rc]) );
asRadarValues.push_back( IntToString(rv[rc]) );
}
}
lines.push_back( ssprintf( " %s:", join(",",asRadarValues).c_str() ) );

RString sNoteData;
Expand Down
11 changes: 3 additions & 8 deletions src/NotesWriterSSC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,9 @@ static RString GetSSCNoteData( const Song &song, const Steps &in, bool bSavingCa
push_back_tag(lines, "#MUSIC:%s;", in.GetMusicFile());

vector<RString> asRadarValues;
FOREACH_PlayerNumber(pn)
{
const RadarValues &rv = in.GetRadarValues(pn);
FOREACH_ENUM(RadarCategory, rc)
{
asRadarValues.push_back(ssprintf("%i", rv[rc]));
}
}
const RadarValues &rv = in.GetRadarValues();
FOREACH_ENUM(RadarCategory, rc)
asRadarValues.push_back(ssprintf("%i", rv[rc]));
lines.push_back(ssprintf("#RADARVALUES:%s;", join(",", asRadarValues).c_str()));

push_back_tag(lines, "#CREDIT:%s;", in.GetCredit());
Expand Down
6 changes: 3 additions & 3 deletions src/PaneDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void PaneDisplay::LoadFromNode( const XNode *pNode )
ActorFrame::LoadFromNode( pNode );
}

void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float & fLevelOut )
void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, int & fLevelOut )
{
const Song *pSong = GAMESTATE->m_pCurSong;
const Steps *pSteps = GAMESTATE->m_pCurSteps[m_PlayerNumber];
Expand Down Expand Up @@ -157,7 +157,7 @@ void PaneDisplay::GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float

if( pSteps )
{
rv = pSteps->GetRadarValues( m_PlayerNumber );
rv = pSteps->GetRadarValues();
pHSL = &PROFILEMAN->GetProfile(slot)->GetStepsHighScoreList(pSong, pSteps);
}

Expand Down Expand Up @@ -258,7 +258,7 @@ void PaneDisplay::SetContent( PaneCategory c )
{
// these get filled in later:
RString str;
float val;
int val;

GetPaneTextAndLevel( c, str, val );
m_textContents[c].SetText( str );
Expand Down
2 changes: 1 addition & 1 deletion src/PaneDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PaneDisplay: public ActorFrame
void PushSelf( lua_State *L );

private:
void GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, float & fLevelOut );
void GetPaneTextAndLevel( PaneCategory c, RString & sTextOut, int & fLevelOut );
void SetContent( PaneCategory c );

BitmapText m_textContents[NUM_PaneCategory];
Expand Down
2 changes: 1 addition & 1 deletion src/PlayerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ bool PlayerOptions::IsEasierForSongAndSteps( Song* pSong, Steps* pSteps, PlayerN
{
if( m_fTimeSpacing && pSteps->HasSignificantTimingChanges() )
return true;
const RadarValues &rv = pSteps->GetRadarValues( pn );
const RadarValues &rv = pSteps->GetRadarValues();
if( m_bTransforms[TRANSFORM_NOHOLDS] && rv[RadarCategory_Holds]>0 )
return true;
if( m_bTransforms[TRANSFORM_NOROLLS] && rv[RadarCategory_Rolls]>0 )
Expand Down
2 changes: 1 addition & 1 deletion src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ int PlayerStageStats::GetLessonScoreNeeded() const

FOREACH_CONST( Steps*, m_vpPossibleSteps, steps )
{
fScore += (*steps)->GetRadarValues(PLAYER_1)[RadarCategory_TapsAndHolds];
fScore += (*steps)->GetRadarValues()[RadarCategory_TapsAndHolds];
}

return lround( fScore * LESSON_PASS_THRESHOLD );
Expand Down
55 changes: 10 additions & 45 deletions src/RadarValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,80 +5,45 @@
#include "XmlFile.h"
#include "ThemeManager.h"

ThemeMetric<bool> RadarValues::WRITE_SIMPLE_VALIES( "RadarValues", "WriteSimpleValues" );
ThemeMetric<bool> RadarValues::WRITE_COMPLEX_VALIES( "RadarValues", "WriteComplexValues" );
RadarValues::RadarValues() { MakeUnknown(); }

RadarValues::RadarValues()
{
MakeUnknown();
}

void RadarValues::MakeUnknown()
{
void RadarValues::MakeUnknown() {
FOREACH_ENUM( RadarCategory, rc )
{
(*this)[rc] = RADAR_VAL_UNKNOWN;
}
}

void RadarValues::Zero()
{
void RadarValues::Zero() {
FOREACH_ENUM( RadarCategory, rc )
{
(*this)[rc] = 0;
}
}

XNode* RadarValues::CreateNode( bool bIncludeSimpleValues, bool bIncludeComplexValues ) const
{
XNode* RadarValues::CreateNode() const {
XNode* pNode = new XNode( "RadarValues" );

// TRICKY: Don't print a remainder for the integer values.
FOREACH_ENUM( RadarCategory, rc )
{
if( rc >= RadarCategory_TapsAndHolds )
{
if( bIncludeSimpleValues )
{
pNode->AppendChild(RadarCategoryToString(rc), (int)((*this)[rc]));
}
}
else
{
if( bIncludeComplexValues )
{
pNode->AppendChild(RadarCategoryToString(rc), (*this)[rc]);
}
}
}

pNode->AppendChild(RadarCategoryToString(rc), (*this)[rc]);
return pNode;
}

void RadarValues::LoadFromNode( const XNode* pNode )
{
void RadarValues::LoadFromNode( const XNode* pNode ) {
ASSERT( pNode->GetName() == "RadarValues" );

Zero();

FOREACH_ENUM( RadarCategory, rc )
{
pNode->GetChildValue( RadarCategoryToString(rc), (*this)[rc] );
}
}

/* iMaxValues is only used for writing compatibility fields in non-cache
* SM files; they're never actually read. */
RString RadarValues::ToString( int iMaxValues ) const
{
RString RadarValues::ToString( int iMaxValues ) const {
if( iMaxValues == -1 )
iMaxValues = NUM_RadarCategory;
iMaxValues = min( iMaxValues, (int)NUM_RadarCategory );
iMaxValues = min( iMaxValues, static_cast<int>(NUM_RadarCategory));

vector<RString> asRadarValues;
for( int r=0; r < iMaxValues; r++ )
{
asRadarValues.push_back(ssprintf("%.3f", (*this)[r]));
asRadarValues.push_back(IntToString((*this)[r]));
}

return join( ",",asRadarValues );
Expand All @@ -97,7 +62,7 @@ void RadarValues::FromString( const RString &sRadarValues )

FOREACH_ENUM( RadarCategory, rc )
{
(*this)[rc] = StringToFloat(saValues[rc]);
(*this)[rc] = StringToInt(saValues[rc]);
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/RadarValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct RadarValues
return !operator==( other );
}

XNode* CreateNode( bool bIncludeSimpleValues, bool bIncludeComplexValues ) const;
XNode* CreateNode() const;
void LoadFromNode( const XNode* pNode );

RString ToString( int iMaxValues = -1 ) const; // default = all
Expand Down
Loading

0 comments on commit b652bd7

Please sign in to comment.