From 3a0eaa58be234cf9044c56bebcd0d68f5acad56e Mon Sep 17 00:00:00 2001 From: Sofia Date: Fri, 14 Aug 2026 23:30:26 +0300 Subject: [PATCH] Allow host_privileges to change map and teams --- rust/src/net/protocol.rs | 17 +++++++++++------ rust/src/ui/lobby.rs | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/rust/src/net/protocol.rs b/rust/src/net/protocol.rs index ae3799b..57d6a99 100644 --- a/rust/src/net/protocol.rs +++ b/rust/src/net/protocol.rs @@ -496,13 +496,12 @@ impl NetworkManager { } Package::SetTeam(player_id, team) => { if let Some(game) = &mut Game::singleton() { - let self_id = game - .bind() - .find_player_by_addr(&conn.address) - .map(|p| p.id()); - if let Some(self_id) = self_id { + let player = + game.bind().find_player_by_addr(&conn.address).cloned(); + if let Some(player) = player { if game.bind().opts.is_true(GameOption::AllowAnyTeam) - || self_id == player_id + || player.id() == player_id + || player.has_host_privileges { game.bind_mut().try_set_player_team(player_id, team); } @@ -511,8 +510,14 @@ impl NetworkManager { } Package::SelectMap(map_idx) => { if let Some(mut game) = Game::singleton() { + let player = + game.bind().find_player_by_addr(&conn.address).cloned(); if game.bind().opts.is_true(GameOption::AllowAnyMap) { game.bind_mut().change_map_selection(map_idx, false); + } else if let Some(player) = player + && player.has_host_privileges + { + game.bind_mut().change_map_selection(map_idx, false); } } } diff --git a/rust/src/ui/lobby.rs b/rust/src/ui/lobby.rs index 3380074..9a8b40f 100644 --- a/rust/src/ui/lobby.rs +++ b/rust/src/ui/lobby.rs @@ -130,8 +130,8 @@ impl IPanel for LobbyPanel { }); }); - let is_host = if let Some(peer) = &NetworkManager::singleton().bind().peer { - peer.is_host() + let is_host = if let Some(game) = &Game::singleton() { + game.bind().has_host_privileges() } else { false };