From c19f437c21f98302ac2a332c7070738464753346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Tue, 29 Mar 2016 12:30:35 +0200 Subject: [PATCH] fixed infinite recursion in Field.spawnStargate() --- cicaprojekt/Field.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cicaprojekt/Field.java b/cicaprojekt/Field.java index d405421..206f34d 100644 --- a/cicaprojekt/Field.java +++ b/cicaprojekt/Field.java @@ -8,6 +8,7 @@ public class Field extends cicaprojekt.Tile public static Map testAdjacentTile = new HashMap(); public static Field testField = new Field(); private static boolean testAdjTileSet = false; + private static int recursionLimit = 0; public Field() { setItemOnTile(new Box()); @@ -30,6 +31,10 @@ public class Field extends cicaprojekt.Tile public void spawnStargate(cicaprojekt.Stargate stargate, Direction direction) { Menu.addTab(); System.out.println(">" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Field.spawnStargate(Stargate stargate, Direction direction)"); + + if (recursionLimit++ >= 10) + this.adjacentTile.put(direction, new Wall()); + adjacentTile.get(direction).spawnStargate(stargate, direction); System.out.println("<" + "[" + ":" + this.getClass().getSimpleName() + "]" + Menu.tabulator + "Field.spawnStargate(Stargate stargate, Direction direction)"); Menu.removeTab();