aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/player_weapon.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 05:33:21 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 05:33:21 +0300
commit7361569a4f2f05ba4c97f276478e70b98c7da39a (patch)
tree95fd6f9e4a9486e8d3da750fa3c33feb3df9f74b /crates/fparkan-runtime/src/player_weapon.rs
parentbe3b214702693eab36da4484624327d2cad8beec (diff)
downloadfparkan-7361569a4f2f05ba4c97f276478e70b98c7da39a.tar.xz
fparkan-7361569a4f2f05ba4c97f276478e70b98c7da39a.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/player_weapon.rs')
-rw-r--r--crates/fparkan-runtime/src/player_weapon.rs42
1 files changed, 40 insertions, 2 deletions
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
@@ -554,6 +552,46 @@ mod tests {
#[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() {
use crate::{
create, initial_component_node_times, load_gameplay_mission, loaded_mission_assets,