Skip to content

Commit

Permalink
Merge pull request #38 from w3champions/ffa-changes
Browse files Browse the repository at this point in the history
Disable `mutef` and `rtt` for FFA.
  • Loading branch information
fluxxu authored May 4, 2024
2 parents 9f96cf5 + effc560 commit 7e795de
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 16 deletions.
1 change: 1 addition & 0 deletions binaries/flo-cli/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down
5 changes: 3 additions & 2 deletions crates/client/src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LocalGameInfo> {
Ok(LocalGameInfo {
Ok(LocalGameInfo {
name: game.name.clone(),
game_id: game.id,
random_seed: game.random_seed,
Expand All @@ -25,5 +25,6 @@ pub fn local_game_from_game_info(player_id: i32, game: &GameInfo) -> Result<Loca
.collect(),
slots: game.slots.clone(),
host_player: game.created_by.clone(),
mask_player_names: game.mask_player_names,
})
}
}
1 change: 1 addition & 0 deletions crates/client/src/lan/diag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub async fn run_test_lobby(
is_live: false,
random_seed: 0,
created_by: None,
mask_player_names: false,
};

let info = LanGameInfo {
Expand Down
36 changes: 23 additions & 13 deletions crates/client/src/lan/game/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,26 @@ impl<'a> 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(
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/controller/src/game/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl S2ProtoPack<flo_net::proto::flo_connect::GameInfo> 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,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/net/src/proto/connect.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion crates/types/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ pub struct GameInfo {
pub is_live: bool,
pub random_seed: i32,
pub created_by: Option<PlayerInfo>,
pub mask_player_names: bool,
}

#[derive(Debug, Clone)]
Expand All @@ -85,9 +86,9 @@ pub struct LocalGameInfo {
pub players: HashMap<i32, PlayerInfo>,
pub slots: Vec<Slot>,
pub host_player: Option<PlayerInfo>,
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 {
Expand Down

0 comments on commit 7e795de

Please sign in to comment.