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/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/fparkan-runtime/src/lib.rs') diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 970e8551..98592d6a 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -131,6 +131,7 @@ mod projectile_flight; mod projectile_parts; mod projectile_shield; mod weapon_deployment; +mod weapon_resupply; pub use projectile_shield::{ collect_shield_impacts, shield_effect_sources, take_shield_impacts, ShieldImpact, }; @@ -644,6 +645,8 @@ pub struct EffectiveControlDevice { pub device174_bits: Option, /// Factory-2 charge at native +0x120, initialized by the weapon reader. pub weapon_charge_bits: Option, + /// Remaining finite ammunition at Control device offset +0x124. + pub weapon_rounds: Option, /// Six class-9 budget values at native `+0x98..+0xac`. pub class9_values_bits: Option<[u32; 6]>, /// Six accumulated class-9 changes at native `+0xb0..+0xc4`. @@ -6543,6 +6546,9 @@ fn append_effective_control_device( tag26_extra_rate_bits: (descriptor.tag == 26).then_some(0), device174_bits: (descriptor.tag == 2).then_some(0), weapon_charge_bits: matches!(descriptor.tag, 2 | 30).then_some(coefficient_words[1]), + weapon_rounds: (descriptor.tag == 2) + .then(|| weapon_resupply::capacity(coefficient_words[0])) + .flatten(), class9_values_bits: (descriptor.tag == 9).then_some([0x3f80_0000; 6]), class9_deltas_bits: (descriptor.tag == 9).then_some([0; 6]), native_word_50_bits, @@ -6624,6 +6630,9 @@ fn apply_effective_control_override( if matches!(device.factory_tag, 2 | 30) { device.weapon_charge_bits = Some(coefficient_words[1]); } + if device.factory_tag == 2 && descriptor.tag == 2 { + device.weapon_rounds = weapon_resupply::capacity(coefficient_words[0]); + } if descriptor.fixed_words[6] != u32::MAX { device.native_word_50_bits = Some(descriptor.fixed_words[6]); } @@ -9306,6 +9315,7 @@ mod tests { tag26_extra_rate_bits: (factory_tag == 26).then_some(0), device174_bits: (factory_tag == 2).then_some(0), weapon_charge_bits: matches!(factory_tag, 2 | 30).then_some(coefficients[1]), + weapon_rounds: None, class9_values_bits: (factory_tag == 9).then_some([0x3f80_0000; 6]), class9_deltas_bits: (factory_tag == 9).then_some([0; 6]), native_word_50_bits, -- cgit v1.2.3