From 39af89adf75d3ca59a349254d5f87c25d1980db0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 29 Oct 2015 10:32:37 +0100 Subject: SearchBoard: simplify clearVisibility logic --- core/src/ch/asynk/rustanddust/engine/SearchBoard.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java index 9ca9f5d..6f7ad2f 100644 --- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java +++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java @@ -484,18 +484,18 @@ public class SearchBoard Tile t = null; los.add(getNode(x, y)); while((x != x1) || (y != y1)) { - boolean ok = false; + boolean ok = !clearVisibility; y += d; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!clearVisibility || !t.blockLineOfSightFrom(from)) + if (!ok && !t.blockLineOfSightFrom(from)) ok = true; x += d; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!clearVisibility || !t.blockLineOfSightFrom(from)) + if (!ok && !t.blockLineOfSightFrom(from)) ok = true; if (!ok) @@ -523,12 +523,12 @@ public class SearchBoard Tile t = null; los.add(getNode(x, y)); while((x != x1) || (y != y1)) { - boolean ok = false; + boolean ok = !clearVisibility; x += dx; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!clearVisibility || !t.blockLineOfSightFrom(from)) + if (!ok && !t.blockLineOfSightFrom(from)) ok = true; y += dy; @@ -536,7 +536,7 @@ public class SearchBoard x -= dx; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!clearVisibility || !t.blockLineOfSightFrom(from)) + if (!ok && !t.blockLineOfSightFrom(from)) ok = true; if (!ok) -- cgit v1.1-2-g2b99