From c781b4ebc43b385695a73aff7fa405a6a570bad9 Mon Sep 17 00:00:00 2001 From: Max Whitehead Date: Thu, 29 Aug 2024 15:21:18 -0700 Subject: [PATCH] fix: Fixup paths using `NetworkInfo` to use `SyncingInfo` + update bones_framework --- Cargo.lock | 26 +++++++++++++------------- src/core/scoring.rs | 29 ++++++++++++++++------------- src/ui/pause_menu.rs | 6 +++++- src/ui/scoring.rs | 9 ++++----- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5742be3597..da79e3ea31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1198,7 +1198,7 @@ dependencies = [ [[package]] name = "bones_asset" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "anyhow", "append-only-vec", @@ -1229,7 +1229,7 @@ dependencies = [ [[package]] name = "bones_bevy_renderer" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "anyhow", "bevy", @@ -1246,7 +1246,7 @@ dependencies = [ [[package]] name = "bones_ecs" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "anyhow", "atomicell", @@ -1263,7 +1263,7 @@ dependencies = [ [[package]] name = "bones_ecs_macros" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "bones_ecs_macros_core", "proc-macro2", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "bones_ecs_macros_core" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "proc-macro2", "quote", @@ -1282,7 +1282,7 @@ dependencies = [ [[package]] name = "bones_framework" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "anyhow", "async-channel 1.9.0", @@ -1331,7 +1331,7 @@ dependencies = [ [[package]] name = "bones_lib" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "bones_ecs", "instant", @@ -1340,7 +1340,7 @@ dependencies = [ [[package]] name = "bones_matchmaker_proto" version = "0.2.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "iroh-net", "serde", @@ -1349,7 +1349,7 @@ dependencies = [ [[package]] name = "bones_schema" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "append-only-vec", "bones_schema_macros", @@ -1367,7 +1367,7 @@ dependencies = [ [[package]] name = "bones_schema_macros" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "proc-macro2", "quote", @@ -1377,7 +1377,7 @@ dependencies = [ [[package]] name = "bones_scripting" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "async-channel 1.9.0", "bevy_tasks", @@ -1394,7 +1394,7 @@ dependencies = [ [[package]] name = "bones_utils" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "bones_utils_macros", "branches", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "bones_utils_macros" version = "0.3.0" -source = "git+https://github.com/fishfolk/bones#66f35a5efeec0391deda3d8be6327809f278c051" +source = "git+https://github.com/fishfolk/bones#280620cf398974894696a5b40c96e73315965a1d" dependencies = [ "quote", "venial", diff --git a/src/core/scoring.rs b/src/core/scoring.rs index f130069317..e504a81fea 100644 --- a/src/core/scoring.rs +++ b/src/core/scoring.rs @@ -95,7 +95,7 @@ pub fn round_end( mut scoring_menu: ResMut, killed_players: Comp, player_indices: Comp, - #[cfg(not(target_arch = "wasm32"))] network_info: Option>, + #[cfg(not(target_arch = "wasm32"))] syncing_info: Option>, ) { // Count players so we can avoid ending round if it's a one player match let mut player_count = 0; @@ -155,6 +155,7 @@ pub fn round_end( // Is round transition sycnrhonized on all clients in network play? // Will evaluate to true in local play. + #[allow(unused_assignments)] let mut round_transition_synchronized = false; // If in network play and determined a prev frame round should end on: @@ -162,8 +163,11 @@ pub fn round_end( if let Some(end_net_frame) = state.network_round_end_frame { // check if this frame is confirmed by all players. #[cfg(not(target_arch = "wasm32"))] - if let Some(network_info) = network_info { - round_transition_synchronized = end_net_frame <= network_info.last_confirmed_frame; + { + round_transition_synchronized = match syncing_info { + Some(syncing_info) => end_net_frame <= syncing_info.last_confirmed_frame(), + None => true, + }; } } else { // Network frame for round end not yet recorded (or in local only) @@ -175,21 +179,20 @@ pub fn round_end( // Save current predicted frame for round end. // Will not follow through with transition until this frame is confirmed - // by all players in network play. If local, safe to transition now. + // by all players in network play. #[cfg(not(target_arch = "wasm32"))] - if let Some(network_info) = network_info { - state.network_round_end_frame = Some(network_info.current_frame); + if let Some(syncing_info) = syncing_info { + state.network_round_end_frame = Some(syncing_info.current_frame()); } else { - // `Option>` always available in network play, - // we are local and can transition now. + // No sync info - must be local and sychronized. round_transition_synchronized = true; } + } - // Wasm32 is always local, can transition now. - #[cfg(target_arch = "wasm32")] - { - round_transition_synchronized = true; - } + // Wasm32 is always local, can transition now. + #[cfg(target_arch = "wasm32")] + { + round_transition_synchronized = true; } if round_transition_synchronized { diff --git a/src/ui/pause_menu.rs b/src/ui/pause_menu.rs index c0bd7a8bb0..f4d2129c46 100644 --- a/src/ui/pause_menu.rs +++ b/src/ui/pause_menu.rs @@ -39,7 +39,11 @@ fn pause_menu_system( let pause_pressed = controls.values().any(|x| x.pause_just_pressed); #[cfg(not(target_arch = "wasm32"))] - let is_online = session.world.get_resource::().is_some(); + let is_online = session + .world + .get_resource::() + .map_or(false, |x| x.is_online()); + #[cfg(target_arch = "wasm32")] let is_online = false; diff --git a/src/ui/scoring.rs b/src/ui/scoring.rs index 37d4ac071d..8497ac5014 100644 --- a/src/ui/scoring.rs +++ b/src/ui/scoring.rs @@ -2,7 +2,7 @@ use std::ops::Deref; #[cfg(not(target_arch = "wasm32"))] -use bones_framework::networking::{NetworkInfo, NetworkSocket, SocketTarget}; +use bones_framework::networking::{socket::Socket, NetworkSocket, SocketTarget, SyncingInfo}; use crate::prelude::*; @@ -91,11 +91,10 @@ fn scoring_menu_system( let match_inputs = session.world.get_resource::().unwrap(); #[cfg(not(target_arch = "wasm32"))] - let network_socket = session + let network_socket: Option = session .world - .get_resource::() - .as_deref() - .map(|x| x.socket.clone()); + .get_resource::() + .and_then(|x| x.socket().cloned()); // Build Vec sorted by player indices let mut player_entities: Vec<(Entity, &PlayerIdx)> =