summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-05-11 14:47:28 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2016-05-11 14:47:28 +0200
commit79cc37d1dd46569f3c5e5a3cef0727494d6b24c6 (patch)
tree654e89359a35cbbb32ac317d64fb2684abfbec19 /core/src/ch
parenta5cef081cee24e162d18d48ff798612f4dafbbd5 (diff)
downloadRustAndDust-79cc37d1dd46569f3c5e5a3cef0727494d6b24c6.zip
RustAndDust-79cc37d1dd46569f3c5e5a3cef0727494d6b24c6.tar.gz
Map5Marshal,Ctrl: use Unit.IterableSet<Unit>, call Unit.clear() at exit
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/rustanddust/game/Ctrl.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/ctrl/Solo.java7
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java13
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;
}