Skip to content

Commit 18b4c3f

Browse files
committed
account for insert/transforms on score save, invalidate >100% scores
get owned
1 parent f562787 commit 18b4c3f

File tree

2 files changed

+48
-4
lines changed

2 files changed

+48
-4
lines changed

src/Etterna/Models/Misc/StageStats.cpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "Core/Services/Locator.hpp"
1717
#include "GamePreferences.h"
1818
#include "Etterna/Singletons/ReplayManager.h"
19+
#include "Etterna/Singletons/GameManager.h"
20+
#include "Etterna/Models/NoteData/NoteDataUtil.h"
1921

2022
#ifndef _WIN32
2123
#include <cpuid.h>
@@ -531,7 +533,8 @@ FillInHighScore(const PlayerStageStats& pss,
531533
asModifiers.push_back(sSongOptions);
532534
}
533535
}
534-
hs.SetModifiers(join(", ", asModifiers));
536+
const auto modstr = join(", ", asModifiers);
537+
hs.SetModifiers(modstr);
535538

536539
hs.SetDateTime(DateTime::GetNowDateTime());
537540
hs.SetPlayerGuid(sPlayerGuid);
@@ -589,8 +592,39 @@ FillInHighScore(const PlayerStageStats& pss,
589592

590593
// for this we need the actual totalpoints values, so we need steps data
591594
auto steps = GAMESTATE->m_pCurSteps;
595+
auto st = steps->m_StepsType;
596+
auto* style = GAMEMAN->GetStyleForStepsType(st);
592597
auto nd = steps->GetNoteData();
593598
auto* td = steps->GetTimingData();
599+
600+
// transform the notedata by style if necessary
601+
if (style != nullptr) {
602+
NoteData ndo;
603+
style->GetTransformedNoteDataForStyle(PLAYER_1, nd, ndo);
604+
nd = ndo;
605+
}
606+
607+
// Have to account for mirror and shuffle
608+
if (style != nullptr && td != nullptr) {
609+
PlayerOptions po;
610+
po.Init();
611+
po.SetForReplay(true);
612+
po.FromString(modstr);
613+
auto tmpSeed = GAMESTATE->m_iStageSeed;
614+
615+
// if rng was not saved, only apply non shuffle mods
616+
if (hs.GetStageSeed() == 0) {
617+
po.m_bTurns[PlayerOptions::TURN_SHUFFLE] = false;
618+
po.m_bTurns[PlayerOptions::TURN_SOFT_SHUFFLE] = false;
619+
po.m_bTurns[PlayerOptions::TURN_SUPER_SHUFFLE] = false;
620+
po.m_bTurns[PlayerOptions::TURN_HRAN_SHUFFLE] = false;
621+
} else {
622+
GAMESTATE->m_iStageSeed = hs.GetStageSeed();
623+
}
624+
625+
NoteDataUtil::TransformNoteData(nd, *td, po, style->m_StepsType);
626+
GAMESTATE->m_iStageSeed = tmpSeed;
627+
}
594628
auto maxpoints = static_cast<float>(nd.WifeTotalScoreCalc(td));
595629

596630
// i _think_ an assert is ok here.. if this can happen we probably want

src/Etterna/Singletons/ScoreManager.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld)
528528
// this function handles skip logic if not necessary
529529
hs->NormalizeJudgments();
530530

531+
// rescore wife2 to wife3 for eligible scores
531532
auto remarried = false;
532533
if (hs->GetWifeVersion() != 3 && !hs->GetChordCohesion() &&
533534
hs->HasReplayData()) {
@@ -540,8 +541,13 @@ ScoreManager::RecalculateSSRs(LoadingWindow* ld)
540541
hs->RescoreToWife3(static_cast<float>(maxpoints));
541542
}
542543

543-
// don't waste time on <= 0%s
544-
if (ssrpercent <= 0.f || !steps->IsRecalcValid()) {
544+
// don't waste time on <= 0%s or > 100%s
545+
if (ssrpercent <= 0.f || ssrpercent > 1.f || !steps->IsRecalcValid()) {
546+
if (ssrpercent > 1.f) {
547+
hs->SetSSRNormPercent(0.f);
548+
hs->SetWifeScore(0.f);
549+
hs->SetGrade(Grade_Failed);
550+
}
545551
hs->ResetSkillsets();
546552
continue;
547553
}
@@ -1197,14 +1203,18 @@ ScoresAtRate::LoadFromNode(const XNode* node,
11971203
scores[sk].IsEmptyNormalized() &&
11981204
(scores[sk].HasReplayData() || scores[sk].GetJudgeScale() == 1.F);
11991205

1206+
// oops (adding this to the recalc list will reset the score to 0)
1207+
const auto broke = scores[sk].GetSSRNormPercent() > 1.F ||
1208+
scores[sk].GetWifeScore() > 1.F;
1209+
12001210
/* technically we don't need to have charts loaded to rescore to
12011211
* wife3, however trying to do this might be quite a bit of work (it
12021212
* would require making a new lambda loop) and while it would be
12031213
* nice to have at some point it's not worth it just at this moment,
12041214
* and while it sort of makes sense from a user convenience aspect
12051215
* to allow this, it definitely does not make sense from a clarity
12061216
* or consistency perspective */
1207-
if ((oldcalc || getremarried || notnormalized) && SONGMAN->IsChartLoaded(ck)) {
1217+
if ((oldcalc || getremarried || notnormalized || broke) && SONGMAN->IsChartLoaded(ck)) {
12081218
SCOREMAN->scorestorecalc.emplace_back(&scores[sk]);
12091219
}
12101220
}

0 commit comments

Comments
 (0)