allow input delay of 0 (#1379)

This commit is contained in:
Logan McNaughton authored and GitHub committed 2026-11-11 18:50:58 +00:00
1 parent 23345321d8
commit f6b9fcd3d2
4 files changed
+14 -9

No files matched your search

+2 -2
View File
@@ -3,7 +3,7 @@ use crate::savestates;
use crate::ui;
use sha2::digest::Digest;
const MAX_PREDICTION_WINDOW: usize = 16;
pub const MAX_PREDICTION_WINDOW: usize = 16;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct RtcIceServerConfig {
@@ -203,7 +203,7 @@ pub fn receive_save(netplay: &mut Netplay, save_type: &str, save_data: &mut Vec<
}
pub fn change_input_delay(netplay: &mut Netplay, input_delay: usize) {
if !(1..=MAX_PREDICTION_WINDOW).contains(&input_delay) {
if input_delay > MAX_PREDICTION_WINDOW {
return;
}
+1
View File
@@ -132,6 +132,7 @@ export component AppWindow inherits Window {
in-out property netplay_chat_text <=> NetplayWaitData.chat_text;
in-out property netplay_input_delay <=> NetplayWaitData.input_delay;
in-out property netplay_recommended_delay <=> NetplayWaitData.recommended_delay;
in-out property netplay_max_input_delay <=> NetplayWaitData.max_input_delay;
in-out property netplay_game_pal <=> NetplayWaitData.game_pal;
in-out property netplay_connected_peers_count <=> NetplayWaitData.connected_peers_count;
+3 -2
View File
@@ -19,6 +19,7 @@ export global NetplayWaitData {
in-out property <string> chat_text;
in-out property <int> input_delay;
in-out property <int> recommended_delay;
in-out property <int> max_input_delay;
in-out property <bool> game_pal;
in-out property <int> connected_peers_count;
}
@@ -116,8 +117,8 @@ export component NetplayWait inherits Page {
SpinBox {
height: self.min-height;
minimum: 1;
maximum: 16;
minimum: 0;
maximum: NetplayWaitData.max_input_delay;
value: NetplayWaitData.input_delay;
enabled: NetplayWaitData.recommended_delay != 0;
edited => {
+8 -5
View File
@@ -1,4 +1,5 @@
use crate::device;
use crate::netplay;
use crate::netplay::RtcIceServerConfig;
use crate::ui;
use crate::ui::gui::{AppWindow, open_uri, run_rom, save_settings, show_touch_overlay};
@@ -688,8 +689,8 @@ fn update_ping(
60.0
};
let latency_frames = (ping_avg / (1000.0 / refresh_rate)).ceil() as i32;
let recommendation =
(latency_frames + 1).min(16);
let recommendation = (latency_frames + 1)
.min(netplay::MAX_PREDICTION_WINDOW as i32);
if handle.get_netplay_recommended_delay() == 0 {
handle.set_netplay_input_delay(recommendation);
@@ -801,9 +802,9 @@ fn setup_wait_window(
let players = handle.get_netplay_players();
// Input delay is per-player: use our own choice, falling back
// to the host's if our recommendation hasn't been calculated yet.
let local_input_delay = handle.get_netplay_input_delay();
let input_delay = if local_input_delay > 0 {
local_input_delay as usize
let input_delay = if handle.get_netplay_recommended_delay() > 0
{
handle.get_netplay_input_delay() as usize
} else {
response
.sessions
@@ -1027,6 +1028,8 @@ pub fn netplay_window(
app: &AppWindow,
no_intro_map: std::sync::Arc<tokio::sync::Mutex<rustc_hash::FxHashMap<String, String>>>,
) {
app.set_netplay_max_input_delay(netplay::MAX_PREDICTION_WINDOW as i32);
let (netplay_read_sender, netplay_read_receiver): (
tokio::sync::broadcast::Sender<Option<NetplayLobbyMessage>>,
tokio::sync::broadcast::Receiver<Option<NetplayLobbyMessage>>,