From 5a2ac320712554337374603b89297ebffa75bb17 Mon Sep 17 00:00:00 2001 From: Richard Zink Date: Fri, 6 Nov 2026 13:12:41 +0100 Subject: [PATCH] Command markers only with the debug setting; removing a marker clears them at once Co-Authored-By: Claude Opus 5.5 --- src/commands.rs | 13 ++++++++----- src/game.rs | 4 +++- src/orders.rs | 2 ++ src/render3d.rs | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index 2fc645c..150bb4d 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -288,7 +288,7 @@ mod tests { } #[test] - fn fixed_order_flags_do_not_need_the_debug_marker_setting() { + fn command_markers_only_show_with_the_debug_setting() { let mut g = game(13); g.debug_markers = false; let (cx, cy) = g.map.core; @@ -296,10 +296,13 @@ mod tests { g.queue(Act::Guard { x: cx, y: cy }); g.queue(Act::Attack { ent: None, x: (cx + 20) as f32, y: (cy + 20) as f32 }); g.queue(Act::Flag { x: cx, y: cy }); - assert!(!g.marks.iter().any(|m| m.kind == MARK_DIG), "dig stays hidden without debug markers"); - assert!(g.marks.iter().any(|m| m.kind == MARK_GUARD && m.fixed), "guard is fixed"); - assert!(g.marks.iter().any(|m| m.kind == MARK_ATTACK && m.fixed), "attack is fixed"); - assert!(g.marks.iter().any(|m| m.kind == MARK_FLAG && m.fixed), "gather flag is fixed"); + assert!(g.marks.is_empty(), "the real shields, swords and flags show the orders"); + // with the setting on they show, and removing a marker takes them away + g.debug_markers = true; + g.queue(Act::Guard { x: cx + 2, y: cy + 2 }); + assert!(g.marks.iter().any(|m| m.kind == MARK_GUARD)); + g.unmark(cx as f32 + 2.5, cy as f32 + 2.5); + assert!(!g.marks.iter().any(|m| m.kind == MARK_GUARD), "gone with the marker"); } #[test] diff --git a/src/game.rs b/src/game.rs index 9d312e6..f814018 100644 --- a/src/game.rs +++ b/src/game.rs @@ -4316,7 +4316,9 @@ impl Game { } pub fn add_mark(&mut self, x: f32, y: f32, kind: u8, side: u8, duration: f32, fixed: bool) { - if (!fixed && !self.debug_markers) || duration <= 0.0 || !x.is_finite() || !y.is_finite() { + // the shields, swords and the flag show themselves; these markers are for debugging only + let _ = fixed; + if !self.debug_markers || duration <= 0.0 || !x.is_finite() || !y.is_finite() { return; } let until = self.sim_steps + (duration / STEP).ceil() as u64; diff --git a/src/orders.rs b/src/orders.rs index cfe3132..3624552 100644 --- a/src/orders.rs +++ b/src/orders.rs @@ -109,6 +109,8 @@ impl Game { // a right click with an order tool: the marker there goes (its creatures are free again); // without a marker there the guards stand down pub fn unmark(&mut self, wx: f32, wy: f32) { + // the command markers there go with it + self.marks.retain(|m| (m.x - wx).powi(2) + (m.y - wy).powi(2) >= 2.0 * 2.0); let near = |m: &usize| { let (mx, my) = xy(*m); (mx as f32 + 0.5 - wx).powi(2) + (my as f32 + 0.5 - wy).powi(2) < 1.6 * 1.6 diff --git a/src/render3d.rs b/src/render3d.rs index 1ccac15..2c8b43e 100644 --- a/src/render3d.rs +++ b/src/render3d.rs @@ -2908,7 +2908,7 @@ fn draw_marks(g: &Game, t: f32) { return; } for m in &g.marks { - if !m.fixed && !g.debug_markers { + if !g.debug_markers { continue; } let left = m.until.saturating_sub(g.sim_steps) as f32 * STEP;