summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java17
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java16
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<GridPoint2> points)
+ public void clearPointVector(Vector<GridPoint2> 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<GridPoint2> points)
+ public void clearPointSet(Set<GridPoint2> 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<Vector3> path, Orientation finalOrientation)
+ public void clearCoordinateVector(Vector<Vector3> points)
+ {
+ for (Vector3 point : points)
+ vector3Pool.free(point);
+ points.clear();
+ }
+
+ public int getCoordinatePath(Pawn pawn, Vector<Vector3> path, Orientation finalOrientation)
{
List<Vector<SearchBoard.Node>> 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)