summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-02-10 11:54:15 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-02-10 11:54:15 +0100
commit6154e6415ecff8949c38e0eb655da01362b9e550 (patch)
treecf6b19549541c8ab3a5bd1c004115ac2afebc730
parentce99297b3e4e46070d4f0eb4f5d05ee9c090dd53 (diff)
downloadRustAndDust-6154e6415ecff8949c38e0eb655da01362b9e550.zip
RustAndDust-6154e6415ecff8949c38e0eb655da01362b9e550.tar.gz
Map5Marshal: unload/load Unit entryZone and exitZone
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
index 4bc0509..5c72394 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
@@ -43,13 +43,13 @@ public abstract class Map5Marshal extends Map4Orders
json.setWriter(writer);
json.writeObjectStart();
+ json.writeObjectStart("map");
+ unload(json);
+ json.writeObjectEnd();
json.writeArrayStart("players");
unload(json, player);
unload(json, opponent);
json.writeArrayEnd();
- json.writeObjectStart("map");
- unload(json);
- json.writeObjectEnd();
json.writeArrayStart("orders");
unload(json, orders);
json.writeArrayEnd();
@@ -100,6 +100,8 @@ public abstract class Map5Marshal extends Map4Orders
json.writeValue(unit.ace);
json.writeValue(unit.hasMoved);
json.writeValue(unit.hasFired);
+ json.writeValue(entryZones.indexOf(unit.entryZone));
+ json.writeValue(exitZones.indexOf(unit.exitZone));
json.writeArrayEnd();
if (pos) {
Hex h = unit.getHex();
@@ -266,9 +268,9 @@ public abstract class Map5Marshal extends Map4Orders
{
units.clear();
JsonValue root = new JsonReader().parse(payload);
+ loadMap(root.get("map"));
players[0] = loadPlayer(root.get("players").get(0));
players[1] = loadPlayer(root.get("players").get(1));
- loadMap(root.get("map"));
loadOrders(root.get("orders"));
units.clear();
}
@@ -307,6 +309,10 @@ public abstract class Map5Marshal extends Map4Orders
Unit u = game.factory.getUnit(code, a.getBoolean(0), a.getBoolean(1));
if (a.getBoolean(2)) u.setMoved();
if (a.getBoolean(3)) u.setFired();
+ int i = a.getInt(4);
+ if (i != -1) u.entryZone = entryZones.get(i);
+ i = a.getInt(5);
+ if (i != -1) u.exitZone = exitZones.get(i);
u.id = unitId;
if (pos) {
a = v.get("p");