Skip to content

Commit

Permalink
track last seen song/pack for each chartkey when saving/reading scores
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 7, 2017
1 parent b87a395 commit f893394
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,14 @@ XNode* ScoresAtRate::CreateNode(const int& rate) const {
XNode * ScoresForChart::CreateNode(const string& ck) const {
XNode* o = new XNode("ChartScores");
Song* song = SONGMAN->GetSongByChartkey(ck);
Steps* steps = SONGMAN->GetStepsByChartkey(ck);
o->AppendAttr("Song", song->GetDisplayMainTitle());
o->AppendAttr("Pack", song->m_sGroupName);
o->AppendAttr("Key", ck);

if (song) {
o->AppendAttr("Song", song->GetDisplayMainTitle());
o->AppendAttr("Pack", song->m_sGroupName);
} else {
o->AppendAttr("Song", LastSeenSong);
o->AppendAttr("Pack", LastSeenPack);
}

FOREACHM_CONST(int, ScoresAtRate, ScoresByRate, i)
o->AppendChild(i->second.CreateNode(i->first));

Expand Down Expand Up @@ -292,6 +295,8 @@ void ScoresForChart::LoadFromNode(const XNode* node, const string& ck) {
int rate;
FOREACH_CONST_Child(node, p) {
ASSERT(p->GetName() == "ScoresAt");
p->GetAttrValue("Song", LastSeenSong);
p->GetAttrValue("Pack", LastSeenPack);
p->GetAttrValue("Rate", rs);
rate = 10 * StringToInt(rs.substr(0, 1) + rs.substr(2, 4));
ScoresByRate[rate].LoadFromNode(p, ck, KeyToRate(rate));
Expand Down
3 changes: 2 additions & 1 deletion src/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ struct ScoresForChart

void PushSelf(lua_State *L);


RString LastSeenPack;
RString LastSeenSong;


ScoresAtRate* GetScoresAtRate(const int& rate);
Expand Down

0 comments on commit f893394

Please sign in to comment.