diff --git a/src/ChartScores.h b/src/ChartScores.h index 621d3a1bc2..32a0f6e24e 100644 --- a/src/ChartScores.h +++ b/src/ChartScores.h @@ -58,13 +58,14 @@ struct ScoresForChart class PlayerScores { public: - // at what? rate. Duh. -mina HighScore* GetChartPBAt(string& ck, float& rate); // technically "up to and including rate: x" but that's a mouthful -mina HighScore* GetChartPBUpTo(string& ck, float& rate); + Grade GetBestGradeFor(string& ck) { if (pscores.count(ck)) return pscores[ck].bestGrade; return Grade_Invalid; } + // for scores achieved during this session void AddScore(const HighScore& hs_) { HighScore hs = hs_; pscores[hs.GetHistoricChartKey()].AddScore(hs); } diff --git a/src/MusicWheelItem.cpp b/src/MusicWheelItem.cpp index 686e927fb7..42513f2ae1 100644 --- a/src/MusicWheelItem.cpp +++ b/src/MusicWheelItem.cpp @@ -363,18 +363,17 @@ void MusicWheelItem::RefreshGrades() FOREACH_ENUM_N(Difficulty, 6, i) { Steps* pSteps = SongUtil::GetStepsByDifficulty(pWID->m_pSong, st, i); if (pSteps != NULL) { - auto& hsv = pProfile->GetScoresByKey(pSteps->ChartKey); - FOREACH(HighScore, hsv, hs) { - if (gradeBest >= hs->GetWifeGrade()) { - dcBest = i; - gradeBest = hs->GetWifeGrade(); - } + Grade dcg = pProfile->pscores.GetBestGradeFor(pSteps->ChartKey); + if (gradeBest >= dcg) { + dcBest = i; + gradeBest = dcg; } } } } } - } else { + } + else { dcBest = dc; if (PROFILEMAN->IsPersistentProfile(ps) && dc != Difficulty_Invalid) { diff --git a/src/Player.cpp b/src/Player.cpp index 6504344cbb..ea1ad3f382 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -678,8 +678,10 @@ void Player::Load() nerv = m_NoteData.GetNonEmptyRowVector(); Profile *pProfile = PROFILEMAN->GetProfile(pn); - wifescorepersonalbest = pProfile->GetWifePBByKey(GAMESTATE->m_pCurSteps[pn]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate); - if (wifescorepersonalbest == 0) + HighScore* pb = pProfile->pscores.GetChartPBAt(GAMESTATE->m_pCurSteps[pn]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate); + if (pb) + wifescorepersonalbest = pb->GetWifeScore(); + else wifescorepersonalbest = m_pPlayerState->playertargetgoal; if (m_pPlayerStageStats) diff --git a/src/Profile.cpp b/src/Profile.cpp index c182010e07..19dbc2bec4 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2400,29 +2400,6 @@ HighScore* ScoreGoal::GetPBUpTo() { return scores.GetChartPBUpTo(chartkey, rate); } -// next on the chopping block -mina -vector Profile::GetScoresByKey(RString ck) { - vector o; - if (!HighScoresByChartKey.count(ck)) - return o; - auto &hsrm = HighScoresByChartKey.at(ck); - FOREACHM(float, vector, hsrm, zz) { - auto &hsv = zz->second; - for (size_t ii = 0; ii < hsv.size(); ii++) { - o.emplace_back(hsv[ii]); } } - return o; } -// and then this one -mina -float Profile::GetWifePBByKey(RString ck, float rate) { - float o = 0.f; - auto it = HighScoresByChartKey.find(ck); - if (it == HighScoresByChartKey.end()) - return o; - auto& hsrm = HighScoresByChartKey.at(ck); - auto iit = hsrm.find(rate); - if (iit == hsrm.end()) - return o; - return hsrm.at(rate).at(0).GetWifeScore(); } - // aaa too lazy to write comparators rn -mina ScoreGoal& Profile::GetLowestGoalForRate(RString ck, float rate) { auto& sgv = goalmap[ck]; diff --git a/src/Profile.h b/src/Profile.h index dfb2d85109..4b00421436 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -359,12 +359,6 @@ class Profile float AggregateScores(vector& invector, float rating, float res, int iter) const; void ValidateAllScores(); - /* Grabbing the highscores here and having lua invoke this results in unhandled exception errors - so instead this funciton finds the song/steps for identical chartkey entries and returns them to - the lua call which then grabs the highscores from the songscores object. -Mina */ - void GetScoresByKey(vector& songids, vector& stepsids, RString key); - float GetWifePBByKey(RString key, float rate); - HighScore& GetPBHighScoreByKey(RString ck, float rate); typedef map> HighScoreRateMap; map HighScoresByChartKey; PlayerScores pscores; @@ -393,37 +387,6 @@ class Profile map m_mapDayToCaloriesBurned; float GetCaloriesBurnedForDay( DateTime day ) const; -/* - // RecentSongScores - struct HighScoreForASongAndSteps - { - StepsID stepsID; - SongID songID; - HighScore hs; - - HighScoreForASongAndSteps() { Unset(); } - void Unset() { stepsID.Unset(); songID.Unset(); hs.Unset(); } - - XNode* CreateNode() const; - }; - - void SaveStepsRecentScore( const Song* pSong, const Steps* pSteps, HighScore hs ); - - // RecentCourseScores - struct HighScoreForACourseAndTrail - { - CourseID courseID; - TrailID trailID; - HighScore hs; - - HighScoreForACourseAndTrail() { Unset(); } - void Unset() { courseID.Unset(); hs.Unset(); } - - XNode* CreateNode() const; - }; - - void SaveCourseRecentScore( const Course* pCourse, const Trail* pTrail, HighScore hs ); -*/ // Init'ing void InitAll() { @@ -494,21 +457,8 @@ class Profile //TopSSRs - bool CalcTopSSRs(unsigned int qty, int skillset); - bool CalcAllTopSSRs(unsigned int qty); - void TopSSRsAddNewScore(HighScore *hs, StepsID stepsid, SongID songid); - float GetTopSSRMSD(unsigned int rank, int skillset); HighScore* GetTopSSRHighScore(unsigned int rank, int skillset); - RString GetTopSSRChartkey(unsigned int rank, int skillset); float GetTopSSRValue(unsigned int rank, int skillset); - Song* GetTopSSRSong(unsigned int rank, int skillset); - Steps* GetTopSSRSteps(unsigned int rank, int skillset); - RString GetTopSSRSongName(unsigned int rank, int skillset); - //Vector array instead of a bunch of vectors - //vector topSSRHighScores[NUM_Skillset]; - vector*> topSSRHighScoreLists[NUM_Skillset]; - vector topSSRHighScoreIndexs[NUM_Skillset];//we work with index+1 so 0 is undefined - vector topSSRChartkeys[NUM_Skillset]; private: const HighScoresForASong *GetHighScoresForASong( const SongID& songID ) const;