From 289d5150711e8b89be5caedeacb779ef277301c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Sun, 5 Oct 2014 12:54:43 +0200 Subject: Board,Map: dispose clears all paths, and sets --- core/src/ch/asynk/tankontank/engine/Board.java | 17 +++++++++++------ core/src/ch/asynk/tankontank/game/Map.java | 16 ++++++++++++---- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 9a0ac32..0a8a47b 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -241,7 +241,7 @@ public abstract class Board implements Disposable debugShapes.setTransformMatrix(prevTransform); } - public void clearNodesVector(Vector points) + public void clearPointVector(Vector points) { for (GridPoint2 point : points) gridPoint2Pool.free(point); @@ -294,7 +294,7 @@ public abstract class Board implements Disposable nodesToPoints(nodes, targets); } - public void clearNodesSet(Set points) + public void clearPointSet(Set points) { for (GridPoint2 point : points) gridPoint2Pool.free(point); @@ -331,13 +331,18 @@ public abstract class Board implements Disposable return nodesToSet(paths, points); } - public int getFinalPath(Pawn pawn, Vector path, Orientation finalOrientation) + public void clearCoordinateVector(Vector points) + { + for (Vector3 point : points) + vector3Pool.free(point); + points.clear(); + } + + public int getCoordinatePath(Pawn pawn, Vector path, Orientation finalOrientation) { List> paths = searchBoard.possiblePaths(); - for (Vector3 v : path) - vector3Pool.free(v); - path.clear(); + clearCoordinateVector(path); if (paths.size() != 1) return 0; diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index eaa83df..0627e47 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -29,6 +29,14 @@ public abstract class Map extends Board setup(); } + @Override + public void dispose() + { + super.dispose(); + resetPaths(); + clearCoordinateVector(finalPath); + } + protected Hex getHex(int col, int row) { return (Hex) getTile(col, row); @@ -104,7 +112,7 @@ public abstract class Map extends Board public void movePawn(Pawn pawn, Orientation o) { - int s = getFinalPath(pawn, finalPath, o); + int s = getCoordinatePath(pawn, finalPath, o); if (s > 0) { movePawn(pawn, finalPath); } @@ -119,9 +127,9 @@ public abstract class Map extends Board public void resetPaths() { - clearNodesSet(possiblePaths); - clearNodesVector(possibleMoves); - clearNodesVector(possibleTargets); + clearPointSet(possiblePaths); + clearPointVector(possibleMoves); + clearPointVector(possibleTargets); } public void toggleDotOverlay(GridPoint2 hex) -- cgit v1.1-2-g2b99