Skip to content

Commit

Permalink
call recalculatessrs and calcplayer rating on profile load
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 29, 2017
1 parent 809ad61 commit eca7cbe
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,9 @@ void Profile::CalculateStatsFromScores() {
m_iNumTotalSongsPlayed = all.size();
m_iTotalDancePoints = m_iTotalTapsAndHolds * 2;
m_iTotalGameplaySeconds = static_cast<int>(TotalGameplaySeconds);

SCOREMAN->RecalculateSSRs();
SCOREMAN->CalcPlayerRating(m_fPlayerRating, m_fPlayerSkillsets);
}

bool Profile::SaveAllToDir( const RString &sDir, bool bSignData ) const
Expand Down
40 changes: 39 additions & 1 deletion src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "XmlFile.h"
#include "XmlFileUtil.h"
#include "Song.h"
#include "MinaCalc.h"
#include "NoteDataStructures.h"
#include "NoteData.h"

ScoreManager* SCOREMAN = NULL;

Expand Down Expand Up @@ -163,10 +166,42 @@ HighScore* ScoreManager::GetChartPBUpTo(string& ck, float& rate) {



void ScoreManager::RecalculateSSRs() {
for(size_t i = 0; i < AllScores.size(); ++i) {
HighScore* hs = AllScores[i];
Steps* steps = SONGMAN->GetStepsByChartkey(hs->GetChartKey());

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

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

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

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

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& dakine = MinaSDCalc(serializednd, steps->GetNoteData().GetNumTracks(), musicrate, ssrpercent, 1.f, false);
FOREACH_ENUM(Skillset, ss)
hs->SetSkillsetSSR(ss, dakine[ss]);
hs->SetSSRCalcVersion(GetCalcVersion());
}
return;
}

Expand All @@ -176,6 +211,9 @@ void ScoreManager::EnableAllScores() {
}

void ScoreManager::CalcPlayerRating(float& prating, float* pskillsets) {
// Force updated calc SSR calculation first
RecalculateSSRs();

float skillsetsum = 0.f;
FOREACH_ENUM(Skillset, ss) {
// actually skip overall
Expand Down

0 comments on commit eca7cbe

Please sign in to comment.