aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
-rw-r--r--crates/fparkan-runtime/src/lib.rs10
1 files changed, 10 insertions, 0 deletions
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<u32>,
/// Factory-2 charge at native +0x120, initialized by the weapon reader.
pub weapon_charge_bits: Option<u32>,
+ /// Remaining finite ammunition at Control device offset +0x124.
+ pub weapon_rounds: Option<u32>,
/// 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,