From 3d1dda648b38d92b3774f323079069e97379d85b Mon Sep 17 00:00:00 2001 From: Barinade Date: Mon, 19 Dec 2022 20:23:37 -0600 Subject: [PATCH] fix loading and rescoring and reprioritizing online replays for rebirth and other uses --- src/Etterna/Models/HighScore/Replay.cpp | 22 +++++++++++++++- src/Etterna/Models/HighScore/Replay.h | 34 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/src/Etterna/Models/HighScore/Replay.cpp b/src/Etterna/Models/HighScore/Replay.cpp index b95bf0c005..a86a222116 100644 --- a/src/Etterna/Models/HighScore/Replay.cpp +++ b/src/Etterna/Models/HighScore/Replay.cpp @@ -305,7 +305,22 @@ Replay::GetReplaySnapshotForNoterow(int row) -> std::shared_ptr auto Replay::LoadReplayData() -> bool { - return LoadReplayDataFull() || LoadReplayDataBasic(); + return LoadReplayDataFull() || LoadReplayDataBasic() || + LoadStoredOnlineData(); +} + +auto +Replay::LoadStoredOnlineData() -> bool +{ + if (vOnlineNoteRowVector.empty() || vOnlineOffsetVector.empty() || + vOnlineTapNoteTypeVector.empty() || vOnlineTrackVector.empty()) { + return false; + } + vNoteRowVector = vOnlineNoteRowVector; + vOffsetVector = vOnlineOffsetVector; + vTapNoteTypeVector = vOnlineTapNoteTypeVector; + vTrackVector = vOnlineTrackVector; + return true; } auto @@ -1231,6 +1246,11 @@ Replay::GeneratePrimitiveVectors() -> bool // we have replay data but not column data return GenerateReplayV2DataPresumptively(); } + + if (LoadStoredOnlineData()) { + // we had the data hiding away + return true; + } } if (!LoadInputData()) { diff --git a/src/Etterna/Models/HighScore/Replay.h b/src/Etterna/Models/HighScore/Replay.h index 1e362068f7..cdd3a1f0f2 100644 --- a/src/Etterna/Models/HighScore/Replay.h +++ b/src/Etterna/Models/HighScore/Replay.h @@ -176,6 +176,16 @@ class Replay void SetUseReprioritizedNoteRows(bool b) { if (b != useReprioritizedNoterows) { + if (isOnlineScore()) { + if (vOnlineNoteRowVector.empty() && + GenerateNoterowsFromTimestamps()) { + // initial backup + vOnlineOffsetVector = GetCopyOfOffsetVector(); + vOnlineNoteRowVector = GetCopyOfNoteRowVector(); + vOnlineTrackVector = GetCopyOfTrackVector(); + vOnlineTapNoteTypeVector = GetCopyOfTapNoteTypeVector(); + } + } ClearPrimitiveVectors(); if (b) { vReprioritizedMissData.clear(); @@ -385,6 +395,16 @@ class Replay vMissReplayDataVector.shrink_to_fit(); vHoldReplayDataVector.shrink_to_fit(); vMineReplayDataVector.shrink_to_fit(); + + // extra online data "backups" + vOnlineOffsetVector.clear(); + vOnlineNoteRowVector.clear(); + vOnlineTrackVector.clear(); + vOnlineTapNoteTypeVector.clear(); + vOnlineOffsetVector.shrink_to_fit(); + vOnlineNoteRowVector.shrink_to_fit(); + vOnlineTrackVector.shrink_to_fit(); + vOnlineTapNoteTypeVector.shrink_to_fit(); } /// Lua @@ -397,6 +417,8 @@ class Replay -> bool; auto LoadInputData(const std::string& replayDir = INPUT_DATA_DIR) -> bool; + auto LoadStoredOnlineData() -> bool; + /// For V1 or earlier replays lacking column data, we need to assume /// information. Make it all up. This fills in the column data using /// NoteData. This also provides TapNoteTypes @@ -420,6 +442,10 @@ class Replay vOnlineReplayTimestampVector.shrink_to_fit(); } + bool isOnlineScore() const { + return scoreKey.find("Online_") != std::string::npos; + } + std::map m_ReplaySnapshotMap{}; JudgeInfo judgeInfo{}; @@ -459,6 +485,14 @@ class Replay // and reloading that v2 data generates wrong input data // so this just refreshes the whole process bool generatedInputData = false; + + ///// + // storage of vectors temporarily for online scores only + std::vector vOnlineOffsetVector{}; + std::vector vOnlineNoteRowVector{}; + std::vector vOnlineTrackVector{}; + std::vector vOnlineTapNoteTypeVector{}; + ///// }; #endif