aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src
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 /apps/fparkan-game/src
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 'apps/fparkan-game/src')
-rw-r--r--apps/fparkan-game/src/main.rs27
-rw-r--r--apps/fparkan-game/src/mission_pause.rs37
2 files changed, 40 insertions, 24 deletions
diff --git a/apps/fparkan-game/src/main.rs b/apps/fparkan-game/src/main.rs
index 72ee3c74..cc7061ae 100644
--- a/apps/fparkan-game/src/main.rs
+++ b/apps/fparkan-game/src/main.rs
@@ -8,6 +8,7 @@ mod control_effects;
use control_effects::{advance_control_effect_instances, owner_control_capacity};
mod mission_hints;
mod mission_notices;
+mod mission_pause;
mod player_collision;
mod projectile_trail;
mod script_coverage;
@@ -9984,6 +9985,7 @@ struct StaticVulkanApp {
simulation_last_tick: Instant,
live_clock_paused_for_zero_extent: bool,
mission_paused: bool,
+ mission_pause_started: Option<Instant>,
window_focused: bool,
last_presented_mission_scene: Option<SceneFrameUpdate>,
simulation_elapsed: Duration,
@@ -10127,6 +10129,7 @@ impl StaticVulkanApp {
simulation_last_tick: Instant::now(),
live_clock_paused_for_zero_extent: false,
mission_paused: false,
+ mission_pause_started: None,
window_focused: true,
last_presented_mission_scene: None,
simulation_elapsed: Duration::ZERO,
@@ -10872,30 +10875,6 @@ impl StaticVulkanApp {
}
}
- fn set_mission_paused_at(&mut self, paused: bool, now: Instant) {
- self.mission_paused = paused;
- self.player_mouse = [0.0; 2];
- self.player_move_pressed = Default::default();
- self.player_capture_pressed = false;
- self.player_select_friend_pressed = false;
- self.player_build_pressed = false;
- self.player_research_pressed = false;
- self.player_mine_pressed = false;
- self.player_disembark_pressed = false;
- if self.cockpit.is_some() && self.demo_camera.is_none() {
- self.set_mouse_look(self.window_focused && !paused);
- }
- self.simulation_last_tick = now;
- eprintln!(
- "mission_pause paused={paused} queue_time_ms={}",
- self.simulation_time_ms
- );
- self.update_mission_title();
- if let Some(audio) = self.audio.as_mut() {
- audio.set_paused(paused || !self.window_focused);
- }
- }
-
fn update_mission_title(&mut self) {
let Some(window) = &self.window else {
return;
diff --git a/apps/fparkan-game/src/mission_pause.rs b/apps/fparkan-game/src/mission_pause.rs
new file mode 100644
index 00000000..6e19161f
--- /dev/null
+++ b/apps/fparkan-game/src/mission_pause.rs
@@ -0,0 +1,37 @@
+use super::{Instant, StaticVulkanApp};
+
+impl StaticVulkanApp {
+ pub(super) fn set_mission_paused_at(&mut self, paused: bool, now: Instant) {
+ if paused {
+ self.mission_pause_started.get_or_insert(now);
+ } else if let Some(start) = self.mission_pause_started.take() {
+ if let Some(engine) = &mut self.mission_engine {
+ fparkan_runtime::note_mission_pause_elapsed(
+ engine,
+ now.saturating_duration_since(start).as_millis() as u32,
+ );
+ }
+ }
+ self.mission_paused = paused;
+ self.player_mouse = [0.0; 2];
+ self.player_move_pressed = Default::default();
+ self.player_capture_pressed = false;
+ self.player_select_friend_pressed = false;
+ self.player_build_pressed = false;
+ self.player_research_pressed = false;
+ self.player_mine_pressed = false;
+ self.player_disembark_pressed = false;
+ if self.cockpit.is_some() && self.demo_camera.is_none() {
+ self.set_mouse_look(self.window_focused && !paused);
+ }
+ self.simulation_last_tick = now;
+ eprintln!(
+ "mission_pause paused={paused} queue_time_ms={}",
+ self.simulation_time_ms
+ );
+ self.update_mission_title();
+ if let Some(audio) = self.audio.as_mut() {
+ audio.set_paused(paused || !self.window_focused);
+ }
+ }
+}