From 9db23444db82bbf0f2c9c2a3f27e6e3c7b2e9867 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Wed, 22 Jun 2011 17:24:12 -0500 Subject: [PATCH] Fix problem with coordinate offsets due to negative coordinate walk on kzedmaps --- src/main/java/org/dynmap/DynmapWorld.java | 20 +++++++++++++------ src/main/java/org/dynmap/kzedmap/KzedMap.java | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/dynmap/DynmapWorld.java b/src/main/java/org/dynmap/DynmapWorld.java index 4afb3fc9..ed841caf 100644 --- a/src/main/java/org/dynmap/DynmapWorld.java +++ b/src/main/java/org/dynmap/DynmapWorld.java @@ -64,6 +64,7 @@ public class DynmapWorld { private static class PrefixData { int stepsize; int[] stepseq; + boolean neg_step_x; } public void freshenZoomOutFilesByLevel(File tilepath, int zoomlevel) { @@ -77,6 +78,10 @@ public class DynmapWorld { PrefixData pd = new PrefixData(); List pfx = mt.baseZoomFilePrefixes(); pd.stepsize = mt.baseZoomFileStepSize(); + if(pd.stepsize < 0) { + pd.stepsize = -pd.stepsize; + pd.neg_step_x = true; + } pd.stepseq = mt.zoomFileStepSequence(); for(String p : pfx) { maptab.put(p, pd); @@ -121,6 +126,7 @@ public class DynmapWorld { } else prefix = zoomprefix + prefix; + int step = pd.stepsize << zoomlevel; zoomlevel++; String[] files = dir.list(new PNGFileFilter(prefix)); for(String fn : files) { @@ -142,14 +148,16 @@ public class DynmapWorld { } if(!parsed) continue; - if(x >= 0) - x = x - (x % (pd.stepsize << zoomlevel)); + if(pd.neg_step_x) x = -x; + if(x >= 0) + x = x - (x % (2*step)); else - x = x + (x % (pd.stepsize << zoomlevel)); + x = x + (x % (2*step)); + if(pd.neg_step_x) x = -x; if(y >= 0) - y = y - (y % (pd.stepsize << zoomlevel)); + y = y - (y % (2*step)); else - y = y + (y % (pd.stepsize << zoomlevel)); + y = y + (y % (2*step)); File zf; if(prefix.equals("")) zf = new File(dir, "z_" + x + "_" + y + ".png"); @@ -170,7 +178,7 @@ public class DynmapWorld { } /* Do processing */ for(ProcessTileRec s : toprocess.values()) { - processZoomTile(dir, s.zf, s.x, s.y, pd.stepsize << (zoomlevel-1), prefix, pd.stepseq); + processZoomTile(dir, s.zf, s.x - (pd.neg_step_x?step:0), s.y, step, prefix, pd.stepseq); } } private void processZoomTile(File dir, File zf, int tx, int ty, int stepsize, String prefix, int[] stepseq) { diff --git a/src/main/java/org/dynmap/kzedmap/KzedMap.java b/src/main/java/org/dynmap/kzedmap/KzedMap.java index 4e12f3bf..85d2d757 100644 --- a/src/main/java/org/dynmap/kzedmap/KzedMap.java +++ b/src/main/java/org/dynmap/kzedmap/KzedMap.java @@ -335,8 +335,8 @@ public class KzedMap extends MapType { } return s; } - - public int baseZoomFileStepSize() { return zTileWidth; } + /* Return negative to flag negative X walk */ + public int baseZoomFileStepSize() { return -zTileWidth; } private static final int[] stepseq = { 0, 2, 1, 3 };