summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-28 17:22:17 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-28 17:22:17 +0100
commite37862758d66e4d4caa259e3b27ca4db04f7ce10 (patch)
treed70174dd43b309572d1d3e58a79a5c56687c34c3 /core/src/ch
parent4c6e80e4ee0cbc669a7fc160d19fa1eb8babd3fc (diff)
downloadRustAndDust-e37862758d66e4d4caa259e3b27ca4db04f7ce10.zip
RustAndDust-e37862758d66e4d4caa259e3b27ca4db04f7ce10.tar.gz
TileSet,Hex: do not crash callint iterator().next() when empty
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/TileSet.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java1
2 files changed, 2 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/TileSet.java b/core/src/ch/asynk/tankontank/engine/TileSet.java
index 07dc8ad..5a75b5d 100644
--- a/core/src/ch/asynk/tankontank/engine/TileSet.java
+++ b/core/src/ch/asynk/tankontank/engine/TileSet.java
@@ -18,6 +18,7 @@ public class TileSet extends LinkedHashSet<Tile> implements Board.TileCollection
public Tile first()
{
+ if (isEmpty()) return null;
return iterator().next();
}
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 77b8bfd..b357e56 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -47,6 +47,7 @@ public class Hex extends Tile
public Unit getUnit()
{
+ if (isEmpty()) return null;
return (Unit) iterator().next();
}