summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:09:33 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-04 16:09:33 +0100
commit5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2 (patch)
tree9c10976b0f4850f8aa3142d9f5c16f595d223e79 /core/src
parent98dd87bc85fd0962efbfc861e762e9c3549b2ee5 (diff)
downloadRustAndDust-5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2.zip
RustAndDust-5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2.tar.gz
PathIterator: support simple rotation
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/PathIterator.java9
1 files 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<Vector3>
@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<Vector3>
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;