From 438fd768a990757b2e072ec0d3e02c4d9cd5826c Mon Sep 17 00:00:00 2001 From: HeatXD <45072324+HeatXD@users.noreply.github.com> Date: Wed, 3 May 2023 23:40:55 +0200 Subject: [PATCH] Netplay: Still figuring out games tend to desync after the first boot of a game. --- src/core/netplay.cpp | 9 +++++++-- src/core/system.cpp | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/core/netplay.cpp b/src/core/netplay.cpp index 10fd0165c..fe7db7ca5 100644 --- a/src/core/netplay.cpp +++ b/src/core/netplay.cpp @@ -182,6 +182,8 @@ void Netplay::SetSettings() // no block linking, it degrades savestate loading performance si.SetBoolValue("CPU", "RecompilerBlockLinking", false); + // not sure its needed but enabled for now. TODO + si.SetBoolValue("GPU", "UseSoftwareRendererForReadbacks", true); Host::Internal::SetNetplaySettingsLayer(&si); } @@ -427,14 +429,17 @@ bool Netplay::NpBeginGameCb(void* ctx, const char* game_name) System::ShutdownSystem(false); // fast boot the selected game and wait for the other player auto param = SystemBootParameters(s_game_path); - // param.save_state = EmuFolders::SaveStates + "/SLUS-00402_2.sav"; + param.override_fast_boot = true; if (!System::BootSystem(param)) { StopNetplaySession(); return false; } - // Fast Forward to Game Start SPU::SetAudioOutputMuted(true); + // Load savestate if available + std::string save = EmuFolders::SaveStates + "/netplay/" + System::GetRunningSerial() + ".sav"; + System::LoadState(save.c_str()); + // Fast Forward to Game Start if needed. while (System::GetInternalFrameNumber() < 2) System::RunFrame(); SPU::SetAudioOutputMuted(false); diff --git a/src/core/system.cpp b/src/core/system.cpp index 606db61d4..bc715b1ec 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1752,6 +1752,18 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di cpu_overclock_active ? Settings::CPUOverclockFractionToPercent(cpu_overclock_numerator, cpu_overclock_denominator) : 100u); + + // during netplay if a file savestate is loaded set + // the overclocks to the same value as the savestate + // file savestates are usually only loaded at game start + if (Netplay::IsActive() && !is_memory_state) + { + g_settings.cpu_overclock_enable = true; + g_settings.cpu_overclock_active = cpu_overclock_active; + g_settings.cpu_overclock_numerator = cpu_overclock_numerator; + g_settings.cpu_overclock_denominator = cpu_overclock_denominator; + } + UpdateOverclock(); }