From a06feaa0ca872f73c1a6a57622e227a4d0ac7f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bokros=20B=C3=A1lint?= Date: Tue, 29 Mar 2016 11:52:52 +0200 Subject: [PATCH] attempt to fix stargate spawning still gives stackoverflow, as there's no stop condition --- cicaprojekt/Field.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cicaprojekt/Field.java b/cicaprojekt/Field.java index 02cec29..d405421 100644 --- a/cicaprojekt/Field.java +++ b/cicaprojekt/Field.java @@ -1,19 +1,29 @@ package cicaprojekt; import java.util.HashMap; +import java.util.Map; public class Field extends cicaprojekt.Tile { + public static Map testAdjacentTile = new HashMap(); public static Field testField = new Field(); + private static boolean testAdjTileSet = false; public Field() { setItemOnTile(new Box()); - adjacentTile = new HashMap(); - adjacentTile.put(Direction.NORTH, Field.testField); - adjacentTile.put(Direction.EAST, Field.testField); - adjacentTile.put(Direction.SOUTH, Field.testField); - adjacentTile.put(Direction.WEST, Field.testField); + adjacentTile = testAdjacentTile; + setTestAdjacentTile(); + } + + private void setTestAdjacentTile() { + if(!testAdjTileSet) { + testAdjacentTile.put(Direction.NORTH, Field.testField); + testAdjacentTile.put(Direction.EAST, Field.testField); + testAdjacentTile.put(Direction.SOUTH, Field.testField); + testAdjacentTile.put(Direction.WEST, Field.testField); + testAdjTileSet = true; + } } @Override