Skip to content

Commit

Permalink
update auto sync logic
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 7, 2020
1 parent d6628b5 commit 157bc1d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
16 changes: 10 additions & 6 deletions src/Etterna/Singletons/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,29 +1144,33 @@ DownloadManager::UploadScores()
if (!LoggedIn())
return false;

// First we accumulate top 2 scores that have
// not been uploaded and have replay data
// First we accumulate top 2 scores that have not been uploaded and have
// replay data. There is no reason to upload updated calc versions to the
// site anymore - the site uses its own calc and afaik ignores the provided
// values, we only need to upload scores that have not been uploaded, and
// scores that have been rescored from wife2 to wife3
auto scores = SCOREMAN->GetAllPBPtrs();
auto& recalculatedscorekeys = SCOREMAN->recalculatedscores;
auto& newly_rescored = SCOREMAN->rescores;
vector<HighScore*> toUpload;
for (auto& vec : scores) {
for (auto& scorePtr : vec) {
auto ts = scorePtr->GetTopScore();

// rescoring should already have properly set topscore values
// if they were to have shuffled
// if they were to have shuffled due to the rescore
if (ts == 1 || ts == 2) {
// handle rescores, ignore upload check
if (recalculatedscorekeys.count(scorePtr->GetScoreKey()))
if (newly_rescored.count(scorePtr))
toUpload.push_back(scorePtr);
// normal behavior, upload scores that haven't been uploaded and
// have replays
else if (!scorePtr->IsUploadedToServer(serverURL.Get()) &&
scorePtr->HasReplayData())
toUpload.push_back(scorePtr);
}
}
}


if (!toUpload.empty())
LOG->Trace("Updating online scores. (Uploading %d scores)",
toUpload.size());
Expand Down
32 changes: 16 additions & 16 deletions src/Etterna/Singletons/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ void
ScoreManager::RecalculateSSRs(LoadingWindow* ld, const string& profileID)
{
RageTimer ld_timer;
vector<HighScore*>& scores = SCOREMAN->scorestorecalc;
auto& scores = SCOREMAN->scorestorecalc;

if (ld != nullptr) {
ld->SetProgress(0);
Expand Down Expand Up @@ -445,7 +445,7 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld, const string& profileID)
}
++scoreIndex;

string ck = hs->GetChartKey();
const string& ck = hs->GetChartKey();
Steps* steps = SONGMAN->GetStepsByChartkey(ck);

// this _should_ be impossible since ischartloaded() checks are required on all charts before getting here
Expand All @@ -466,27 +466,24 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld, const string& profileID)
float ssrpercent = hs->GetSSRNormPercent();
float musicrate = hs->GetMusicRate();

// check needs to be done before rescoring to wife3 since highscore doesn't have
// access to notedata and will assume total points based on replay data vector
// lengths; any pass will have the correct length (also we don't care about fails)
if (ssrpercent <= 0.f || hs->GetGrade() == Grade_Failed) {
// don't waste time on <= 0%s
if (ssrpercent <= 0.f) {
hs->ResetSkillsets();
continue;
}

bool remarried = hs->RescoreToWife3();
// ghasgh we need to decompress to get maxpoints
TimingData* td = steps->GetTimingData();
NoteData nd;
steps->GetNoteData(nd);

auto maxpoints = nd.WifeTotalScoreCalc(td);
bool remarried = hs->RescoreToWife3(static_cast<float>(maxpoints));

// if this is not a rescore and has already been run on the current calc vers, skip
if (!remarried && hs->GetSSRCalcVersion() == GetCalcVersion())
continue;

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

//nd.LogNonEmptyRows();
//auto& nerv = nd.GetNonEmptyRowVector();
//auto& etaner = td->BuildAndGetEtaner(nerv);
const auto& serializednd = nd.SerializeNoteData2(td);
auto dakine = MinaSDCalc_OLD(serializednd,
musicrate,
Expand All @@ -496,8 +493,11 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld, const string& profileID)
hs->SetSkillsetSSR(ss, ssrVals[ss]);
hs->SetSSRCalcVersion(GetCalcVersion());

if (remarried) // maybe recalculated scores should be renamed rescored?
SCOREMAN->recalculatedscores.emplace(hs->GetScoreKey());
// we only want to upload scores that have been rescored to
// wife3, not generic calc changes, since the site runs its own
// calc anyway
if (remarried)
SCOREMAN->rescores.emplace(hs);

td->UnsetEtaner();
nd.UnsetNerv();
Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Singletons/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ScoreManager
vector<HighScore*> scorestorecalc;

// probably can avoid copying strings if we're sure it's safe
set<std::string> recalculatedscores;
set<HighScore*> rescores;

private:
unordered_map<string, unordered_map<string, ScoresForChart>>
Expand Down

0 comments on commit 157bc1d

Please sign in to comment.