diff --git a/src/core/netplay.cpp b/src/core/netplay.cpp index 9d64c289d..0f4751f1f 100644 --- a/src/core/netplay.cpp +++ b/src/core/netplay.cpp @@ -148,6 +148,7 @@ static void GenerateChecksumForFrame(int* checksum, int frame, unsigned char* bu static MemorySettingsInterface s_settings_overlay; static SessionState s_state; +static bool send_desync_notifications = false; /// Enet struct Peer @@ -1933,10 +1934,18 @@ void Netplay::UpdateThrottlePeriod() Common::Timer::ConvertSecondsToValue(1.0 / (static_cast(System::GetThrottleFrequency()) * s_target_speed)); } +void Netplay::ToggleDesyncNotifications() +{ + bool was_enabled = send_desync_notifications; + send_desync_notifications = send_desync_notifications ? false : true; + if (was_enabled) + Host::ClearNetplayMessages(); +} + void Netplay::HandleTimeSyncEvent(float frame_delta, int update_interval) { // only activate timesync if its worth correcting. - if (std::abs(frame_delta) < 1.0f) + if (std::abs(frame_delta) < 1.75f) return; // Distribute the frame difference over the next N * 0.75 frames. // only part of the interval time is used since we want to come back to normal speed. diff --git a/src/core/netplay.h b/src/core/netplay.h index 6918b82ab..674c6372d 100644 --- a/src/core/netplay.h +++ b/src/core/netplay.h @@ -53,4 +53,6 @@ u32 GetMaxPrediction(); /// Updates the throttle period, call when target emulation speed changes. void UpdateThrottlePeriod(); +void ToggleDesyncNotifications(); + } // namespace Netplay diff --git a/src/core/system.h b/src/core/system.h index 168b821b9..f8cf728ad 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -521,4 +521,5 @@ bool IsFullscreen(); void SetFullscreen(bool enabled); // netplay void OnNetplayMessage(std::string message); +void ClearNetplayMessages(); } // namespace Host diff --git a/src/frontend-common/imgui_netplay.cpp b/src/frontend-common/imgui_netplay.cpp index 8b3d23deb..f5881db04 100644 --- a/src/frontend-common/imgui_netplay.cpp +++ b/src/frontend-common/imgui_netplay.cpp @@ -77,6 +77,12 @@ void Host::OnNetplayMessage(std::string message) Common::Timer::ConvertSecondsToValue(NETPLAY_MESSAGE_DURATION)); } +void Host::ClearNetplayMessages() +{ + while (s_netplay_messages.size() > 0) + s_netplay_messages.pop_front(); +} + void ImGuiManager::RenderNetplayOverlays() { DrawNetplayMessages();