Skip to content

Commit 3d1dda6

Browse files
committed
fix loading and rescoring and reprioritizing online replays
for rebirth and other uses
1 parent f0a5a26 commit 3d1dda6

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

src/Etterna/Models/HighScore/Replay.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,22 @@ Replay::GetReplaySnapshotForNoterow(int row) -> std::shared_ptr<ReplaySnapshot>
305305
auto
306306
Replay::LoadReplayData() -> bool
307307
{
308-
return LoadReplayDataFull() || LoadReplayDataBasic();
308+
return LoadReplayDataFull() || LoadReplayDataBasic() ||
309+
LoadStoredOnlineData();
310+
}
311+
312+
auto
313+
Replay::LoadStoredOnlineData() -> bool
314+
{
315+
if (vOnlineNoteRowVector.empty() || vOnlineOffsetVector.empty() ||
316+
vOnlineTapNoteTypeVector.empty() || vOnlineTrackVector.empty()) {
317+
return false;
318+
}
319+
vNoteRowVector = vOnlineNoteRowVector;
320+
vOffsetVector = vOnlineOffsetVector;
321+
vTapNoteTypeVector = vOnlineTapNoteTypeVector;
322+
vTrackVector = vOnlineTrackVector;
323+
return true;
309324
}
310325

311326
auto
@@ -1231,6 +1246,11 @@ Replay::GeneratePrimitiveVectors() -> bool
12311246
// we have replay data but not column data
12321247
return GenerateReplayV2DataPresumptively();
12331248
}
1249+
1250+
if (LoadStoredOnlineData()) {
1251+
// we had the data hiding away
1252+
return true;
1253+
}
12341254
}
12351255

12361256
if (!LoadInputData()) {

src/Etterna/Models/HighScore/Replay.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,16 @@ class Replay
176176
void SetUseReprioritizedNoteRows(bool b)
177177
{
178178
if (b != useReprioritizedNoterows) {
179+
if (isOnlineScore()) {
180+
if (vOnlineNoteRowVector.empty() &&
181+
GenerateNoterowsFromTimestamps()) {
182+
// initial backup
183+
vOnlineOffsetVector = GetCopyOfOffsetVector();
184+
vOnlineNoteRowVector = GetCopyOfNoteRowVector();
185+
vOnlineTrackVector = GetCopyOfTrackVector();
186+
vOnlineTapNoteTypeVector = GetCopyOfTapNoteTypeVector();
187+
}
188+
}
179189
ClearPrimitiveVectors();
180190
if (b) {
181191
vReprioritizedMissData.clear();
@@ -385,6 +395,16 @@ class Replay
385395
vMissReplayDataVector.shrink_to_fit();
386396
vHoldReplayDataVector.shrink_to_fit();
387397
vMineReplayDataVector.shrink_to_fit();
398+
399+
// extra online data "backups"
400+
vOnlineOffsetVector.clear();
401+
vOnlineNoteRowVector.clear();
402+
vOnlineTrackVector.clear();
403+
vOnlineTapNoteTypeVector.clear();
404+
vOnlineOffsetVector.shrink_to_fit();
405+
vOnlineNoteRowVector.shrink_to_fit();
406+
vOnlineTrackVector.shrink_to_fit();
407+
vOnlineTapNoteTypeVector.shrink_to_fit();
388408
}
389409

390410
/// Lua
@@ -397,6 +417,8 @@ class Replay
397417
-> bool;
398418
auto LoadInputData(const std::string& replayDir = INPUT_DATA_DIR) -> bool;
399419

420+
auto LoadStoredOnlineData() -> bool;
421+
400422
/// For V1 or earlier replays lacking column data, we need to assume
401423
/// information. Make it all up. This fills in the column data using
402424
/// NoteData. This also provides TapNoteTypes
@@ -420,6 +442,10 @@ class Replay
420442
vOnlineReplayTimestampVector.shrink_to_fit();
421443
}
422444

445+
bool isOnlineScore() const {
446+
return scoreKey.find("Online_") != std::string::npos;
447+
}
448+
423449
std::map<int, ReplaySnapshot> m_ReplaySnapshotMap{};
424450
JudgeInfo judgeInfo{};
425451

@@ -459,6 +485,14 @@ class Replay
459485
// and reloading that v2 data generates wrong input data
460486
// so this just refreshes the whole process
461487
bool generatedInputData = false;
488+
489+
/////
490+
// storage of vectors temporarily for online scores only
491+
std::vector<float> vOnlineOffsetVector{};
492+
std::vector<int> vOnlineNoteRowVector{};
493+
std::vector<int> vOnlineTrackVector{};
494+
std::vector<TapNoteType> vOnlineTapNoteTypeVector{};
495+
/////
462496
};
463497

464498
#endif

0 commit comments

Comments
 (0)