summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java10
1 files changed, 6 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 72e050a..3f53070 100644
--- a/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
+++ b/core/src/ch/asynk/rustanddust/game/map/Map5Marshal.java
@@ -24,6 +24,8 @@ import ch.asynk.rustanddust.game.Engagement;
public abstract class Map5Marshal extends Map4Orders
{
+ private static StringWriter writer = new StringWriter(2048);
+
public Map5Marshal(final RustAndDust game, Texture map, SelectedTile hex)
{
super(game, map, hex);
@@ -32,8 +34,8 @@ public abstract class Map5Marshal extends Map4Orders
public String unload(Player player, Player opponent)
{
Json json = new Json(OutputType.json);
- StringWriter buffer = new StringWriter(2048);
- json.setWriter(buffer);
+ writer.getBuffer().setLength(0);
+ json.setWriter(writer);
json.writeObjectStart();
json.writeArrayStart("players");
@@ -48,8 +50,8 @@ public abstract class Map5Marshal extends Map4Orders
json.writeArrayEnd();
json.writeObjectEnd();
- buffer.flush();
- return buffer.toString();
+ writer.flush();
+ return writer.toString();
}
private void unload(Json json, Player player)