aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/mission_events.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-14 19:16:15 +0300
committerValentin Popov <valentin@popov.link>2026-11-14 19:16:15 +0300
commitf61cc5fd7dda6a76b843b36013795f52b03fae7e (patch)
tree89836bc276b7f81430feddc3da949cc1a28f3538 /crates/fparkan-runtime/src/mission_events.rs
parent38cd46123518136222473662df409f78cc63584b (diff)
downloadfparkan-f61cc5fd7dda6a76b843b36013795f52b03fae7e.tar.xz
fparkan-f61cc5fd7dda6a76b843b36013795f52b03fae7e.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/mission_events.rs')
-rw-r--r--crates/fparkan-runtime/src/mission_events.rs12
1 files changed, 12 insertions, 0 deletions
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)