aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-01 21:08:37 +0300
committerValentin Popov <valentin@popov.link>2026-12-01 21:08:37 +0300
commit501779c19f5a86f0035683840f176d371abafc27 (patch)
tree376b8b41a3668233b8d051badc9f3f2171d3f756 /crates/fparkan-runtime
parentd154efdd050e730c4072e5f53843cf3610651d00 (diff)
downloadfparkan-501779c19f5a86f0035683840f176d371abafc27.tar.xz
fparkan-501779c19f5a86f0035683840f176d371abafc27.zip
fix(script): return the registered ID of a produced capturer
The Mission handler now resolves the eligible warbot through the shared logical ID lookup. The original handler returns the registered roster ID. The Teleport regression reproduces the former stop with a newly registered eligible candidate, and the unmodified mission starts in the game window.
Diffstat (limited to 'crates/fparkan-runtime')
-rw-r--r--crates/fparkan-runtime/src/mission_events.rs85
1 files changed, 79 insertions, 6 deletions
diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs
index a017eada..8a6f3592 100644
--- a/crates/fparkan-runtime/src/mission_events.rs
+++ b/crates/fparkan-runtime/src/mission_events.rs
@@ -890,13 +890,10 @@ impl LoadedMissionState {
if !capturer_chassis(&chassis.resource_raw) {
continue;
}
- // shortcut: native logical IDs for newly produced robots are still open.
- let object = self
- .mission
- .objects
- .get(index)
+ let id = mission_events
+ .logic_id(&self.mission, world, handle)
.ok_or("Handler(13) dynamic capturer logical ID is unavailable")?;
- return Ok(Some(object.identity_or_clan_raw));
+ return Ok(Some(id));
}
Ok(Some(u32::MAX))
}
@@ -1135,6 +1132,82 @@ mod tests {
};
#[test]
+ #[ignore = "requires licensed corpus"]
+ fn licensed_teleport_mission_accepts_a_newly_registered_capturer() {
+ use crate::{
+ create, load_gameplay_mission, EngineServices, MissionMode, MissionRequest,
+ MissionStartupInput,
+ };
+ use fparkan_script::VarSetDefault;
+ use fparkan_vfs::DirectoryVfs;
+ use fparkan_world::OriginalObjectId;
+ 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/CAMPAIGN/CAMPAIGN.00/Mission.04/data.tma".into(),
+ mode: MissionMode::SingleMission,
+ },
+ MissionStartupInput {
+ queue_time_ms: 0,
+ research_creation_gate: false,
+ },
+ None,
+ )
+ .unwrap();
+ let loaded = engine.loaded.as_mut().unwrap();
+ let roster = &mut loaded.mission_events;
+ let mut draft = loaded
+ .object_drafts
+ .iter()
+ .find(|draft| {
+ draft.identity_or_clan_raw == 3
+ && draft.unit_dat_header_flags == Some(crate::boarding::WARBOT_CLASS)
+ })
+ .unwrap()
+ .clone();
+ roster.reserved_units.extend(
+ roster
+ .placed_clan_objects
+ .iter()
+ .map(|&(handle, _)| (0, handle)),
+ );
+ // Add a candidate with the same chassis through the runtime's dynamic roster.
+ draft.original_id = Some(OriginalObjectId(loaded.object_drafts.len() as u32));
+ let handle = construct_object(
+ &mut engine.world,
+ ObjectDraft {
+ original_id: draft.original_id,
+ },
+ )
+ .unwrap();
+ loaded.object_drafts.push(draft);
+ set_owner(&mut engine.world, handle, Some(OwnerId(0))).unwrap();
+ register_object(&mut engine.world, handle).unwrap();
+ roster.register_unit(&engine.world, handle, crate::boarding::WARBOT_CLASS);
+ let id = roster.issue_logic_id(&loaded.mission, &engine.world, handle);
+
+ let tick = loaded.tick_mission_event(&engine.world, 1).unwrap();
+ assert!(tick.stop.is_none(), "{tick:?}");
+ let temp = loaded
+ .script_varset
+ .as_ref()
+ .unwrap()
+ .declarations
+ .declarations
+ .iter()
+ .position(|entry| entry.name == "dTemp")
+ .unwrap();
+ assert_eq!(
+ loaded.script_varset_states[0].values[temp],
+ VarSetDefault::Dword(id)
+ );
+ }
+
+ #[test]
fn free_unit_selection_skips_busy_reserved_foreign_and_removed_entries() {
let mission = crate::MissionDocument {
format_version: 1,