aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/mission_events.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-11-25 19:47:00 +0300
committerValentin Popov <valentin@popov.link>2026-11-25 19:47:00 +0300
commitc63fadd7c2aa0e0d9f81f65aa88ef9fe905e76e3 (patch)
tree613b4a92373fb637ee491a19babaa4726bd57fda /crates/fparkan-runtime/src/mission_events.rs
parent5cc5602b3fa42e5864d205a1c42c895504038b10 (diff)
downloadfparkan-c63fadd7c2aa0e0d9f81f65aa88ef9fe905e76e3.tar.xz
fparkan-c63fadd7c2aa0e0d9f81f65aa88ef9fe905e76e3.zip
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.
Diffstat (limited to 'crates/fparkan-runtime/src/mission_events.rs')
-rw-r--r--crates/fparkan-runtime/src/mission_events.rs19
1 files changed, 17 insertions, 2 deletions
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)));
+ }
}