From effc560c6cfa16426d1d2b761af2137864c75438 Mon Sep 17 00:00:00 2001 From: Flux Xu Date: Sat, 4 May 2024 12:56:57 -0400 Subject: [PATCH] Disable `mutef` and `rtt` for FFA. --- binaries/flo-cli/src/map.rs | 1 + crates/client/src/game/mod.rs | 5 ++-- crates/client/src/lan/diag.rs | 1 + crates/client/src/lan/game/game.rs | 36 ++++++++++++++++++----------- crates/controller/src/game/types.rs | 1 + crates/net/src/proto/connect.proto | 1 + crates/types/src/game.rs | 3 ++- 7 files changed, 32 insertions(+), 16 deletions(-) diff --git a/binaries/flo-cli/src/map.rs b/binaries/flo-cli/src/map.rs index 94619f8b..95f01d5b 100644 --- a/binaries/flo-cli/src/map.rs +++ b/binaries/flo-cli/src/map.rs @@ -16,6 +16,7 @@ impl Command { let (map, checksum) = W3Map::open_with_checksum(path)?; println!("Checkdsum: {:?}", checksum); println!("Map Name: {}", map.name()); + println!("Map Players: {:?}", map.get_players().len()); } } Ok(()) diff --git a/crates/client/src/game/mod.rs b/crates/client/src/game/mod.rs index d2c8138a..d354677d 100644 --- a/crates/client/src/game/mod.rs +++ b/crates/client/src/game/mod.rs @@ -2,7 +2,7 @@ use crate::error::{Error, Result}; use flo_types::game::{GameInfo, LocalGameInfo}; pub fn local_game_from_game_info(player_id: i32, game: &GameInfo) -> Result { - Ok(LocalGameInfo { + Ok(LocalGameInfo { name: game.name.clone(), game_id: game.id, random_seed: game.random_seed, @@ -25,5 +25,6 @@ pub fn local_game_from_game_info(player_id: i32, game: &GameInfo) -> Result GameHandler<'a> { let mut muted_names = vec![]; #[cfg(feature = "blacklist")] let mut blacklisted = vec![]; - for p in &self.info.slot_info.player_infos { - if mute_list.contains(&p.player_id) { - muted_names.push(p.name.clone()); - self.muted_players.insert(p.slot_player_id); + + // Disable auto-mute (mutef) for FFA games + if !self.info.game.mask_player_names { + for p in &self.info.slot_info.player_infos { + if mute_list.contains(&p.player_id) { + muted_names.push(p.name.clone()); + self.muted_players.insert(p.slot_player_id); + } + #[cfg(feature = "blacklist")] + if let Some(r) = blacklist::read(&p.name).unwrap_or(None) { + blacklisted.push(format!("{} for {}", p.name.clone(), r)); + } } - #[cfg(feature = "blacklist")] - if let Some(r) = blacklist::read(&p.name).unwrap_or(None) { - blacklisted.push(format!("{} for {}", p.name.clone(), r)); + if !muted_names.is_empty() { + self.send_chats_to_self( + self.info.slot_info.my_slot_player_id, + vec![format!("Auto muted: {}", muted_names.join(", "))], + ) } } - if !muted_names.is_empty() { - self.send_chats_to_self( - self.info.slot_info.my_slot_player_id, - vec![format!("Auto muted: {}", muted_names.join(", "))], - ) - } #[cfg(feature = "blacklist")] if !blacklisted.is_empty() { self.send_chats_to_self( @@ -793,6 +797,12 @@ impl<'a> GameHandler<'a> { } } } + cmd if cmd.starts_with("rtt") && self.info.game.mask_player_names => { + self.send_chats_to_self( + self.info.slot_info.my_slot_player_id, + vec!["Command disabled".to_string()], + ); + } _ => { // unknown command treats like regular chat message return false; diff --git a/crates/controller/src/game/types.rs b/crates/controller/src/game/types.rs index 40bca6d7..66240c95 100644 --- a/crates/controller/src/game/types.rs +++ b/crates/controller/src/game/types.rs @@ -54,6 +54,7 @@ impl S2ProtoPack for Game { is_live: self.is_live, random_seed: self.random_seed, created_by: self.created_by.pack()?, + mask_player_names: self.mask_player_names, }) } } diff --git a/crates/net/src/proto/connect.proto b/crates/net/src/proto/connect.proto index 5423dbf7..06eecbb6 100644 --- a/crates/net/src/proto/connect.proto +++ b/crates/net/src/proto/connect.proto @@ -213,6 +213,7 @@ message GameInfo { bool is_live = 9; int32 random_seed = 10; PlayerInfo created_by = 11; + bool mask_player_names = 12; } message Slot { diff --git a/crates/types/src/game.rs b/crates/types/src/game.rs index 8c7d7aa9..5c736284 100644 --- a/crates/types/src/game.rs +++ b/crates/types/src/game.rs @@ -70,6 +70,7 @@ pub struct GameInfo { pub is_live: bool, pub random_seed: i32, pub created_by: Option, + pub mask_player_names: bool, } #[derive(Debug, Clone)] @@ -85,9 +86,9 @@ pub struct LocalGameInfo { pub players: HashMap, pub slots: Vec, pub host_player: Option, + pub mask_player_names: bool, } - #[derive(Debug, S2ProtoEnum, PartialEq, Copy, Clone, Serialize)] #[s2_grpc(proto_enum_type = "flo_net::proto::flo_connect::GameStatus")] pub enum GameStatus {