From 0d97a93100e1410904240106dfd12b2ed70a50e6 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 26 Sep 2011 23:32:23 -0500 Subject: [PATCH] Fix encoding for saved tile flags --- src/main/java/org/dynmap/MapManager.java | 11 ++++++----- src/main/java/org/dynmap/utils/TileFlags.java | 14 ++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 1ea75878..340f5d02 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -261,7 +261,7 @@ public class MapManager { czmin = n.getInteger("czmin", 0); czmax = n.getInteger("czmax", 0); rendertype = n.getString("rendertype", ""); - mapname = n.getString("mapname", ""); + mapname = n.getString("mapname", null); sender = plug_in.getServer().getConsoleSender(); } @@ -269,9 +269,9 @@ public class MapManager { HashMap v = new HashMap(); v.put("world", world.world.getName()); - v.put("locX", loc.getX()); - v.put("locY", loc.getY()); - v.put("locZ", loc.getZ()); + v.put("locX", loc.getBlockX()); + v.put("locY", loc.getBlockY()); + v.put("locZ", loc.getBlockZ()); v.put("mapindex", map_index); v.put("map", map.getName()); v.put("found", found.save()); @@ -297,7 +297,8 @@ public class MapManager { v.put("czmin", czmin); v.put("czmax", czmax); v.put("rendertype", rendertype); - v.put("mapname", mapname); + if(mapname != null) + v.put("mapname", mapname); return v; } diff --git a/src/main/java/org/dynmap/utils/TileFlags.java b/src/main/java/org/dynmap/utils/TileFlags.java index 51e34529..5bf76fd9 100644 --- a/src/main/java/org/dynmap/utils/TileFlags.java +++ b/src/main/java/org/dynmap/utils/TileFlags.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; + +import org.dynmap.Log; /** * scalable flags primitive - used for keeping track of potentially huge number of tiles * @@ -24,10 +26,11 @@ public class TileFlags { ArrayList v = new ArrayList(); StringBuilder sb = new StringBuilder(); for(Map.Entry ent : chunkmap.entrySet()) { - sb.append(String.format("%x", ent.getKey().longValue())); + long v1 = ent.getKey().longValue(); + sb.append(String.format("%x/%x", ((v1>>32)&0xFFFFFFFFL), (v1 & 0xFFFFFFFFL) )); long[] val = ent.getValue(); for(long vv : val) { - sb.append(String.format(":%x", vv)); + sb.append(String.format(":%x/%x", ((vv>>32) & 0xFFFFFFFFL), (vv & 0xFFFFFFFFL))); } v.add(sb.toString()); sb.setLength(0); @@ -41,12 +44,15 @@ public class TileFlags { String[] tok = v.split(":"); long[] row = new long[64]; try { - long rowaddr = Long.parseLong(tok[0], 16); + String ss[] = tok[0].split("/"); + long rowaddr = (Long.parseLong(ss[0], 16)<<32) | Long.parseLong(ss[1],16); for(int i = 0; (i < 64) && (i < (tok.length-1)); i++) { - row[i] = Long.parseLong(tok[i+1], 16); + ss = tok[i+1].split("/"); + row[i] = (Long.parseLong(ss[0], 16)<<32) | Long.parseLong(ss[1],16); } chunkmap.put(rowaddr, row); } catch (NumberFormatException nfx) { + Log.info("parse error - " + nfx); } } }