aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/lib.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 07:33:51 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 07:33:51 +0300
commit777f48345c7faf891ac105fc4a831114914aff5d (patch)
treea9e550c582aa976d87e6c0ae4297e7c29e6e5526 /crates/fparkan-runtime/src/lib.rs
parent352026c1ce039443efc779876b27654d992bfff1 (diff)
downloadfparkan-777f48345c7faf891ac105fc4a831114914aff5d.tar.xz
fparkan-777f48345c7faf891ac105fc4a831114914aff5d.zip
fix(combat): charge the drive before refilling weapons
Read the resource multiplier from CTL when all authored states agree and price the latest local motion in the existing Control budget. A licensed AutoDemo flyer charges its weapons more slowly when the drive is drawing from the same supply. Control.dll oracle vectors, the AutoDemo window, and all 29 mission startup sweeps pass.
Diffstat (limited to 'crates/fparkan-runtime/src/lib.rs')
-rw-r--r--crates/fparkan-runtime/src/lib.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 5f3f436e..0ac5197f 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -4496,10 +4496,18 @@ fn control_resource_budget_pass(
table: &mut MissionControlDeviceTableState,
delta_time_seconds: f32,
) -> Result<(), ControlResourceAccessError> {
+ control_resource_budget_pass_with_motion(table, delta_time_seconds, None)
+}
+
+fn control_resource_budget_pass_with_motion(
+ table: &mut MissionControlDeviceTableState,
+ delta_time_seconds: f32,
+ motion: Option<mobile_budget::DriveMotion>,
+) -> Result<(), ControlResourceAccessError> {
let delta_time_seconds =
checked_control_float(0, "Control resource interval", delta_time_seconds)?;
let mut updated = table.clone();
- control_resource_budget_pass_inner(&mut updated, delta_time_seconds)?;
+ control_resource_budget_pass_inner(&mut updated, delta_time_seconds, motion)?;
*table = updated;
Ok(())
}
@@ -4507,6 +4515,7 @@ fn control_resource_budget_pass(
fn control_resource_budget_pass_inner(
table: &mut MissionControlDeviceTableState,
delta_time_seconds: f32,
+ motion: Option<mobile_budget::DriveMotion>,
) -> Result<(), ControlResourceAccessError> {
let device_count = match &table.status {
MissionControlDeviceTableStatus::Available(devices) => devices.len(),
@@ -4534,7 +4543,12 @@ fn control_resource_budget_pass_inner(
let mut positive_rate_sum = 0.0_f32;
for index in 0..device_count {
let device = control_budget_device(table, index)?;
- let rate = control_device_resource_rate(table, &device, delta_time_seconds)?;
+ let rate = match motion {
+ Some(motion) if device.factory_tag == 5 => {
+ motion.rate(table, device, delta_time_seconds)?
+ }
+ _ => control_device_resource_rate(table, device, delta_time_seconds)?,
+ };
if rate > 0.0 {
positive_rate_sum = checked_control_sum(
device.factory_tag,
@@ -8381,6 +8395,7 @@ mod tests {
PreparedComponentControl {
source: synthetic_resource_key(940),
native_profile_words: [0; 27],
+ uniform_drive_factor_bits: None,
model_node_count: 3,
bindings: Vec::new(),
timeline_rows: Vec::new(),
@@ -8888,6 +8903,7 @@ mod tests {
PreparedComponentControl {
source: synthetic_resource_key(100 + index),
native_profile_words: [0; 27],
+ uniform_drive_factor_bits: None,
model_node_count: 0,
bindings: Vec::new(),
timeline_rows: Vec::new(),