From 7361569a4f2f05ba4c97f276478e70b98c7da39a Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Tue, 1 Dec 2026 06:33:21 +0400 Subject: fix(combat): accept weapon CPT points with distinct metadata words Control.dll caches the node from CPT offset +4 at RVA 0xb210 and uses that node for the point and direction at RVA 0x1b4f0. A native call with the medium cannon's words 3 and 2 selected node 3. Rejecting those different words disabled the authored bb_m_02 cannon. The licensed regression finds the cannon in the stock medium warbot. Both enemy medium warbots fire in the normal-start input replay of Two Fortresses. The 29 stock missions still reach 900 simulated seconds. Rocket racks without resolved CPT lists remain outside the weapon bank. --- crates/fparkan-runtime/src/player_weapon.rs | 42 +++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'crates/fparkan-runtime/src') diff --git a/crates/fparkan-runtime/src/player_weapon.rs b/crates/fparkan-runtime/src/player_weapon.rs index a4d51c51..b966af9a 100644 --- a/crates/fparkan-runtime/src/player_weapon.rs +++ b/crates/fparkan-runtime/src/player_weapon.rs @@ -415,8 +415,6 @@ fn prepare_weapons( let muzzle = points.points.get(row.raw_parameters[1] as usize)?; let rate = f32::from_bits(row.raw_parameters[2]); if muzzle.raw_signed_field_04 < 0 - || (muzzle.raw_signed_field_08 != -1 - && muzzle.raw_signed_field_04 != muzzle.raw_signed_field_08) || !rate.is_finite() || rate <= 0.0 || row.flags & 1 != 0 @@ -552,6 +550,46 @@ pub(super) fn prepare_unit_weapons(controls: &[Option] mod tests { use super::*; + #[test] + #[ignore = "requires licensed corpus"] + fn licensed_medium_warbot_prepares_its_cannon_from_the_cpt_node() { + use crate::{ + create, load_gameplay_mission, EngineServices, MissionMode, MissionRequest, + MissionStartupInput, + }; + use fparkan_vfs::DirectoryVfs; + use std::sync::Arc; + + let root = std::env::var_os("FPARKAN_CORPUS_PART1_ROOT").expect("licensed corpus"); + let mut engine = create(EngineServices::new(Arc::new(DirectoryVfs::new(root)))).unwrap(); + load_gameplay_mission( + &mut engine, + MissionRequest { + key: "MISSIONS/Single.01/data.tma".into(), + mode: MissionMode::SingleMission, + }, + MissionStartupInput { + queue_time_ms: 0, + research_creation_gate: false, + }, + None, + ) + .unwrap(); + let (_, bank) = prepared_warbot_weapons(&engine) + .find(|(index, _)| *index == 12) + .expect("medium warbot"); + let cannon = bank + .weapons() + .iter() + .find(|weapon| weapon.projectile == "bb_m_02") + .expect("medium cannon"); + let point = &cannon.barrels[0].muzzle; + assert_eq!( + (point.raw_signed_field_04, point.raw_signed_field_08), + (3, 2) + ); + } + #[test] #[ignore = "requires licensed corpus"] fn licensed_constructor_deploys_cannon_before_firing() { -- cgit v1.2.3