From e6fe893a41a8af576058261610d90f9151dbc2c3 Mon Sep 17 00:00:00 2001 From: Tekhnae Raav Date: Tue, 27 Jan 2026 15:39:39 -0600 Subject: [PATCH 1/3] update rust toolchain to 1.93.0 --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4cef0b738f..075062e5e6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.81" +channel = "1.93.0" From 238df38b84a68ea400d2e9459c0195e84aa380d6 Mon Sep 17 00:00:00 2001 From: Tekhnae Raav Date: Tue, 27 Jan 2026 15:48:05 -0600 Subject: [PATCH 2/3] fix: clippy warnings per suggestions --- framework_crates/bones_asset/src/server.rs | 5 +---- framework_crates/bones_ecs/src/components/typed.rs | 4 ---- framework_crates/bones_ecs/src/system.rs | 4 ++-- framework_crates/bones_framework/src/audio/audio_center.rs | 7 ++++--- framework_crates/bones_framework/src/localization.rs | 2 +- framework_crates/bones_lib/src/reset.rs | 2 +- framework_crates/bones_schema/src/ser_de.rs | 4 ++-- 7 files changed, 11 insertions(+), 17 deletions(-) diff --git a/framework_crates/bones_asset/src/server.rs b/framework_crates/bones_asset/src/server.rs index 3a78f614f2..482a6cfbaa 100644 --- a/framework_crates/bones_asset/src/server.rs +++ b/framework_crates/bones_asset/src/server.rs @@ -896,10 +896,7 @@ impl AssetServer { SchemaMismatchError, >, > { - let cid = match self.store.asset_ids.get(&handle.untyped()) { - Some(cid) => cid, - None => return None, - }; + let cid = self.store.asset_ids.get(&handle.untyped())?; Some( MapRef::try_map(self.store.assets.get(&cid).unwrap(), |x| { let asset = &x.data; diff --git a/framework_crates/bones_ecs/src/components/typed.rs b/framework_crates/bones_ecs/src/components/typed.rs index 4073f6bf72..f4c28e9118 100644 --- a/framework_crates/bones_ecs/src/components/typed.rs +++ b/framework_crates/bones_ecs/src/components/typed.rs @@ -311,10 +311,6 @@ mod tests { #[repr(C)] struct A(u32); - #[derive(Debug, Clone, Copy, PartialEq, Eq, HasSchema, Default)] - #[repr(C)] - struct B(u32); - fn entity(index: u32) -> Entity { Entity::new(index, 0) } diff --git a/framework_crates/bones_ecs/src/system.rs b/framework_crates/bones_ecs/src/system.rs index 73b8ae927c..1f6af2f118 100644 --- a/framework_crates/bones_ecs/src/system.rs +++ b/framework_crates/bones_ecs/src/system.rs @@ -464,7 +464,7 @@ mod tests { assert!(d.as_deref() == Some(&2)); } - let mut world = World::new(); + let world = World::new(); world.insert_resource(1u16); world.insert_resource(2u64); world.run_system(access_resource, ()); @@ -480,7 +480,7 @@ mod tests { **n *= 3; } - let mut world = World::new(); + let world = World::new(); world.insert_resource(2usize); let result = world.run_system(mul_by_res, 3); diff --git a/framework_crates/bones_framework/src/audio/audio_center.rs b/framework_crates/bones_framework/src/audio/audio_center.rs index 0f438550cd..0723d80bd4 100644 --- a/framework_crates/bones_framework/src/audio/audio_center.rs +++ b/framework_crates/bones_framework/src/audio/audio_center.rs @@ -308,9 +308,10 @@ pub fn _process_audio_events( force_restart, } => { let should_play = force_restart - || audio_center.music.as_ref().map_or(true, |current_music| { - sound_source != current_music.bones_handle - }); + || audio_center + .music + .as_ref() + .is_none_or(|current_music| sound_source != current_music.bones_handle); if should_play { // Stop the current music diff --git a/framework_crates/bones_framework/src/localization.rs b/framework_crates/bones_framework/src/localization.rs index 0d436e2678..6f508cc1c1 100644 --- a/framework_crates/bones_framework/src/localization.rs +++ b/framework_crates/bones_framework/src/localization.rs @@ -256,7 +256,7 @@ impl AssetLoader for LocalizationLoader { .unwrap_or(en_us.clone()); let selected_locale = fluent_langneg::negotiate_languages( - &[user_locale.clone()], + std::slice::from_ref(&user_locale), &available_locales, Some(&en_us), fluent_langneg::NegotiationStrategy::Filtering, diff --git a/framework_crates/bones_lib/src/reset.rs b/framework_crates/bones_lib/src/reset.rs index 48178fe430..2a9ddb6a14 100644 --- a/framework_crates/bones_lib/src/reset.rs +++ b/framework_crates/bones_lib/src/reset.rs @@ -69,7 +69,7 @@ impl WorldExt for World { } fn reset_triggered(&self) -> bool { - self.get_resource::().map_or(false, |r| r.reset) + self.get_resource::().is_some_and(|r| r.reset) } fn reset_internals(&mut self, stages: &mut SystemStages) { diff --git a/framework_crates/bones_schema/src/ser_de.rs b/framework_crates/bones_schema/src/ser_de.rs index e1c698b5a5..57a44acee5 100644 --- a/framework_crates/bones_schema/src/ser_de.rs +++ b/framework_crates/bones_schema/src/ser_de.rs @@ -34,7 +34,7 @@ mod serializer_deserializer { return serializer.serialize_str(u); } - return match self.0.access() { + match self.0.access() { SchemaRefAccess::Struct(s) => { if s.fields().count() == 1 && s.fields().nth(0).unwrap().name.is_none() { SchemaSerializer(s.fields().nth(0).unwrap().value).serialize(serializer) @@ -131,7 +131,7 @@ mod serializer_deserializer { Err(S::Error::custom("Cannot serialize opaque types")) } }, - }; + } } } From 9c06b3aeed4bca1ae616e3f035979a1bdc6177b2 Mon Sep 17 00:00:00 2001 From: Tekhnae Raav Date: Tue, 27 Jan 2026 15:48:53 -0600 Subject: [PATCH 3/3] fix: adjust SyncingInfo to satisfy clippy --- .../bones_framework/src/networking.rs | 260 +++++++----------- 1 file changed, 101 insertions(+), 159 deletions(-) diff --git a/framework_crates/bones_framework/src/networking.rs b/framework_crates/bones_framework/src/networking.rs index d90360728c..4e71fc3c2c 100644 --- a/framework_crates/bones_framework/src/networking.rs +++ b/framework_crates/bones_framework/src/networking.rs @@ -200,116 +200,94 @@ pub enum SocketTarget { /// Resource updated each frame exposing syncing/networking information in the current session. #[derive(HasSchema, Clone)] #[schema(no_default)] -pub enum SyncingInfo { - /// Holds data for an online session - Online { - /// Current frame of simulation step - current_frame: i32, - /// Last confirmed frame by all clients. - /// Anything that occurred on this frame is agreed upon by all clients. - last_confirmed_frame: i32, - /// Socket - socket: Socket, - /// Networking stats for each connected player, stored at the \[player_idx\] index for each respective player. - players_network_stats: SVec, - /// The local player's index - local_player_idx: usize, - /// The local input delay set for this session - local_frame_delay: usize, - /// List of disconnected players (their idx) - disconnected_players: SVec, - /// The random seed for this session - random_seed: u64, - }, - /// Holds data for an offline session - Offline { - /// Current frame of simulation step - current_frame: i32, - /// The random seed for this session - random_seed: u64, - }, +pub struct SyncingInfo { + /// Current frame of simulation step + current_frame: i32, + /// The random seed for this session + random_seed: u64, + /// The additional online info. + online_info: Option, +} + +/// Holds data for an online session +#[derive(HasSchema, Clone)] +#[schema(no_default)] +pub struct OnlineSyncingInfo { + /// Last confirmed frame by all clients. + /// Anything that occurred on this frame is agreed upon by all clients. + last_confirmed_frame: i32, + /// Socket + socket: Socket, + /// Networking stats for each connected player, stored at the \[player_idx\] index for each respective player. + players_network_stats: SVec, + /// The local player's index + local_player_idx: usize, + /// The local input delay set for this session + local_frame_delay: usize, + /// List of disconnected players (their idx) + disconnected_players: SVec, } impl SyncingInfo { /// Checks if the session is online. pub fn is_online(&self) -> bool { - matches!(self, SyncingInfo::Online { .. }) + self.online_info.is_some() } /// Checks if the session is offline. pub fn is_offline(&self) -> bool { - matches!(self, SyncingInfo::Offline { .. }) + self.online_info.is_none() } /// Getter for the current frame (number). pub fn current_frame(&self) -> i32 { - match self { - SyncingInfo::Online { current_frame, .. } => *current_frame, - SyncingInfo::Offline { current_frame, .. } => *current_frame, - } + self.current_frame } /// Getter for the last confirmed frame (number). pub fn last_confirmed_frame(&self) -> i32 { - match self { - SyncingInfo::Online { - last_confirmed_frame, - .. - } => *last_confirmed_frame, - SyncingInfo::Offline { current_frame, .. } => *current_frame, - } + self.online_info + .as_ref() + .map(|info| info.last_confirmed_frame) + .unwrap_or(self.current_frame) } /// Getter for socket. pub fn socket(&self) -> Option<&Socket> { - match self { - SyncingInfo::Online { socket, .. } => Some(socket), - SyncingInfo::Offline { .. } => None, - } + self.online_info.as_ref().map(|info| &info.socket) } /// Mutable getter for socket. pub fn socket_mut(&mut self) -> Option<&mut Socket> { - match self { - SyncingInfo::Online { socket, .. } => Some(socket), - SyncingInfo::Offline { .. } => None, - } + self.online_info.as_mut().map(|info| &mut info.socket) } /// Getter for a single player's network stats using their player_idx pub fn player_network_stats(&self, player_idx: usize) -> Option { - match self { - SyncingInfo::Online { - players_network_stats, - .. - } => players_network_stats.get(player_idx).cloned(), - SyncingInfo::Offline { .. } => None, - } + self.online_info + .as_ref() + .map(|info| info.players_network_stats.get(player_idx).cloned())? } /// Getter for all players' network stats, including local player (set to default). This maintains index == player_idx. pub fn players_network_stats(&self) -> SVec { - match self { - SyncingInfo::Online { - players_network_stats, - .. - } => players_network_stats.clone(), - SyncingInfo::Offline { .. } => SVec::new(), - } + self.online_info + .as_ref() + .map(|info| info.players_network_stats.clone()) + .unwrap_or_default() } /// Getter for remote player network stats (filtering out local player). This does not maintain index == player_idx. pub fn remote_players_network_stats(&self) -> SVec { - match self { - SyncingInfo::Online { - players_network_stats, - .. - } => players_network_stats - .iter() - .filter(|&stats| stats.ping != 0 || stats.kbps_sent != 0) - .cloned() - .collect(), - SyncingInfo::Offline { .. } => SVec::new(), - } + self.online_info + .as_ref() + .map(|info| { + info.players_network_stats + .iter() + .filter(|&stats| stats.ping != 0 || stats.kbps_sent != 0) + .cloned() + .collect() + }) + .unwrap_or_default() } /// Calculates the total kilobits per second sent across all remote players. @@ -380,119 +358,81 @@ impl SyncingInfo { /// Getter for the local player index, if offline defaults to None. pub fn local_player_idx_checked(&self) -> Option { - match self { - SyncingInfo::Online { - local_player_idx, .. - } => Some(*local_player_idx), - SyncingInfo::Offline { .. } => None, - } + self.online_info.as_ref().map(|info| info.local_player_idx) } /// Getter for the local player index, if offline defaults to 0. pub fn local_player_idx(&self) -> usize { - match self { - SyncingInfo::Online { - local_player_idx, .. - } => *local_player_idx, - SyncingInfo::Offline { .. } => 0, - } + self.online_info + .as_ref() + .map(|info| info.local_player_idx) + .unwrap_or(0) } /// Getter for the local frame delay. pub fn local_frame_delay(&self) -> usize { - match self { - SyncingInfo::Online { - local_frame_delay, .. - } => *local_frame_delay, - SyncingInfo::Offline { .. } => 0, - } + self.online_info + .as_ref() + .map(|info| info.local_frame_delay) + .unwrap_or(0) } /// Getter for the number of players, if offline defaults to 0. pub fn players_count(&self) -> usize { - match self { - SyncingInfo::Online { - players_network_stats, - .. - } => players_network_stats.len(), - SyncingInfo::Offline { .. } => 0, - } + self.online_info + .as_ref() + .map(|info| info.players_network_stats.len()) + .unwrap_or(0) } /// Getter for the number of players, if offline defaults to None. pub fn players_count_checked(&self) -> Option { - match self { - SyncingInfo::Online { - players_network_stats, - .. - } => Some(players_network_stats.len()), - SyncingInfo::Offline { .. } => None, - } + self.online_info + .as_ref() + .map(|info| info.players_network_stats.len()) } /// Getter for the list of active players (idx) which are connected. Offline returns empty list. pub fn active_players(&self) -> SVec { - match self { - SyncingInfo::Online { - players_network_stats, - disconnected_players, - .. - } => { - let total_players = players_network_stats.len(); + self.online_info + .as_ref() + .map(|info| { + let total_players = info.players_network_stats.len(); (0..total_players) - .filter(|&id| !disconnected_players.contains(&id)) + .filter(|&id| !info.disconnected_players.contains(&id)) .collect() - } - SyncingInfo::Offline { .. } => SVec::new(), - } + }) + .unwrap_or_default() } /// Getter for the list of active players (idx) which are connected. Offline returns None. pub fn active_players_checked(&self) -> Option> { - match self { - SyncingInfo::Online { - players_network_stats, - disconnected_players, - .. - } => { - let total_players = players_network_stats.len(); - let active = (0..total_players) - .filter(|&id| !disconnected_players.contains(&id)) - .collect(); - Some(active) - } - SyncingInfo::Offline { .. } => None, - } + self.online_info.as_ref().map(|info| { + let total_players = info.players_network_stats.len(); + (0..total_players) + .filter(|&id| !info.disconnected_players.contains(&id)) + .collect() + }) } /// Getter for the list of players which have been disconnected (their idx). Offline returns empty list. pub fn disconnected_players(&self) -> SVec { - match self { - SyncingInfo::Online { - disconnected_players, - .. - } => disconnected_players.clone(), - SyncingInfo::Offline { .. } => SVec::new(), - } + self.online_info + .as_ref() + .map(|info| info.disconnected_players.clone()) + .unwrap_or_default() } /// Getter for the list of players which have been disconnected (their idx). Offline returns None. pub fn disconnected_players_checked(&self) -> Option> { - match self { - SyncingInfo::Online { - disconnected_players, - .. - } => Some(disconnected_players.clone()), - SyncingInfo::Offline { .. } => None, - } + self.online_info + .as_ref() + .map(|info| info.disconnected_players.clone()) } /// Getter for the random seed. pub fn random_seed(&self) -> u64 { - match self { - SyncingInfo::Online { random_seed, .. } => *random_seed, - SyncingInfo::Offline { random_seed, .. } => *random_seed, - } + self.random_seed } } @@ -893,18 +833,20 @@ where // even before a frame has advanced. // The existance of this resource may be used to determine if in an online match, and there could // be race if expected it to exist but testing before first frame advance. - world.insert_resource(SyncingInfo::Online { + world.insert_resource(SyncingInfo { current_frame: self.session.current_frame(), - last_confirmed_frame: self.session.confirmed_frame(), - socket: self.socket.clone(), - players_network_stats: players_network_stats.into(), - local_player_idx: self.local_player_idx as usize, - local_frame_delay: self.local_input_delay, - disconnected_players: self - .disconnected_players - .clone() - .into(), random_seed: self.random_seed, + online_info: Some(OnlineSyncingInfo { + last_confirmed_frame: self.session.confirmed_frame(), + socket: self.socket.clone(), + players_network_stats: players_network_stats.into(), + local_player_idx: self.local_player_idx as usize, + local_frame_delay: self.local_input_delay, + disconnected_players: self + .disconnected_players + .clone() + .into(), + }), }); // Disconnected players persisted on session runner, and updated each frame.