From 4b775828fec5f41499d084b8f3a508aa806b34a4 Mon Sep 17 00:00:00 2001 From: MinaciousGrace Date: Tue, 23 May 2017 18:30:56 -0400 Subject: [PATCH] more temporary cheesy stuff for profile conversions --- src/Profile.cpp | 4 +++- src/ScoreManager.cpp | 21 ++++++++++++++++++--- src/ScoreManager.h | 4 ++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Profile.cpp b/src/Profile.cpp index eb1315a0e0..df71b6fe0f 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2001,6 +2001,8 @@ void Profile::LoadOldEttScoresFromNode(const XNode* pSongScores) { RString ck; pChart->GetAttrValue("Key", ck); + RString title; + pChart->GetAttrValue("SongTitle", title); const XNode *pRateScores = pChart->GetChild("RateScores"); FOREACH_CONST_Child(pRateScores, pRate) { @@ -2008,7 +2010,7 @@ void Profile::LoadOldEttScoresFromNode(const XNode* pSongScores) { FOREACH_CONST_Child(pRate, hs) { HighScore tmp; tmp.LoadFromEttNode(hs); - SCOREMAN->AddScore(tmp, ck, rate); + SCOREMAN->AddScore(tmp, ck, rate, title); loaded++; } } diff --git a/src/ScoreManager.cpp b/src/ScoreManager.cpp index 8e3735a7e1..80c7f01df1 100644 --- a/src/ScoreManager.cpp +++ b/src/ScoreManager.cpp @@ -99,6 +99,17 @@ void ScoresForChart::AddScore(HighScore& hs) { ScoresByRate[key].AddScore(hs); } +void ScoresForChart::AddScore(HighScore& hs, const string& title) { + bestGrade = min(hs.GetWifeGrade(), bestGrade); + + if(title != "") + LastSeenSong = title; + + float rate = hs.GetMusicRate(); + int key = RateToKey(rate); + ScoresByRate[key].AddScore(hs); +} + vector ScoresForChart::GetPlayedRates() { vector o; FOREACHM(int, ScoresAtRate, ScoresByRate, i) @@ -227,7 +238,7 @@ HighScore* ScoreManager::GetTopSSRHighScore(unsigned int rank, int ss) { -void ScoreManager::AddScore(const HighScore& hs_, const string& ck, const float& rate) { +void ScoreManager::AddScore(const HighScore& hs_, const string& ck, const float& rate, const string& title) { HighScore hs = hs_; // don't save any scores under the percent threshold and dont duplicate scores if (hs.GetWifeScore() <= minpercent || ScoresByKey.count(hs.GetScoreKey())) @@ -237,7 +248,7 @@ void ScoreManager::AddScore(const HighScore& hs_, const string& ck, const float& hs.SetChartKey(ck); hs.SetMusicRate(rate); - pscores[hs.GetChartKey()].AddScore(hs); + pscores[hs.GetChartKey()].AddScore(hs, title); } // Write scores to xml @@ -256,7 +267,11 @@ XNode* ScoresAtRate::CreateNode(const int& rate) const { if (o->ChildrenEmpty()) return o; - string rs = ssprintf("%.3f", static_cast(rate) / 10000.f); + float oops = rate; + if (oops > 30000) + oops /= 10; + + string rs = ssprintf("%.3f", static_cast(oops) / 10000.f); // should be safe as this is only called if there is at least 1 score (which would be the pb) o->AppendAttr("PBKey", PBptr->GetScoreKey()); o->AppendAttr("BestGrade", GradeToString(bestGrade)); diff --git a/src/ScoreManager.h b/src/ScoreManager.h index 6dc7055741..eed943b777 100644 --- a/src/ScoreManager.h +++ b/src/ScoreManager.h @@ -53,8 +53,8 @@ struct ScoresForChart vector GetAllPBPtrs(); - void AddScore(HighScore& hs); + void AddScore(HighScore& hs, const string& title); vector GetPlayedRates(); vector GetPlayedRateKeys(); @@ -100,7 +100,7 @@ class ScoreManager void AddScore(const HighScore& hs_) { HighScore hs = hs_; pscores[hs.GetChartKey()].AddScore(hs); } // temporarily to be used for conversion of old ett.xml and not only adding scores obtained in-session - void AddScore(const HighScore& hs_, const string& ck, const float& rate); + void AddScore(const HighScore& hs_, const string& ck, const float& rate, const string& title); float minpercent = PREFSMAN->m_fMinPercentToSaveScores; // until i can get this shit to load properly the right way -mina // Player Rating and SSR functions