Skip to content

Commit

Permalink
move skillset resets to highscore and clear constructed timing/noteda…
Browse files Browse the repository at this point in the history
…ta after recalcing
  • Loading branch information
MinaciousGrace committed May 30, 2017
1 parent 04dce35 commit 6aa1055
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
10 changes: 10 additions & 0 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct HighScoreImpl
void LoadFromEttNode(const XNode *pNode);
Grade GetWifeGrade() const;
void UnloadReplayData();
void ResetSkillsets();

bool WriteReplayData(bool duringload);

Expand Down Expand Up @@ -206,6 +207,11 @@ vector<int> HighScoreImpl::NoteRowsToVector(RString s) {
return o;
}

void HighScoreImpl::ResetSkillsets() {
FOREACH_ENUM(Skillset, ss)
fSkillsetSSRs[ss] = 0.f;
}

HighScoreImpl::HighScoreImpl()
{
sName = "";
Expand Down Expand Up @@ -656,6 +662,10 @@ void HighScore::UnloadReplayData() {
m_Impl->UnloadReplayData();
}

void HighScore::ResetSkillsets() {
m_Impl->ResetSkillsets();
}

/* We normally don't give direct access to the members. We need this one
* for NameToFillIn; use a special accessor so it's easy to find where this
* is used. */
Expand Down
1 change: 1 addition & 0 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ struct HighScore
bool LoadReplayData(bool duringload);
bool HasReplayData();
void UnloadReplayData();
void ResetSkillsets();

string GetDisplayName() const;

Expand Down
27 changes: 16 additions & 11 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,39 +171,44 @@ void ScoreManager::RecalculateSSRs() {
HighScore* hs = AllScores[i];
Steps* steps = SONGMAN->GetStepsByChartkey(hs->GetChartKey());

if (!steps)
if (!steps) {
hs->ResetSkillsets();
continue;
}

if (!steps->IsRecalcValid()) {
FOREACH_ENUM(Skillset, ss)
hs->SetSkillsetSSR(ss, 0.f);
hs->ResetSkillsets();
continue;
}

float ssrpercent = hs->GetSSRNormPercent();
float musicrate = hs->GetMusicRate();

if (ssrpercent <= 0.f || hs->GetGrade() == Grade_Failed) {
FOREACH_ENUM(Skillset, ss)
hs->SetSkillsetSSR(ss, 0.f);
hs->ResetSkillsets();
continue;
}

if (hs->GetSSRCalcVersion() == GetCalcVersion())
continue;
//if (hs->GetSSRCalcVersion() == GetCalcVersion())
//continue;

steps->Decompress();
TimingData* td = steps->GetTimingData();
NoteData& nd = steps->GetNoteData();

nd.LogNonEmptyRows();
auto& nerv = nd.GetNonEmptyRowVector();
const vector<float>& etaner = td->BuildAndGetEtaner(nerv);
auto& serializednd = nd.SerializeNoteData(etaner);
auto nerv = nd.GetNonEmptyRowVector();
auto etaner = td->BuildAndGetEtaner(nerv);
auto serializednd = nd.SerializeNoteData(etaner);

auto& dakine = MinaSDCalc(serializednd, steps->GetNoteData().GetNumTracks(), musicrate, ssrpercent, 1.f, false);
auto dakine = MinaSDCalc(serializednd, steps->GetNoteData().GetNumTracks(), musicrate, ssrpercent, 1.f, td->HasWarps());
FOREACH_ENUM(Skillset, ss)
hs->SetSkillsetSSR(ss, dakine[ss]);
hs->SetSSRCalcVersion(GetCalcVersion());

td->UnsetElapsedTimesAtAllRows();
nd.UnsetNerv();
nd.UnsetSerializedNoteData();
}
return;
}
Expand Down

0 comments on commit 6aa1055

Please sign in to comment.