aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 05:53:50 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 05:53:50 +0300
commit204223a2b3900f3be981942ecde81ec7475f440c (patch)
tree3801cae210fa1d5579571f25d56497ac53e27af2 /crates
parent7361569a4f2f05ba4c97f276478e70b98c7da39a (diff)
downloadfparkan-204223a2b3900f3be981942ecde81ec7475f440c.tar.xz
fparkan-204223a2b3900f3be981942ecde81ec7475f440c.zip
fix(combat): load CPT launch points for rocket racks
Read the component's authored CPT when its weapon records reference firing rows. The stock medium and heavy racks have no muzzle flash row, but their 16 and 9 launch points belong to the weapon cycle. The licensed battery test verifies both rack layouts. A runtime replay from the stock Two Fortresses start records heavy rocket launches from the restored racks. All 29 stock missions reach 900 simulation seconds.
Diffstat (limited to 'crates')
-rw-r--r--crates/fparkan-assets/src/lib.rs8
-rw-r--r--crates/fparkan-runtime/src/player_weapon.rs21
2 files changed, 26 insertions, 3 deletions
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs
index 51270eca..d98bff3d 100644
--- a/crates/fparkan-assets/src/lib.rs
+++ b/crates/fparkan-assets/src/lib.rs
@@ -1059,7 +1059,7 @@ pub struct PreparedComponentControl {
pub node_effect_links: Vec<(usize, u32, u32)>,
/// Changes to the clocks of existing effect instances, from opcode 10.
pub effect_modes: Vec<PreparedControlEffectMode>,
- /// Component-local points selected for parsed effect rows, when present.
+ /// Component-local points used by weapons and effect rows, when present.
pub point_list: Option<PreparedControlPointList>,
}
@@ -3668,7 +3668,11 @@ fn prepare_component_control_from_resource<R: ResourceRepository>(
&control.effect_section,
PreparedControlEffectSection::Parsed(rows) if rows.iter().any(|row| row.opcode == 4)
);
- let Some(point_source) = point_source.filter(|_| has_effect_rows) else {
+ let has_weapon_points = control
+ .typed_records
+ .iter()
+ .any(|record| record.tag == 2 && !record.values.is_empty());
+ let Some(point_source) = point_source.filter(|_| has_effect_rows || has_weapon_points) else {
return Ok(Some(control));
};
let Some(point_payload) =
diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs
index b966af9a..db24036b 100644
--- a/crates/fparkan-runtime/src/player_weapon.rs
+++ b/crates/fparkan-runtime/src/player_weapon.rs
@@ -552,7 +552,7 @@ mod tests {
#[test]
#[ignore = "requires licensed corpus"]
- fn licensed_medium_warbot_prepares_its_cannon_from_the_cpt_node() {
+ fn licensed_fortress_warbots_prepare_their_authored_cpt_weapons() {
use crate::{
create, load_gameplay_mission, EngineServices, MissionMode, MissionRequest,
MissionStartupInput,
@@ -588,6 +588,25 @@ mod tests {
(point.raw_signed_field_04, point.raw_signed_field_08),
(3, 2)
);
+
+ for (index, projectile, tube_count) in [(12, "br_l_01", 16), (14, "br_b_01", 9)] {
+ let (_, bank) = prepared_warbot_weapons(&engine)
+ .find(|(unit, _)| *unit == index)
+ .expect("warbot with rocket racks");
+ let racks: Vec<_> = bank
+ .weapons()
+ .iter()
+ .filter(|weapon| weapon.projectile == projectile)
+ .collect();
+ assert_eq!(racks.len(), 2, "warbot {index}");
+ for rack in racks {
+ assert_eq!(rack.barrels.len(), tube_count);
+ assert_eq!(rack.rounds_remaining(), Some(tube_count as u32));
+ assert!(rack.barrels.iter().enumerate().all(|(i, tube)| {
+ tube.row.raw_parameters[1] == i as u32 && tube.muzzle.raw_signed_field_04 == 1
+ }));
+ }
+ }
}
#[test]