From f61cc5fd7dda6a76b843b36013795f52b03fae7e Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Sat, 14 Nov 2026 20:16:15 +0400 Subject: feat(script): evaluate scenario deadlines and timeout tests Handler(59) stores a DWORD deadline in Init or Mission. Handler(60) compares it strictly against the current scenario clock. The original ai.dll confirms overflow and the equality boundary. Mission 16 now reaches its scheduled message. --- crates/fparkan-runtime/src/mission_events.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'crates/fparkan-runtime/src/mission_events.rs') diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index c3b2af44..2226ebd5 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -141,6 +141,7 @@ impl MissionObjectives { #[derive(Default)] pub(super) struct MissionEvents { + pub(super) start_ms: u32, next_ms: u32, reported_stops: HashSet<(usize, usize)>, inside_hero_exit: bool, @@ -588,6 +589,7 @@ impl LoadedMissionState { .iter_mut() .find(|state| state.clan_index == bundle.clan_index)?; let mission_events = &mut self.mission_events; + let clock_seconds = crate::script_time::elapsed_seconds(mission_events.start_ms, now_ms); let mut notices = Vec::new(); let mut patrol_orders = Vec::new(); let execution = declarations.execute_mission_prefix( @@ -692,6 +694,16 @@ impl LoadedMissionState { .find_map(|handle| identity_metadata(world, handle).ok()?.owner_id); Ok(Some(clan.map_or(u32::MAX, |owner| u32::from(owner.0)))) } + ScriptDispatchSelector::Handler(59 | 60) => { + crate::script_time::result(instruction, values, clock_seconds) + .map(Some) + .ok_or_else(|| { + format!( + "{:?} requires one DWORD operand", + instruction.dispatch_selector() + ) + }) + } ScriptDispatchSelector::Handler(15) => { let order = declarations .resolve_handler15_with_values(instruction, values) -- cgit v1.2.3