From 1db75b27cf23a8d5a6c1315de6a362e8bd9d09b2 Mon Sep 17 00:00:00 2001 From: Sofia Date: Mon, 3 Aug 2026 21:36:07 +0300 Subject: [PATCH] Fetch telegrenades allowed per team --- rust/src/game/mod.rs | 8 ++++++++ rust/src/game/opts.rs | 16 ++++++++++++++++ rust/src/player/local_player.rs | 5 ++++- rust/src/player/remote_player.rs | 5 ++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/rust/src/game/mod.rs b/rust/src/game/mod.rs index db4b808..9b91043 100644 --- a/rust/src/game/mod.rs +++ b/rust/src/game/mod.rs @@ -1427,6 +1427,14 @@ impl Game { None } } + + pub fn get_player_team(&self, player_id: u16) -> u8 { + if let Some(player) = self.find_player(player_id) { + player.data.team + } else { + 0 + } + } } #[derive(Clone, Debug)] diff --git a/rust/src/game/opts.rs b/rust/src/game/opts.rs index 2adb3c0..759bbe5 100644 --- a/rust/src/game/opts.rs +++ b/rust/src/game/opts.rs @@ -59,6 +59,22 @@ impl GameOptions { } } + pub fn is_team_true(&self, team: u8, opt: GameOption) -> bool { + if let Some(opts) = self.teams.get(team as usize) { + let opt = opts + .values + .get(&opt) + .copied() + .unwrap_or(GameOptionValue::Boolean(false)); + match opt { + GameOptionValue::Boolean(value) => value, + _ => false, + } + } else { + false + } + } + pub fn get_float(&self, opt: GameOption) -> f64 { let opt = self .values diff --git a/rust/src/player/local_player.rs b/rust/src/player/local_player.rs index 2fce198..597eb56 100644 --- a/rust/src/player/local_player.rs +++ b/rust/src/player/local_player.rs @@ -449,7 +449,10 @@ impl ICharacterBody3D for LocalPlayer { self.run_deferred(|s| { s.telegrenades_allowed = if let Some(game) = Game::singleton() { - game.bind().opts.is_true(GameOption::TelegrenadesAllowed) + game.bind().opts.is_team_true( + game.bind().get_player_team(s.player_id.unwrap_or(0)), + GameOption::TelegrenadesAllowed, + ) } else { false }; diff --git a/rust/src/player/remote_player.rs b/rust/src/player/remote_player.rs index 19a8d9f..13a7a40 100644 --- a/rust/src/player/remote_player.rs +++ b/rust/src/player/remote_player.rs @@ -380,7 +380,10 @@ impl ICharacterBody3D for RemotePlayer { self.run_deferred(|s| { s.telegrenades_allowed = if let Some(game) = Game::singleton() { - game.bind().opts.is_true(GameOption::TelegrenadesAllowed) + game.bind().opts.is_team_true( + game.bind().get_player_team(s.player_id.unwrap_or(0)), + GameOption::TelegrenadesAllowed, + ) } else { false };