From 11fe2619eb9299730a63e338d78959dff4754e4c Mon Sep 17 00:00:00 2001 From: sonicfind <52436993+sonicfind@users.noreply.github.com> Date: Fri, 18 Sep 2020 10:44:50 -0500 Subject: [PATCH] recording: Disable currently active frame advancing when opening a different recording --- pcsx2/Recording/InputRecording.cpp | 2 ++ pcsx2/Recording/InputRecordingControls.cpp | 14 +++++++++----- pcsx2/Recording/InputRecordingControls.h | 3 +++ pcsx2/Recording/InputRecordingFile.h | 2 -- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pcsx2/Recording/InputRecording.cpp b/pcsx2/Recording/InputRecording.cpp index 461bad0724..b18b3e2bad 100644 --- a/pcsx2/Recording/InputRecording.cpp +++ b/pcsx2/Recording/InputRecording.cpp @@ -265,6 +265,7 @@ bool InputRecording::Create(wxString FileName, bool fromSaveState, wxString auth // Write header contents inputRecordingData.WriteHeader(); state = InputRecordingMode::Recording; + g_InputRecordingControls.DisableFrameAdvance(); recordingConLog(wxString::Format(L"[REC]: Started new recording - [%s]\n", FileName)); return true; } @@ -309,6 +310,7 @@ bool InputRecording::Play(wxString fileName) incrementUndo = true; state = InputRecordingMode::Replaying; + g_InputRecordingControls.DisableFrameAdvance(); recordingConLog(wxString::Format(L"[REC]: Replaying input recording - [%s]\n", inputRecordingData.GetFilename())); recordingConLog(wxString::Format(L"[REC]: PCSX2 Version Used: %s\n", inputRecordingData.GetHeader().emu)); recordingConLog(wxString::Format(L"[REC]: Recording File Version: %d\n", inputRecordingData.GetHeader().version)); diff --git a/pcsx2/Recording/InputRecordingControls.cpp b/pcsx2/Recording/InputRecordingControls.cpp index 0110c289fd..a8cc3b94de 100644 --- a/pcsx2/Recording/InputRecordingControls.cpp +++ b/pcsx2/Recording/InputRecordingControls.cpp @@ -80,13 +80,12 @@ void InputRecordingControls::HandleFrameAdvanceAndPausing() switchToReplay = false; } - if (g_InputRecording.IsReplaying() - && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames()) + if ((g_InputRecording.IsReplaying() && g_InputRecording.GetFrameCounter() >= g_InputRecording.GetInputRecordingData().GetTotalFrames()) + || g_InputRecording.GetFrameCounter() == INT_MAX) pauseEmulation = true; - // If we havn't yet advanced atleast a single frame from when we paused, setup things to be paused - if (frameAdvancing - && (frameAdvanceMarker < g_InputRecording.GetFrameCounter() || g_InputRecording.GetFrameCounter() == INT_MAX)) + // If we haven't yet advanced atleast a single frame from when we paused, setup things to be paused + if (frameAdvancing && frameAdvanceMarker < g_InputRecording.GetFrameCounter()) { frameAdvancing = false; pauseEmulation = true; @@ -163,6 +162,11 @@ void InputRecordingControls::SetFrameCountTracker(u32 newFrame) frameCountTracker = newFrame; } +void InputRecordingControls::DisableFrameAdvance() +{ + frameAdvancing = false; +} + void InputRecordingControls::TogglePause() { if (pauseEmulation && g_InputRecording.IsReplaying() diff --git a/pcsx2/Recording/InputRecordingControls.h b/pcsx2/Recording/InputRecordingControls.h index 2b6af3c83a..fd34efda36 100644 --- a/pcsx2/Recording/InputRecordingControls.h +++ b/pcsx2/Recording/InputRecordingControls.h @@ -49,6 +49,9 @@ public: // Resume emulation when the next pcsx2 App event is handled void Resume(); void SetFrameCountTracker(u32 newFrame); + // Sets frameAdvancing variable to false + // Used to restrict a frameAdvaceTravker value from transferring between recordings + void DisableFrameAdvance(); // Alternates emulation between a paused and unpaused state void TogglePause(); // Switches between recording and replaying the active input recording file diff --git a/pcsx2/Recording/InputRecordingFile.h b/pcsx2/Recording/InputRecordingFile.h index 4272191890..a97f570df2 100644 --- a/pcsx2/Recording/InputRecordingFile.h +++ b/pcsx2/Recording/InputRecordingFile.h @@ -82,8 +82,6 @@ public: // Writes the current frame's input data to the file so it can be replayed bool WriteKeyBuffer(const uint &frame, const uint port, const uint bufIndex, const u8 &buf); - unsigned long recordingFrameCounter = 0; - private: static const int controllerPortsSupported = 2; static const int controllerInputBytes = 18;