diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 10:27:11 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-06 10:27:11 +0200 |
commit | e4724369211efe1017099300e8ac83faacb26c05 (patch) | |
tree | 38c1f857afdc0983c16efd4195b7fe0653654dc4 /core/src/ch/asynk | |
parent | ddab8eb00c9bf89935d495b1a58ae2c44cb20506 (diff) | |
download | RustAndDust-e4724369211efe1017099300e8ac83faacb26c05.zip RustAndDust-e4724369211efe1017099300e8ac83faacb26c05.tar.gz |
Board: fix nodesToPoints(...)
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 50f83a8..dddb746 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -250,23 +250,14 @@ public abstract class Board implements Disposable private void nodesToPoints(List<SearchBoard.Node> nodes, ArrayList<GridPoint2> points) { - // for (GridPoint2 point : points) - // gridPoint2Pool.free(point); - // points.clear(); - - // for (SearchBoard.Node node : nodes) { - // GridPoint2 point = gridPoint2Pool.obtain(); - // point.set(node.col, node.row); - // points.add(point); - // } - int ns = nodes.size(); int ps = points.size(); if (ps > ns) { - for (int i = ns; i < ps; i++) - gridPoint2Pool.free(points.get(i)); - } + for (int i = (ps - 1); i >= ns; i--) + gridPoint2Pool.free(points.remove(i)); + } else + points.ensureCapacity(ns); int i = 0; for (SearchBoard.Node node : nodes) { @@ -279,7 +270,6 @@ public abstract class Board implements Disposable } i += 1; } - points.ensureCapacity(ns); } public void possibleMovesFrom(Pawn pawn, GridPoint2 coords, ArrayList<GridPoint2> moves) |