Skip to content

Commit

Permalink
determine a specific nocc personal best and store a pointer to it, as…
Browse files Browse the repository at this point in the history
… well as write it out to the save file
  • Loading branch information
MinaciousGrace committed Sep 17, 2017
1 parent 2208f4e commit 49c669f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ScoresAtRate::ScoresAtRate() {
bestGrade = Grade_Invalid;
scores.clear();
PBptr = nullptr;
noccPBptr = nullptr;
}

void ScoresAtRate::AddScore(HighScore& hs) {
Expand Down Expand Up @@ -389,6 +390,8 @@ XNode* ScoresAtRate::CreateNode(const int& rate) const {
string rs = ssprintf("%.3f", static_cast<float>(rate) / 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());
if(noccPBptr != nullptr)
o->AppendAttr("noccPBKey", noccPBptr->GetScoreKey());
o->AppendAttr("BestGrade", GradeToString(bestGrade));
o->AppendAttr("Rate", rs);

Expand Down Expand Up @@ -436,6 +439,15 @@ void ScoresAtRate::LoadFromNode(const XNode* node, const string& ck, const float
PBptr = &scores.find(sk)->second;
}

// Set any nocc pb
if (noccPBptr == nullptr)
noccPBptr = &scores.find(sk)->second;
else {
// update nocc pb if a better score is found
if (noccPBptr->GetWifeScore() < scores[sk].GetWifeScore() && scores[sk].GetChordCohesion() == 1)
noccPBptr = &scores.find(sk)->second;
}

// Fill in stuff for the highscores
scores[sk].SetChartKey(ck);
scores[sk].SetScoreKey(sk);
Expand Down
1 change: 1 addition & 0 deletions src/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct ScoresAtRate
ScoresAtRate();

HighScore* PBptr;
HighScore* noccPBptr;

// -technically- your pb could be a fail grade so use "bestgrade" -mina
Grade bestGrade;
Expand Down

0 comments on commit 49c669f

Please sign in to comment.