diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 13:02:42 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 13:02:42 +0300 |
| commit | 059d891d187a0fc5b79916b00ae5163aa1c259a6 (patch) | |
| tree | f1b1b8b4ff4f0d8848e9b83fc9212db9f6d35b1d /crates | |
| parent | 1b7a5a9c149270e9046a86590e7d0d62116eec5f (diff) | |
| download | fparkan-059d891d187a0fc5b79916b00ae5163aa1c259a6.tar.xz fparkan-059d891d187a0fc5b79916b00ae5163aa1c259a6.zip | |
fix(runtime): capture the main teleport from the communicator floor
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/fparkan-runtime/src/lib.rs | 28 | ||||
| -rw-r--r-- | crates/fparkan-runtime/src/mission_events.rs | 6 |
2 files changed, 32 insertions, 2 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs index 483ffb71..f0be9bad 100644 --- a/crates/fparkan-runtime/src/lib.rs +++ b/crates/fparkan-runtime/src/lib.rs @@ -18039,6 +18039,34 @@ mod tests { after.notices.contains(&MissionNotice::ObjectiveComplete(0)), "{after:?}" ); + for (time, slot, objective, plate) in [ + (4_001, 4, 1, [750.0_f32, 950.7, 45.88]), + (6_001, 5, 2, [950.7, 869.4, 69.98]), + (8_001, 3, 4, [1179.28, 1242.12, 101.60]), + ] { + if slot == 3 { + pose.position = [plate[0], plate[1], 110.28].map(f32::to_bits); + set_transform(&mut engine.world, cockpit.handle, pose).unwrap(); + assert_eq!( + capture_neutral_building(&mut engine, cockpit).unwrap(), + None + ); + } + pose.position = plate.map(f32::to_bits); + set_transform(&mut engine.world, cockpit.handle, pose).unwrap(); + assert_eq!( + capture_neutral_building(&mut engine, cockpit).unwrap(), + Some(OriginalObjectId(slot)), + ); + let event = frame(&mut engine, time).unwrap().mission_event.unwrap(); + assert!(event.stop.is_none(), "{event:?}"); + assert!( + event + .notices + .contains(&MissionNotice::ObjectiveComplete(objective)), + "{event:?}" + ); + } } #[test] diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index 8e420e4f..61624135 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -17,6 +17,7 @@ use fparkan_world::{ use std::collections::HashSet; const MOBILE_HQ_CLASS: u32 = 0x0101_0000; +const MAIN_TELEPORT_CLASS: u32 = 0x8000_0200; /// First encounter with an uncovered periodic script instruction. #[derive(Clone, Debug, Eq, PartialEq)] @@ -368,6 +369,7 @@ pub(super) fn on_communicator( [x, y, z]: [f32; 3], ) -> bool { let is_generator = class == 0x8000_0002; + let floor_only = is_generator || class == MAIN_TELEPORT_CLASS; let material = if is_generator { &b"B_MTP_07G"[..] } else { @@ -432,8 +434,8 @@ pub(super) fn on_communicator( transform.try_transform_scaled_point(pose.transform_point(local), scale) }); let (a, b, c) = (a?, b?, c?); - if is_generator { - // The generator also uses this material on the underside. + if floor_only { + // These models use the platform material on both the floor and the surface above it. let winding = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); if winding <= 0.0 { return None; |
