From 0d8031eccad92190ea01c2c7f9a2cee28adecb62 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 06:49:08 +0400 Subject: fix(ui): validate warbot designs on transfer Keep the selected model open on a failed research check and post the original central-computer message to the shared pager and history. Verified rejection and corrected production order in the Field Camp window with Vulkan validation. --- apps/fparkan-game/src/mission_hints.rs | 75 ++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 26 deletions(-) (limited to 'apps/fparkan-game/src/mission_hints.rs') diff --git a/apps/fparkan-game/src/mission_hints.rs b/apps/fparkan-game/src/mission_hints.rs index 47ecc25c..f9713335 100644 --- a/apps/fparkan-game/src/mission_hints.rs +++ b/apps/fparkan-game/src/mission_hints.rs @@ -15,11 +15,15 @@ const WIDTH: u16 = 640; const HEIGHT: u16 = 384; const UV: [[f32; 2]; 4] = [[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0]]; const PAGER_DURATION_MS: u32 = 20_000; +const CENTRAL_COMPUTER: u32 = 0x605; const INSTRUCTOR: u32 = 0x0bf1; const INFORMATION_SYSTEM: u32 = 0x1846; pub(super) struct MissionHints { messages: Option, + sender_strings: Option, + pager: Option, + overflow_hint: String, range: EnvironmentGpuRange, pending: Option, active: Option, @@ -50,9 +54,6 @@ struct MessageResources { config: Arc<[u8]>, catalog: Arc<[u8]>, strings: StringResources, - sender_strings: Option, - pager: MissionPager, - overflow_hint: String, } impl MissionHints { @@ -69,6 +70,24 @@ impl MissionHints { eprintln!("sim_coverage mission_text_unavailable=1 reason={error}"); None }); + let sender_strings = match StringResources::open(&root.join("iron3d.dll")) { + Ok(strings) => Some(strings), + Err(error) => { + eprintln!("sim_coverage mission_text_unavailable=1 resource=iron3d.dll field=sender reason={error}"); + None + } + }; + let overflow_hint = sender_strings + .as_ref() + .and_then(|strings| strings.get(0x1840)) + .map(|text| text.replace("%s", "F1")) + .unwrap_or_default(); + let pager = MissionPager::load(&DirectoryVfs::new(root)) + .map(Some) + .unwrap_or_else(|error| { + eprintln!("sim_coverage mission_text_unavailable=1 reason={error}"); + None + }); eprintln!("sim_coverage mission_outcome_display_approx=1"); let material = append_environment_gradient_material(&mut preview.materials)?; preview.materials[material].screen_tl = true; @@ -85,6 +104,9 @@ impl MissionHints { // Keep the degenerate reservation until the renderer receives live caption vertices. Ok(Self { messages, + sender_strings, + pager, + overflow_hint, range, pending: None, active: None, @@ -114,20 +136,38 @@ impl MissionHints { .filter(|text| !text.trim().is_empty()) .ok_or_else(|| format!("missing string {id} for {symbol}"))?; let sender_id = sender_resource_id(&fields); - let sender = messages + let sender = self .sender_strings .as_ref() .and_then(|strings| strings.get(sender_id)); if sender.is_none() { eprintln!("sim_coverage mission_text_unavailable=1 sender={sender_id} index={index}"); } + Ok(self.enqueue(index, sender.unwrap_or_default(), body, clock)) + } + + pub(super) fn post_computer(&mut self, id: u32, clock: u32) -> Result<(&str, &str), String> { + let strings = self + .sender_strings + .as_ref() + .ok_or("missing iron3d.dll strings")?; + let sender = strings + .get(CENTRAL_COMPUTER) + .ok_or("missing central computer caption")?; + let body = strings + .get(id) + .ok_or_else(|| format!("missing iron3d.dll string {id:#06x}"))?; + Ok(self.enqueue(id, sender, body, clock)) + } + + fn enqueue(&mut self, index: u32, sender: String, body: String, clock: u32) -> (&str, &str) { let pending = self.pending.insert(PagerMessage { index, - sender: sender.unwrap_or_default(), + sender, body, posted_ms: clock, }); - Ok((&pending.sender, &pending.body)) + (&pending.sender, &pending.body) } pub(super) fn toggle_current(&mut self) { @@ -165,14 +205,12 @@ impl MissionHints { .map_err(|error| error.to_string()); } self.outcome = None; - if let Some(message) = self.pending.take() { + if let (Some(message), Some(pager)) = (self.pending.take(), &self.pager) { self.active = None; if pager_visible(message.posted_ms, clock) { let index = message.index; - let resources = self.messages.as_ref().expect("posted message resources"); - let (extent, bounds, texture) = match resources - .pager - .paint(&message.sender, &message.body, &resources.overflow_hint) + let (extent, bounds, texture) = match pager + .paint(&message.sender, &message.body, &self.overflow_hint) .and_then(|(image, bounds)| { Ok(([image.width, image.height], bounds, panel_texture(image)?)) }) { @@ -282,26 +320,11 @@ impl MessageResources { let library = normalize_relative(library.as_bytes(), PathPolicy::StrictLegacy) .map_err(|error| error.to_string())?; let strings = StringResources::open(&root.join(library.as_str()))?; - let sender_strings = match StringResources::open(&root.join("iron3d.dll")) { - Ok(strings) => Some(strings), - Err(error) => { - eprintln!("sim_coverage mission_text_unavailable=1 resource=iron3d.dll field=sender reason={error}"); - None - } - }; eprintln!("sim_coverage mission_text_display_approx=1"); - let overflow_hint = sender_strings - .as_ref() - .and_then(|strings| strings.get(0x1840)) - .map(|text| text.replace("%s", "F1")) - .unwrap_or_default(); Ok(Some(Self { config, catalog, strings, - sender_strings, - pager: MissionPager::load(&vfs)?, - overflow_hint, })) } } -- cgit v1.2.3