From e4724369211efe1017099300e8ac83faacb26c05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 6 Oct 2014 10:27:11 +0200 Subject: Board: fix nodesToPoints(...) --- core/src/ch/asynk/tankontank/engine/Board.java | 18 ++++-------------- 1 file 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 nodes, ArrayList 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 moves) -- cgit v1.1-2-g2b99