From 87c082f87844f47dd6b057fc2458cee80002dc55 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 20:08:24 +0400 Subject: feat(control): replenish ammunition on repair pads --- crates/fparkan-runtime/src/player_weapon.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'crates/fparkan-runtime/src/player_weapon.rs') diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs index e9d748e6..347e0450 100644 --- a/crates/fparkan-runtime/src/player_weapon.rs +++ b/crates/fparkan-runtime/src/player_weapon.rs @@ -56,7 +56,7 @@ pub struct PlayerWeapon { deployment: Option, barrels: Vec, barrel_index: usize, - rounds_remaining: Option, + pub(super) rounds_remaining: Option, shot_hold_ms: f64, reload_ms: f64, phase: FirePhase, @@ -83,14 +83,14 @@ enum FirePhase { } impl PlayerWeapons { - /// Reads the authoritative Control charge before sampling this weapon bank. + /// Reads the authoritative Control charge and ammunition before firing. pub fn read_control_energy(&mut self, engine: &Engine, handle: crate::ObjectHandle) { if let Some(mission) = &engine.loaded { crate::mobile_budget::read(mission, handle, &mut self.weapons); } } - /// Publishes completed shots to Control before its next resource budget. + /// Publishes charge and ammunition consumed by completed shots to Control. pub fn publish_control_energy(&mut self, engine: &mut Engine, handle: crate::ObjectHandle) { if let Some(mission) = &mut engine.loaded { crate::mobile_budget::publish(mission, handle, &mut self.weapons); @@ -545,10 +545,8 @@ fn prepare_weapons( let rounds = f32::from_bits(record.fixed_words[11]).round_ties_even(); let rounds_remaining = if rounds == -1.0 { None - } else if (0.0..2_147_483_648.0).contains(&rounds) { - Some(rounds as u32) } else { - return None; + Some(crate::weapon_resupply::capacity(record.fixed_words[11])?) }; let effect_row = firing_effect_row(control, row); let effect_node = effect_row.and_then(|effect| { -- cgit v1.2.3