Skip to content

Commit

Permalink
keep track of and add lua hooks for ScoresThisSession
Browse files Browse the repository at this point in the history
it does what it says it means it is does i t is
  • Loading branch information
poco0317 committed Nov 7, 2020
1 parent 44bc50b commit 7a9236a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/Etterna/Singletons/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,19 @@ class LunaScoreManager : public Luna<ScoreManager>
return 1;
}

static auto GetScoresThisSession(T* p, lua_State* L) -> int
{
auto v = p->GetScoresThisSession();
LuaHelpers::CreateTableFromArray(v, L);
return 1;
}

static auto GetNumScoresThisSession(T* p, lua_State* L) -> int
{
lua_pushnumber(L, p->GetNumScoresThisSession());
return 1;
}

DEFINE_METHOD(GetTempReplayScore, tempscoreforonlinereplayviewing);
LunaScoreManager()
{
Expand All @@ -1406,6 +1419,8 @@ class LunaScoreManager : public Luna<ScoreManager>
ADD_METHOD(GetTotalNumberOfScores);
ADD_METHOD(GetTopPlayedSkillsets);
ADD_METHOD(GetPlaycountPerSkillset);
ADD_METHOD(GetScoresThisSession);
ADD_METHOD(GetNumScoresThisSession);
}
};

Expand Down
23 changes: 21 additions & 2 deletions src/Etterna/Singletons/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ class ScoreManager
PROFILEMAN->GetProfile(PLAYER_1)->m_sProfileID) -> int
{
HighScore hs = hs_;
RegisterScoreInProfile(
pscores[profileID][hs.GetChartKey()].AddScore(hs), profileID);
HighScore* h = pscores[profileID][hs.GetChartKey()].AddScore(hs);
RegisterScoreThisSession(h);
RegisterScoreInProfile(h, profileID);
return hs.GetTopScore();
}

Expand Down Expand Up @@ -292,6 +293,19 @@ class ScoreManager
// probably can avoid copying strings if we're sure it's safe
std::set<HighScore*> rescores;

auto GetNumScoresThisSession() -> int
{
return scoresThisSession.size();
}
auto GetScoresThisSession() -> vector<HighScore*>
{
return scoresThisSession;
}
void RegisterScoreThisSession(HighScore* hs)
{
scoresThisSession.push_back(hs);
}

private:
std::unordered_map<std::string,
std::unordered_map<std::string, ScoresForChart>>
Expand All @@ -307,6 +321,11 @@ class ScoreManager
// pointers in a keyed index (by scorekey, in case it's not immediately
// obvious)
std::unordered_map<std::string, HighScore*> ScoresByKey;

// a more thought out (not really) replacement for STATSMAN played stage stats
// note: scoresThisSession is NOT meant to reset on profile load
// (design choice)
vector<HighScore*> scoresThisSession;
};

extern ScoreManager* SCOREMAN;
Expand Down

0 comments on commit 7a9236a

Please sign in to comment.