Skip to content

Commit

Permalink
more temporary cheesy stuff for profile conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 23, 2017
1 parent 599e9f5 commit 4b77582
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,14 +2001,16 @@ 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) {
float rate = StringToFloat(pRate->GetName());
FOREACH_CONST_Child(pRate, hs) {
HighScore tmp;
tmp.LoadFromEttNode(hs);
SCOREMAN->AddScore(tmp, ck, rate);
SCOREMAN->AddScore(tmp, ck, rate, title);
loaded++;
}
}
Expand Down
21 changes: 18 additions & 3 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> ScoresForChart::GetPlayedRates() {
vector<float> o;
FOREACHM(int, ScoresAtRate, ScoresByRate, i)
Expand Down Expand Up @@ -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()))
Expand All @@ -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
Expand All @@ -256,7 +267,11 @@ XNode* ScoresAtRate::CreateNode(const int& rate) const {
if (o->ChildrenEmpty())
return o;

string rs = ssprintf("%.3f", static_cast<float>(rate) / 10000.f);
float oops = rate;
if (oops > 30000)
oops /= 10;

string rs = ssprintf("%.3f", static_cast<float>(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));
Expand Down
4 changes: 2 additions & 2 deletions src/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ struct ScoresForChart

vector<HighScore*> GetAllPBPtrs();


void AddScore(HighScore& hs);
void AddScore(HighScore& hs, const string& title);

vector<float> GetPlayedRates();
vector<int> GetPlayedRateKeys();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4b77582

Please sign in to comment.