From 5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 4 Jan 2016 16:09:33 +0100 Subject: PathIterator: support simple rotation --- core/src/ch/asynk/rustanddust/engine/PathIterator.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/PathIterator.java b/core/src/ch/asynk/rustanddust/engine/PathIterator.java index 7feb550..a3667b4 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathIterator.java +++ b/core/src/ch/asynk/rustanddust/engine/PathIterator.java @@ -33,7 +33,8 @@ public class PathIterator implements Iterator @Override public boolean hasNext() { - if ((i > path.size()) && (o == orientation)) + int s = path.size(); + if (((s == 0) || (i > s)) && (o == orientation)) return false; return true; } @@ -44,13 +45,15 @@ public class PathIterator implements Iterator if (!hasNext()) throw new java.util.NoSuchElementException(); - if (i > path.size()) { + int s = path.size(); + + if ((s == 0) || (i >s)) { v.z = orientation.r(); o = orientation; return v; } Tile nextTile; - if (i < path.size()) + if (i < s) nextTile = path.get(i); else nextTile = to; -- cgit v1.1-2-g2b99