Fix problem with coordinate offsets due to negative coordinate walk on

kzedmaps
This commit is contained in:
Mike Primm 2011-06-22 17:24:12 -05:00
parent 8e102446fe
commit 9db23444db
2 changed files with 16 additions and 8 deletions

View File

@ -64,6 +64,7 @@ public class DynmapWorld {
private static class PrefixData { private static class PrefixData {
int stepsize; int stepsize;
int[] stepseq; int[] stepseq;
boolean neg_step_x;
} }
public void freshenZoomOutFilesByLevel(File tilepath, int zoomlevel) { public void freshenZoomOutFilesByLevel(File tilepath, int zoomlevel) {
@ -77,6 +78,10 @@ public class DynmapWorld {
PrefixData pd = new PrefixData(); PrefixData pd = new PrefixData();
List<String> pfx = mt.baseZoomFilePrefixes(); List<String> pfx = mt.baseZoomFilePrefixes();
pd.stepsize = mt.baseZoomFileStepSize(); pd.stepsize = mt.baseZoomFileStepSize();
if(pd.stepsize < 0) {
pd.stepsize = -pd.stepsize;
pd.neg_step_x = true;
}
pd.stepseq = mt.zoomFileStepSequence(); pd.stepseq = mt.zoomFileStepSequence();
for(String p : pfx) { for(String p : pfx) {
maptab.put(p, pd); maptab.put(p, pd);
@ -121,6 +126,7 @@ public class DynmapWorld {
} }
else else
prefix = zoomprefix + prefix; prefix = zoomprefix + prefix;
int step = pd.stepsize << zoomlevel;
zoomlevel++; zoomlevel++;
String[] files = dir.list(new PNGFileFilter(prefix)); String[] files = dir.list(new PNGFileFilter(prefix));
for(String fn : files) { for(String fn : files) {
@ -142,14 +148,16 @@ public class DynmapWorld {
} }
if(!parsed) if(!parsed)
continue; continue;
if(pd.neg_step_x) x = -x;
if(x >= 0) if(x >= 0)
x = x - (x % (pd.stepsize << zoomlevel)); x = x - (x % (2*step));
else else
x = x + (x % (pd.stepsize << zoomlevel)); x = x + (x % (2*step));
if(pd.neg_step_x) x = -x;
if(y >= 0) if(y >= 0)
y = y - (y % (pd.stepsize << zoomlevel)); y = y - (y % (2*step));
else else
y = y + (y % (pd.stepsize << zoomlevel)); y = y + (y % (2*step));
File zf; File zf;
if(prefix.equals("")) if(prefix.equals(""))
zf = new File(dir, "z_" + x + "_" + y + ".png"); zf = new File(dir, "z_" + x + "_" + y + ".png");
@ -170,7 +178,7 @@ public class DynmapWorld {
} }
/* Do processing */ /* Do processing */
for(ProcessTileRec s : toprocess.values()) { 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) { private void processZoomTile(File dir, File zf, int tx, int ty, int stepsize, String prefix, int[] stepseq) {

View File

@ -335,8 +335,8 @@ public class KzedMap extends MapType {
} }
return s; return s;
} }
/* Return negative to flag negative X walk */
public int baseZoomFileStepSize() { return zTileWidth; } public int baseZoomFileStepSize() { return -zTileWidth; }
private static final int[] stepseq = { 0, 2, 1, 3 }; private static final int[] stepseq = { 0, 2, 1, 3 };