Compare commits
2
Commits
be4459e19e
...
95655a0886
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95655a0886 | ||
|
|
5a2ac32071 |
No files matched your search
+8
-5
@@ -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]
|
||||
|
||||
+3
-1
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user