mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 18:17:37 +01:00
More tuning on zoom-out, fix zoomout on bigworld on iso-maps
This commit is contained in:
parent
c2ee0ebd42
commit
d63db655d8
@ -137,18 +137,19 @@ public class DynmapWorld {
|
|||||||
Debug.debug("freshenZoomOutFiles(" + world.getName() + "," + zoomlevel + ") - done (" + cnt + " updated files)");
|
Debug.debug("freshenZoomOutFiles(" + world.getName() + "," + zoomlevel + ") - done (" + cnt + " updated files)");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ProcessTileRec {
|
private static class ProcessTileRec {
|
||||||
File zf;
|
File zf;
|
||||||
String zfname;
|
String zfname;
|
||||||
int x, y;
|
int x, y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makeFilePath(PrefixData pd, int x, int y, boolean zoomed) {
|
private String makeFilePath(PrefixData pd, int x, int y, boolean zoomed) {
|
||||||
if(bigworld)
|
if(bigworld)
|
||||||
return pd.baseprefix + "/" + ((x/pd.stepsize) >> 5) + "_" + ((y/pd.stepsize) >> 5) + "/" + (zoomed?pd.zfnprefix:pd.fnprefix) + x + "_" + y + ".png";
|
return pd.baseprefix + "/" + ((x/pd.stepsize) >> 5) + "_" + ((y/pd.stepsize) >> 5) + "/" + (zoomed?pd.zfnprefix:pd.fnprefix) + x + "_" + y + ".png";
|
||||||
else
|
else
|
||||||
return (zoomed?pd.zfnprefix:pd.fnprefix) + "_" + x + "_" + y + ".png";
|
return (zoomed?pd.zfnprefix:pd.fnprefix) + "_" + x + "_" + y + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
private int processZoomDirectory(File dir, PrefixData pd) {
|
private int processZoomDirectory(File dir, PrefixData pd) {
|
||||||
Debug.debug("processZoomDirectory(" + dir.getPath() + "," + pd.baseprefix + ")");
|
Debug.debug("processZoomDirectory(" + dir.getPath() + "," + pd.baseprefix + ")");
|
||||||
HashMap<String, ProcessTileRec> toprocess = new HashMap<String, ProcessTileRec>();
|
HashMap<String, ProcessTileRec> toprocess = new HashMap<String, ProcessTileRec>();
|
||||||
@ -188,8 +189,9 @@ public class DynmapWorld {
|
|||||||
/* Make name of corresponding zoomed tile */
|
/* Make name of corresponding zoomed tile */
|
||||||
String zfname = makeFilePath(pd, x, y, true);
|
String zfname = makeFilePath(pd, x, y, true);
|
||||||
File zf = new File(worldtilepath, zfname);
|
File zf = new File(worldtilepath, zfname);
|
||||||
|
long fts = f.lastModified();
|
||||||
/* If zoom file exists and is older than our file, nothing to do */
|
/* If zoom file exists and is older than our file, nothing to do */
|
||||||
if(zf.exists() && (zf.lastModified() >= f.lastModified())) {
|
if(zf.exists() && ((zf.lastModified() >= f.lastModified()) || checkIgnoreUpdate(f, fts))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String zfpath = zf.getPath();
|
String zfpath = zf.getPath();
|
||||||
@ -211,6 +213,7 @@ public class DynmapWorld {
|
|||||||
Debug.debug("processZoomDirectory(" + dir.getPath() + "," + pd.baseprefix + ") - done (" + cnt + " files)");
|
Debug.debug("processZoomDirectory(" + dir.getPath() + "," + pd.baseprefix + ") - done (" + cnt + " files)");
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processZoomTile(PrefixData pd, File dir, File zf, String zfname, int tx, int ty) {
|
private void processZoomTile(PrefixData pd, File dir, File zf, String zfname, int tx, int ty) {
|
||||||
Debug.debug("processZoomFile(" + pd.baseprefix + "," + dir.getPath() + "," + zf.getPath() + "," + tx + "," + ty + ")");
|
Debug.debug("processZoomFile(" + pd.baseprefix + "," + dir.getPath() + "," + zf.getPath() + "," + tx + "," + ty + ")");
|
||||||
int width = 128, height = 128;
|
int width = 128, height = 128;
|
||||||
@ -264,18 +267,49 @@ public class DynmapWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
FileLockManager.getWriteLock(zf);
|
FileLockManager.getWriteLock(zf);
|
||||||
try {
|
TileHashManager hashman = MapManager.mapman.hashman;
|
||||||
if(!zf.getParentFile().exists())
|
long crc = hashman.calculateTileHash(argb); /* Get hash of tile */
|
||||||
zf.getParentFile().mkdirs();
|
int tilex = tx/step/2;
|
||||||
FileLockManager.imageIOWrite(zIm, "png", zf);
|
int tiley = ty/step/2;
|
||||||
Debug.debug("Saved zoom-out tile at " + zf.getPath());
|
String key = world.getName()+"."+pd.zoomprefix+pd.baseprefix;
|
||||||
} catch (IOException e) {
|
if((!zf.exists()) || (crc != MapManager.mapman.hashman.getImageHashCode(key, null, tilex, tiley))) {
|
||||||
Debug.error("Failed to save zoom-out tile: " + zf.getName(), e);
|
try {
|
||||||
} catch (java.lang.NullPointerException e) {
|
if(!zf.getParentFile().exists())
|
||||||
Debug.error("Failed to save zoom-out tile (NullPointerException): " + zf.getName(), e);
|
zf.getParentFile().mkdirs();
|
||||||
|
FileLockManager.imageIOWrite(zIm, "png", zf);
|
||||||
|
Debug.debug("Saved zoom-out tile at " + zf.getPath());
|
||||||
|
} catch (IOException e) {
|
||||||
|
Debug.error("Failed to save zoom-out tile: " + zf.getName(), e);
|
||||||
|
} catch (java.lang.NullPointerException e) {
|
||||||
|
Debug.error("Failed to save zoom-out tile (NullPointerException): " + zf.getName(), e);
|
||||||
|
}
|
||||||
|
hashman.updateHashCode(key, null, tilex, tiley, crc);
|
||||||
|
MapManager.mapman.pushUpdate(this.world, new Client.Tile(zfname));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
zf.setLastModified(System.currentTimeMillis()); /* Touch the existing file */
|
||||||
|
// ignoreUpdate(zf); /* Remember to ignore this update */
|
||||||
}
|
}
|
||||||
FileLockManager.releaseWriteLock(zf);
|
FileLockManager.releaseWriteLock(zf);
|
||||||
KzedMap.freeBufferedImage(kzIm);
|
KzedMap.freeBufferedImage(kzIm);
|
||||||
MapManager.mapman.pushUpdate(this.world, new Client.Tile(zfname));
|
|
||||||
}
|
}
|
||||||
|
private HashMap<String, Long> ignore_upd = new HashMap<String, Long>();
|
||||||
|
|
||||||
|
private void ignoreUpdate(File f) {
|
||||||
|
long ts = f.lastModified();
|
||||||
|
ignore_upd.put(f.getPath(), ts);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if ignore for file at current timestamp - return true if so
|
||||||
|
*/
|
||||||
|
private boolean checkIgnoreUpdate(File f, long ts) {
|
||||||
|
String fn = f.getPath();
|
||||||
|
Long its = ignore_upd.get(fn);
|
||||||
|
if((its != null) && (ts <= its.longValue())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ignore_upd.remove(fn); /* If newer, stop ignoring */
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,18 +50,19 @@ KzedMapType.prototype = $.extend(new DynMapType(), {
|
|||||||
dnprefix = '_day';
|
dnprefix = '_day';
|
||||||
var extrazoom = this.dynmap.world.extrazoomout;
|
var extrazoom = this.dynmap.world.extrazoomout;
|
||||||
if (zoom <= extrazoom) {
|
if (zoom <= extrazoom) {
|
||||||
var zpre = 'zzzzzzzzzzzzzzzz'.substring(0, extrazoom-zoom+1);
|
var zpre = 'zzzzzzzzzzzzzzzz'.substring(0, extrazoom-zoom);
|
||||||
// Most zoomed out tiles.
|
// Most zoomed out tiles.
|
||||||
tileSize = 128;
|
tileSize = 128;
|
||||||
imgSize = tileSize;
|
imgSize = tileSize;
|
||||||
var tilescale = 2 << (extrazoom-zoom);
|
var tilescale = 2 << (extrazoom-zoom);
|
||||||
if (this.dynmap.world.bigworld) {
|
if (this.dynmap.world.bigworld) {
|
||||||
tileName = zpre + this.prefix + dnprefix + '/' + ((-coord.x * tileSize*tilescale)>>12) +
|
if(zoom < extrazoom) zpre = zpre + '_';
|
||||||
'_' + ((coord.y * tileSize*tilescale) >> 12) + '/' +
|
tileName = 'z' + this.prefix + dnprefix + '/' + ((-coord.x * tileSize*tilescale)>>12) +
|
||||||
|
'_' + ((coord.y * tileSize*tilescale) >> 12) + '/' + zpre +
|
||||||
(-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png';
|
(-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tileName = zpre + this.prefix + dnprefix + '_' + (-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png';
|
tileName = zpre + 'z' + this.prefix + dnprefix + '_' + (-coord.x * tileSize*tilescale) + '_' + (coord.y * tileSize*tilescale) + '.png';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Other zoom levels.
|
// Other zoom levels.
|
||||||
|
Loading…
Reference in New Issue
Block a user