diff --git a/src/ChartScores.cpp b/src/ChartScores.cpp index f5492f3eb3..c35dd9fb9c 100644 --- a/src/ChartScores.cpp +++ b/src/ChartScores.cpp @@ -27,20 +27,20 @@ vector ScoresAtRate::GetSortedKeys() { return o; } -HighScore& ScoresForChart::GetPBAt(float& rate) { +HighScore* ScoresForChart::GetPBAt(float& rate) { int key = RateToKey(rate); if(ScoresByRate.count(key)) - return ScoresByRate.at(key).GetPB(); - return HighScore(); + return ScoresByRate.at(key).PBptr; + return NULL; } -HighScore& ScoresForChart::GetPBUpTo(float& rate) { +HighScore* ScoresForChart::GetPBUpTo(float& rate) { int key = RateToKey(rate); FOREACHM(int, ScoresAtRate, ScoresByRate, i) if (i->first <= key) - return i->second.GetPB(); + return i->second.PBptr; - return HighScore(); + return NULL; } void ScoresForChart::AddScore(HighScore& hs) { @@ -72,16 +72,16 @@ vector ScoresForChart::GetAllPBPtrs() { return o; } -HighScore& PlayerScores::GetChartPBAt(string& ck, float& rate) { +HighScore* PlayerScores::GetChartPBAt(string& ck, float& rate) { if (pscores.count(ck)) return pscores.at(ck).GetPBAt(rate); - return HighScore(); + return NULL; } -HighScore& PlayerScores::GetChartPBUpTo(string& ck, float& rate) { +HighScore* PlayerScores::GetChartPBUpTo(string& ck, float& rate) { if (pscores.count(ck)) return pscores.at(ck).GetPBUpTo(rate); - return HighScore(); + return NULL; } diff --git a/src/ChartScores.h b/src/ChartScores.h index 18bf680fff..621d3a1bc2 100644 --- a/src/ChartScores.h +++ b/src/ChartScores.h @@ -8,17 +8,12 @@ struct ScoresAtRate { public: - string pbKey = ""; - float pbScore = 0.f; - HighScore* PBptr; - HighScore** GetPBPtr() { return (&PBptr); } // -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); vector GetSortedKeys(); @@ -36,8 +31,8 @@ struct ScoresForChart public: Grade bestGrade = Grade_Invalid; // best grade for any rate - HighScore& GetPBAt(float& rate); - HighScore & GetPBUpTo(float& rate); + HighScore* GetPBAt(float& rate); + HighScore* GetPBUpTo(float& rate); vector GetAllPBPtrs(); @@ -65,10 +60,10 @@ class PlayerScores public: // at what? rate. Duh. -mina - HighScore& GetChartPBAt(string& ck, float& rate); + 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); + HighScore* GetChartPBUpTo(string& ck, float& rate); // for scores achieved during this session void AddScore(const HighScore& hs_) { HighScore hs = hs_; pscores[hs.GetHistoricChartKey()].AddScore(hs); } diff --git a/src/Profile.cpp b/src/Profile.cpp index 4156def88f..5c9e9d3f17 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -2395,7 +2395,7 @@ void ScoreGoal::LoadFromNode(const XNode *pNode) { pNode->GetChildValue("Comment", comment); } -HighScore& ScoreGoal::GetPBUpTo() { +HighScore* ScoreGoal::GetPBUpTo() { auto& scores = PROFILEMAN->GetProfile(PLAYER_1)->pscores; return scores.GetChartPBUpTo(chartkey, rate); } @@ -3713,11 +3713,11 @@ class LunaScoreGoal : public Luna } static int GetPBUpTo(T* p, lua_State *L) { - HighScore& pb = p->GetPBUpTo(); - if (pb.IsEmpty()) + HighScore* pb = p->GetPBUpTo(); + if (!pb) lua_pushnil(L); else - pb.PushSelf(L); + pb->PushSelf(L); return 1; } diff --git a/src/Profile.h b/src/Profile.h index 04c56aa97f..dfb2d85109 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -90,7 +90,7 @@ class ScoreGoal XNode* CreateNode() const; void LoadFromNode(const XNode *pNode); - HighScore& GetPBUpTo(); + HighScore* GetPBUpTo(); void PushSelf(lua_State *L); };