summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-10-29 17:40:30 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-10-29 17:40:30 +0100
commitf6829e0cf640248ec0de8c47f5224d7580da9bda (patch)
treee6037338902d342d2ab7a2bcd6fa95b3b70e7117 /core/src/ch/asynk
parentb8edcfe686b058796d7e77e96784145efc7112a4 (diff)
downloadRustAndDust-f6829e0cf640248ec0de8c47f5224d7580da9bda.zip
RustAndDust-f6829e0cf640248ec0de8c47f5224d7580da9bda.tar.gz
SearchBoard: fix possibleTargetsFrom()
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/SearchBoard.java34
1 files changed, 14 insertions, 20 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
index 6a1e6bb..9d251ac 100644
--- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
+++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
@@ -286,40 +286,34 @@ public class SearchBoard
queue.add(from);
- boolean first = true;
while (queue.size() != 0) {
Node src = queue.remove();
if (src.remaining <= 0)
continue;
- if (!first && (((range - src.remaining) % 2) == 0))
+ if (((range - src.remaining) % 2) == 1)
adjacentTargets(src, extendedAngle, adjacents);
else
adjacentTargets(src, angle, adjacents);
- first = false;
int rangeLeft = src.remaining - 1;
for(int i = 0; i < 6; i++) {
Node dst = adjacents[i];
- if (dst != null) {
- if (dst.search == searchCount) {
- if ((rangeLeft > dst.remaining))
- dst.remaining = rangeLeft;
- } else {
- dst.search = searchCount;
- dst.remaining = rangeLeft;
- queue.add(dst);
- Tile t = getTile(dst);
- if (hasClearLineOfSight(from, dst, angle)) {
- Iterator<Pawn> it = t.iterator();
- while (it.hasNext()) {
- Pawn target = it.next();
- if (shooter.canEngage(target))
- targets.add(target);
- }
- }
+ if ((dst == null) || (dst.search == searchCount))
+ continue;
+
+ dst.search = searchCount;
+ dst.remaining = rangeLeft;
+ queue.add(dst);
+ Tile t = getTile(dst);
+ if (!t.isEmpty() && hasClearLineOfSight(from, dst, angle)) {
+ Iterator<Pawn> it = t.iterator();
+ while (it.hasNext()) {
+ Pawn target = it.next();
+ if (shooter.canEngage(target))
+ targets.add(target);
}
}
}