Skip to content

Commit

Permalink
remove replay reliance on playerstate
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Oct 29, 2022
1 parent c1e68b6 commit 1e1877d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#include "Etterna/Models/NoteData/NoteDataUtil.h"
#include "Etterna/Models/StepsAndStyles/Style.h"
#include "Etterna/Models/Misc/PlayerOptions.h"
#include "Etterna/Models/Misc/PlayerState.h"

// Singletons
#include "RageUtil/File/RageFileManager.h"
#include "Etterna/Singletons/PrefsManager.h"
#include "Etterna/Singletons/DownloadManager.h"
#include "Etterna/Singletons/GameManager.h"
#include "Etterna/Singletons/GameState.h"
#include "Etterna/Singletons/ReplayManager.h"
#include "Etterna/Singletons/ScoreManager.h"
Expand Down Expand Up @@ -117,6 +117,17 @@ Replay::GetSteps() -> Steps*
return SONGMAN->GetStepsByChartkey(chartKey);
}

auto
Replay::GetStyle() -> const Style*
{
auto* steps = GetSteps();
if (steps == nullptr) {
return nullptr;
}
auto st = steps->m_StepsType;
return GAMEMAN->GetStyleForStepsType(st);
}

auto
Replay::GetNoteData(Steps* pSteps, bool bTransform) -> NoteData
{
Expand Down Expand Up @@ -1623,33 +1634,24 @@ Replay::GenerateJudgeInfoAndReplaySnapshots(int startingRow, float timingScale)
}

// transform the notedata by style if necessary
// TODO: this sucks dont rely on GAMESTATE
// TODO: please dont, please stop
auto* pstate = GAMESTATE->m_pPlayerState;
if (pstate != nullptr) {
auto* style = GAMESTATE->GetCurrentStyle(pstate->m_PlayerNumber);
if (style != nullptr) {
NoteData ndo;
style->GetTransformedNoteDataForStyle(PLAYER_1, noteData, ndo);
noteData = ndo;
}
auto* style = GetStyle();
if (style != nullptr) {
NoteData ndo;
style->GetTransformedNoteDataForStyle(PLAYER_1, noteData, ndo);
noteData = ndo;
}

// Have to account for mirror being in the highscore options
// please dont change styles in the middle of calculation and break this
// thanks
if (pScoreData != nullptr &&
if (pScoreData != nullptr && style != nullptr &&
(pScoreData->GetModifiers().find("mirror") != std::string::npos ||
pScoreData->GetModifiers().find("Mirror") != std::string::npos)) {
PlayerOptions po;
po.Init();
po.m_bTurns[PlayerOptions::TURN_MIRROR] = true;
NoteDataUtil::TransformNoteData(
noteData,
*pReplayTiming,
po,
GAMESTATE->GetCurrentStyle(GAMESTATE->m_pPlayerState->m_PlayerNumber)
->m_StepsType);
noteData, *pReplayTiming, po, style->m_StepsType);
}

// Now handle misses and holds.
Expand Down
1 change: 1 addition & 0 deletions src/Etterna/Models/HighScore/Replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class Replay
auto GetNoteData(Steps* pSteps = nullptr, bool bTransform = true)
-> NoteData;
auto GetTimingData() -> TimingData*;
auto GetStyle() -> const Style*;

auto GetReplaySnapshotForNoterow(int row)
-> std::shared_ptr<ReplaySnapshot>;
Expand Down

0 comments on commit 1e1877d

Please sign in to comment.