From c63fadd7c2aa0e0d9f81f65aa88ef9fe905e76e3 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 25 Nov 2026 20:47:00 +0400 Subject: fix(ai): age script deadlines while the world is paused Record paused wall time separately from simulation time. After resuming, Mission and clan AI check their expired deadlines once, then schedule the next interval without replaying missed cycles. Move application pause handling into its own module and retain frozen world, animation and audio. Live ai.dll timer calls confirm that Mission runs before the paused world clock refreshes and the next AI callback uses an already expired deadline. Record the unresolved AutoDemo sphere and first-projectile boundaries. Validation: workspace fmt/check/tests, release build, licensed stock-clock pause test, all 29 missions at --sim-report 900 without script stops, and a stock mission-28 window with a 33-second pause and unchanged world time. Full AI chronology and minimized-window timing remain open. --- crates/fparkan-runtime/src/mission_events.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (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 e8da353c..b200d0b9 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -779,11 +779,13 @@ impl LoadedMissionState { let inside_exit = exit_event.is_some() && self.hero_in_teleport_exit(world); let entered_exit = inside_exit && !self.mission_events.inside_hero_exit; self.mission_events.inside_hero_exit = inside_exit; - // shortcut: dispatch Mission on the shared 2 s queue timer until its native cadence is wired. let (event_index, event) = if entered_exit && self.script_outcome == super::MissionScriptOutcome::Active { exit_event? - } else if self.mission_events.due(now_ms) { + } else if self + .mission_events + .due(self.clan_ai_events.wall_time_ms(now_ms)) + { events.find(|(_, event)| { event.name_raw.split(|byte| *byte == 0).next() == Some(b"Mission") })? @@ -1364,4 +1366,17 @@ mod tests { assert!(!events.due(12_122)); assert!(events.due(12_123)); } + + #[test] + fn mission_timer_is_due_after_a_long_pause_without_advancing_the_world_clock() { + let mut events = MissionEvents::default(); + let mut clocks = crate::clan_ai_events::ClanAiEvents::default(); + assert!(events.due(clocks.wall_time_ms(0))); + assert!(!events.due(clocks.wall_time_ms(500))); + clocks.add_paused_time(22_300); + assert!(events.due(clocks.wall_time_ms(500))); + assert!(!events.due(clocks.wall_time_ms(500))); + assert!(!events.due(clocks.wall_time_ms(2_499))); + assert!(events.due(clocks.wall_time_ms(2_500))); + } } -- cgit v1.2.3