From 9852aa74f9f727e702283ba6c90551156d6610d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Feb 2015 12:42:22 +0100 Subject: Map: correctly free used Engagement --- core/src/ch/asynk/tankontank/game/Map.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index ddcc237..517afc8 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -58,6 +58,7 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS private Sound sound; private long soundId = -1; private Animation animationClosure; + private Engagement engagement; protected abstract void setup(); @@ -315,6 +316,10 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS public void actionDone() { objectives.forget(); + if (engagement != null) { + engagement.dispose(); + engagement = null; + } } public boolean enterBoard(Unit unit, Hex to, int allowedMoves) @@ -508,9 +513,9 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS public boolean engageUnit(Unit unit, final Unit target) { attack(unit, target, true); - Engagement e = Engagement.get(unit, target); + engagement = Engagement.get(unit, target); - boolean success = resolveFight(unit, target, e); + boolean success = resolveFight(unit, target, engagement); breakUnits.clear(); for (Unit u : activatedUnits) { -- cgit v1.1-2-g2b99