Skip to content

Commit

Permalink
break replay playback event generation to fix replay playback
Browse files Browse the repository at this point in the history
yeah really so basically what i did here was do the right thing and it caused the player to automatically recalculate all the values based on current conditions. this fixed one specific issue that is caused when you record a replay on one specific song/global offset and then change either one and then play it back. checking back other replay types and regular input data replays this didnt break those so it looks fine. this just means half the code i wrote there to generate the stuff is kind of pointless
  • Loading branch information
poco0317 committed Mar 1, 2023
1 parent 209837b commit 6a75685
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
13 changes: 7 additions & 6 deletions src/Etterna/Actor/Gameplay/PlayerReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,7 @@ PlayerReplay::Update(float fDeltaTime)
}

void
PlayerReplay::SetPlaybackEvents(
const std::map<int, std::vector<PlaybackEvent>>& v)
PlayerReplay::SetPlaybackEvents(std::map<int, std::vector<PlaybackEvent>> v)
{
playbackEvents.clear();

Expand All @@ -330,10 +329,12 @@ PlayerReplay::SetPlaybackEvents(
// must update row and time to match current chart
if (fabsf(rowpos - supposedTime) > 0.01F) {
// haha oh my god
noterow = BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(
m_Timing->GetElapsedTimeFromBeat(
NoteRowToBeat(evt.noterowJudged)) +
(evt.offset * musicRate)));
auto tapPosition = m_Timing->GetElapsedTimeFromBeat(
NoteRowToBeat(evt.noterowJudged)) +
(evt.offset * musicRate);
noterow =
BeatToNoteRow(m_Timing->GetBeatFromElapsedTime(tapPosition));
evt.songPositionSeconds = tapPosition;
gapError = rowpos - supposedTime;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Etterna/Actor/Gameplay/PlayerReplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PlayerReplay : public Player
std::map<int, std::vector<PlaybackEvent>>& GetPlaybackEvents() {
return playbackEvents;
}
void SetPlaybackEvents(const std::map<int, std::vector<PlaybackEvent>>& v);
void SetPlaybackEvents(std::map<int, std::vector<PlaybackEvent>> v);

std::map<int, std::set<int>>& GetDroppedHolds() {
return droppedHolds;
Expand Down
10 changes: 8 additions & 2 deletions src/Etterna/Models/HighScore/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2874,14 +2874,20 @@ Replay::GeneratePlaybackEvents(int startRow) -> std::map<int, std::vector<Playba
return out;
}

const auto globalOffset = fGlobalOffset * fMusicRate;
const auto songOffset = fSongOffset * fMusicRate;
const auto* td = SONGMAN->GetStepsByChartkey(chartKey)->GetTimingData();
for (const InputDataEvent& evt : InputData) {
const auto& evtPositionSeconds = evt.songPositionSeconds;
const auto& column = evt.column;
const auto& isPress = evt.is_press;

const auto noterow =
BeatToNoteRow(td->GetBeatFromElapsedTime(evtPositionSeconds));
// this is technically (???) correct but causes the PlayerReplay
// to correct the noterow later on every single time.
// thats probably a bad thing
// but it does force every replay to be correct ......
const auto noterow = BeatToNoteRow(td->GetBeatFromElapsedTime(
evtPositionSeconds - globalOffset - songOffset));
if (evt.nearestTapNoterow < startRow) {
if (evt.nearestTapNoterow == -1) {
// for ghost taps, only remove them if they are truly too early
Expand Down

0 comments on commit 6a75685

Please sign in to comment.