diff --git a/src/ChartScores.cpp b/src/ChartScores.cpp index 5a1c42bc1b..4736592e27 100644 --- a/src/ChartScores.cpp +++ b/src/ChartScores.cpp @@ -6,16 +6,18 @@ #include "ChartScores.h" -void ScoreMap::AddScore(HighScore& hs) { +void ScoresAtRate::AddScore(HighScore& hs) { string& key = hs.GetScoreKey(); if (float newpb = hs.GetWifeScore() > pbScore) { pbScore = newpb; pbKey = key; } + + bestGrade = min(hs.GetWifeGrade(), bestGrade); scores.emplace(key, hs); } -vector ScoreMap::GetSortedKeys() { +vector ScoresAtRate::GetSortedKeys() { map> tmp; vector o; FOREACHM(string, HighScore, scores, i) @@ -25,38 +27,40 @@ vector ScoreMap::GetSortedKeys() { return o; } -HighScore& ChartScores::GetPBAt(float& rate) { +HighScore& ScoresForChart::GetPBAt(float& rate) { int key = RateToKey(rate); if(ScoresByRate.count(key)) return ScoresByRate.at(key).GetPB(); return HighScore(); } -HighScore& ChartScores::GetPBUpTo(float& rate) { +HighScore& ScoresForChart::GetPBUpTo(float& rate) { int key = RateToKey(rate); - FOREACHM(int, ScoreMap, ScoresByRate, i) + FOREACHM(int, ScoresAtRate, ScoresByRate, i) if (i->first <= key) return i->second.GetPB(); return HighScore(); } -void ChartScores::AddScore(HighScore& hs) { +void ScoresForChart::AddScore(HighScore& hs) { + bestGrade = min(hs.GetWifeGrade(), bestGrade); + float rate = hs.GetMusicRate(); int key = RateToKey(rate); ScoresByRate[key].AddScore(hs); } -vector ChartScores::GetPlayedRates() { +vector ScoresForChart::GetPlayedRates() { vector o; - FOREACHM(int, ScoreMap, ScoresByRate, i) + FOREACHM(int, ScoresAtRate, ScoresByRate, i) o.emplace_back(KeyToRate(i->first)); return o; } -vector ChartScores::GetPlayedRateKeys() { +vector ScoresForChart::GetPlayedRateKeys() { vector o; - FOREACHM(int, ScoreMap, ScoresByRate, i) + FOREACHM(int, ScoresAtRate, ScoresByRate, i) o.emplace_back(i->first); return o; } @@ -77,7 +81,7 @@ HighScore& PlayerScores::GetChartPBUpTo(string& ck, float& rate) { #include "LuaBinding.h" -class LunaScoreMap: public Luna +class LunaScoresAtRate: public Luna { public: static int GetScores(T* p, lua_State *L) { @@ -92,18 +96,18 @@ class LunaScoreMap: public Luna return 1; } - LunaScoreMap() + LunaScoresAtRate() { ADD_METHOD(GetScores); } }; -LUA_REGISTER_CLASS(ScoreMap) +LUA_REGISTER_CLASS(ScoresAtRate) -class LunaChartScores : public Luna +class LunaScoresForChart : public Luna { public: - static int GetScoreMaps(T* p, lua_State *L) { + static int GetScoresAtRates(T* p, lua_State *L) { lua_newtable(L); vector rates = p->GetPlayedRates(); for (size_t i = 0; i < rates.size(); ++i) { @@ -115,10 +119,10 @@ class LunaChartScores : public Luna } - LunaChartScores() + LunaScoresForChart() { - ADD_METHOD(GetScoreMaps); + ADD_METHOD(GetScoresAtRates); } }; -LUA_REGISTER_CLASS(ChartScores) +LUA_REGISTER_CLASS(ScoresForChart) diff --git a/src/ChartScores.h b/src/ChartScores.h index c847f0401e..bbf617723c 100644 --- a/src/ChartScores.h +++ b/src/ChartScores.h @@ -3,11 +3,17 @@ #include -struct ScoreMap + +// Scores for a specific rate for a specific chart +struct ScoresAtRate { public: string pbKey = ""; float pbScore = 0.f; + + // -technically- your pb could be a fail grade so use "bestgrade" -mina + Grade bestGrade = Grade_Invalid; + HighScore& GetPB() { return scores.at(pbKey); } void AddScore(HighScore& hs); @@ -19,13 +25,18 @@ struct ScoreMap }; -struct ChartScores + +// All scores for a specific chart +struct ScoresForChart { public: + Grade bestGrade = Grade_Invalid; // best grade for any rate + HighScore& GetPBAt(float& rate); HighScore & GetPBUpTo(float& rate); void AddScore(HighScore& hs); + vector GetPlayedRates(); vector GetPlayedRateKeys(); int RateToKey(float& rate) { return lround(rate * 10000.f); } @@ -36,7 +47,7 @@ struct ChartScores /* It makes sense internally to have the map keys sorted highest rate to lowest however my experience in lua is that it tends to be more friendly to approach things in the reverse -mina */ - map> ScoresByRate; + map> ScoresByRate; private: @@ -56,9 +67,17 @@ class PlayerScores // the loading process should actually really be done by constructing scores in place -mina // and any internal sorting should occur after all scores ares loaded - void AddScore(string& ck, ChartScores& cs) { pscores.emplace(ck, cs); } + void AddScore(string& ck, ScoresForChart& cs) { pscores.emplace(ck, cs); } + + + + // Top SSRs + + + + - map pscores; + map pscores; map AllScores; private: diff --git a/src/Profile.cpp b/src/Profile.cpp index a02ee97b90..728a2a61da 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2321,7 +2321,7 @@ void Profile::LoadEttScoresFromNode(const XNode* pSongScores) { const XNode *pRateScores = pChart->GetChild("RateScores"); HighScoreRateMap hsrm; - ChartScores wot; + ScoresForChart wot; FOREACH_CONST_Child(pRateScores, pRate) { float rate = StringToFloat(pRate->GetName()); diff --git a/src/StageStats.cpp b/src/StageStats.cpp index 1e0ffef077..5b1047908f 100644 --- a/src/StageStats.cpp +++ b/src/StageStats.cpp @@ -309,7 +309,7 @@ void StageStats::FinalizeScores( bool bSummary ) // new score structure -mina PROFILEMAN->AddScoreByKey(p, hs); Profile* zzz = PROFILEMAN->GetProfile(PLAYER_1); - zzz->pscores.AddScore(GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey(), hs); + zzz->pscores.AddScore(hs); zzz->SetAnyAchievedGoals(GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate, hs); } }