Skip to content

Commit 869bc14

Browse files
use new score structure with getwifepb and give lua access to it in order to display values in the goal tracker
1 parent f91fbb2 commit 869bc14

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/Player.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ void Player::Load()
678678
nerv = m_NoteData.GetNonEmptyRowVector();
679679

680680
Profile *pProfile = PROFILEMAN->GetProfile(pn);
681-
wifescorepersonalbest = pProfile->GetWifePBByKey(GAMESTATE->m_pCurSteps[pn]->GetChartKey());
681+
wifescorepersonalbest = pProfile->GetWifePBByKey(GAMESTATE->m_pCurSteps[pn]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate);
682682
if (wifescorepersonalbest == 0)
683683
wifescorepersonalbest = m_pPlayerState->playertargetgoal;
684684

src/Profile.cpp

+17-15
Original file line numberDiff line numberDiff line change
@@ -2425,24 +2425,20 @@ vector<HighScore> Profile::GetScoresByKey(RString ck) {
24252425
return o;
24262426
}
24272427

2428-
float Profile::GetWifePBByKey(RString key) {
2428+
float Profile::GetWifePBByKey(RString ck, float rate) {
24292429
float o = 0.f;
2430+
auto it = HighScoresByChartKey.find(ck);
2431+
if (it == HighScoresByChartKey.end())
2432+
return o;
24302433

2434+
// why will this only compile using at -mina
2435+
auto& hsrm = HighScoresByChartKey.at(ck);
2436+
auto iit = hsrm.find(rate);
2437+
if (iit == hsrm.end())
2438+
return o;
24312439

2432-
2433-
FOREACHM_CONST(SongID, HighScoresForASong, m_SongHighScores, i) {
2434-
const SongID& id = i->first;
2435-
const HighScoresForASong& hsfas = i->second;
2436-
FOREACHM_CONST(StepsID, HighScoresForASteps, hsfas.m_StepsHighScores, j) {
2437-
const StepsID& sid = j->first;
2438-
if (sid.GetKey() == key) {
2439-
FOREACH_CONST(HighScore, j->second.hsl.vHighScores, hs)
2440-
if (hs->GetWifeScore() > o && GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate == hs->GetMusicRate())
2441-
o = hs->GetWifeScore();
2442-
}
2443-
}
2444-
}
2445-
return o;
2440+
// this _should_ be valid as the vector _should_ be sorted already -mina
2441+
return hsrm.at(rate).at(0).GetWifeScore();
24462442
}
24472443

24482444
bool Profile::ChartkeyHasGoal(RString ck) {
@@ -3780,6 +3776,11 @@ class LunaProfile : public Luna<Profile>
37803776
return 1;
37813777
}
37823778

3779+
static int GetPBWifeScoreByKey(T* p, lua_State *L) {
3780+
lua_pushnumber(L, p->GetWifePBByKey(SArg(1), FArg(2)));
3781+
return 1;
3782+
}
3783+
37833784
LunaProfile()
37843785
{
37853786
ADD_METHOD( AddScreenshot );
@@ -3860,6 +3861,7 @@ class LunaProfile : public Luna<Profile>
38603861
ADD_METHOD( GetTopSSRHighScore );
38613862
ADD_METHOD( RecalcTopSSR );
38623863
ADD_METHOD( GetPBHighScoreByKey );
3864+
ADD_METHOD( GetPBWifeScoreByKey );
38633865
ADD_METHOD( ValidateAllScores );
38643866
ADD_METHOD( GetGoalByKey );
38653867
ADD_METHOD( RemoveGoalsByKey );

src/Profile.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class Profile
359359
so instead this funciton finds the song/steps for identical chartkey entries and returns them to
360360
the lua call which then grabs the highscores from the songscores object. -Mina */
361361
void GetScoresByKey(vector<SongID>& songids, vector<StepsID>& stepsids, RString key);
362-
float GetWifePBByKey(RString key);
362+
float GetWifePBByKey(RString key, float rate);
363363
typedef map<float, vector<HighScore>> HighScoreRateMap;
364364
map<RString, HighScoreRateMap> HighScoresByChartKey;
365365

0 commit comments

Comments
 (0)