Skip to content

Commit

Permalink
fix loading and rescoring and reprioritizing online replays
Browse files Browse the repository at this point in the history
for rebirth and other uses
  • Loading branch information
poco0317 committed Dec 20, 2022
1 parent f0a5a26 commit 3d1dda6
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,22 @@ Replay::GetReplaySnapshotForNoterow(int row) -> std::shared_ptr<ReplaySnapshot>
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
Expand Down Expand Up @@ -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()) {
Expand Down
34 changes: 34 additions & 0 deletions src/Etterna/Models/HighScore/Replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -420,6 +442,10 @@ class Replay
vOnlineReplayTimestampVector.shrink_to_fit();
}

bool isOnlineScore() const {
return scoreKey.find("Online_") != std::string::npos;
}

std::map<int, ReplaySnapshot> m_ReplaySnapshotMap{};
JudgeInfo judgeInfo{};

Expand Down Expand Up @@ -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<float> vOnlineOffsetVector{};
std::vector<int> vOnlineNoteRowVector{};
std::vector<int> vOnlineTrackVector{};
std::vector<TapNoteType> vOnlineTapNoteTypeVector{};
/////
};

#endif

0 comments on commit 3d1dda6

Please sign in to comment.