From 79cc37d1dd46569f3c5e5a3cef0727494d6b24c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 11 May 2016 14:47:28 +0200 Subject: Map5Marshal,Ctrl: use Unit.IterableSet, call Unit.clear() at exit --- core/src/ch/asynk/rustanddust/game/Ctrl.java | 2 +- core/src/ch/asynk/rustanddust/game/ctrl/Solo.java | 7 ------- core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java | 13 +++---------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/Ctrl.java b/core/src/ch/asynk/rustanddust/game/Ctrl.java index 2f88b43..0f608d6 100644 --- a/core/src/ch/asynk/rustanddust/game/Ctrl.java +++ b/core/src/ch/asynk/rustanddust/game/Ctrl.java @@ -439,7 +439,6 @@ public abstract class Ctrl implements Disposable return; } nextState = null; - map.clearMarshalUnits(); } hud.notify("Replay Done", Position.MIDDLE_CENTER); this.mode = Mode.PLAY; @@ -584,6 +583,7 @@ public abstract class Ctrl implements Disposable private void exitBattle() { if (debugCtrl) RustAndDust.debug(" EXIT BATTLE"); + Unit.clear(); game.switchToMenu(); } diff --git a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java index 19dd390..d41034f 100644 --- a/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java +++ b/core/src/ch/asynk/rustanddust/game/ctrl/Solo.java @@ -45,13 +45,6 @@ public class Solo extends Ctrl load(Marshal.Mode.MAP, r.map); load(Marshal.Mode.PLAYERS, r.players); load(Marshal.Mode.ORDERS, r.orders); - switch (game.config.loadMode) - { - case REPLAY_BATTLE: break; - default: - battle.getMap().clearMarshalUnits(); - break; - } synched = r.synched; r.dispose(); diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java index dc7554f..fed1840 100644 --- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java +++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java @@ -25,10 +25,6 @@ import ch.asynk.rustanddust.game.Engagement; public abstract class Map5Marshal extends Map4Orders implements Marshal { - private static UnitList units = new UnitList(30); - - public void clearMarshalUnits() { units.clear(); } - public Map5Marshal(final RustAndDust game, Texture map, SelectedTile hex) { super(game, map, hex); @@ -273,7 +269,6 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal public void loadPlayers(JsonValue v, Player[] players) { - clearMarshalUnits(); Unit.blockId = true; players[0] = loadPlayer(v.get("players").get(0)); players[1] = loadPlayer(v.get("players").get(1)); @@ -331,7 +326,6 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal Hex h = getHex(a.getInt(0), a.getInt(1)); setOnBoard(u, h, Orientation.fromRotation(a.getInt(2))); } - units.add(u); return u; } @@ -474,10 +468,9 @@ public abstract class Map5Marshal extends Map4Orders implements Marshal private static Unit findById(int id) { - for (Unit u : units) { - if (u.id() == id) - return u; - } + Unit u = Unit.findById(id); + if (u != null) + return u; RustAndDust.error(String.format("findById: unable to find unit %d", id)); return null; } -- cgit v1.1-2-g2b99