mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-28 13:15:30 +01:00
Add support for cleanup of stale tiles (off edge of map)
This commit is contained in:
parent
8f66d34752
commit
ba2c3eac1c
@ -371,7 +371,17 @@ public class MapManager {
|
|||||||
else
|
else
|
||||||
sendMessage(String.format("%s of map '%s' of '%s' completed - %d tiles rendered (%.2f msec/map-tile, %.2f msec per render)",
|
sendMessage(String.format("%s of map '%s' of '%s' completed - %d tiles rendered (%.2f msec/map-tile, %.2f msec per render)",
|
||||||
rendertype, activemaps, world.world.getName(), rendercnt, msecpertile, rendtime));
|
rendertype, activemaps, world.world.getName(), rendercnt, msecpertile, rendtime));
|
||||||
|
/* Now, if fullrender, use the render bitmap to purge obsolete tiles */
|
||||||
|
if(cxmin == Integer.MIN_VALUE) {
|
||||||
|
if(activemapcnt == 1) {
|
||||||
|
map.purgeOldTiles(world, rendered);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for(MapType mt : map.getMapsSharingRender(world)) {
|
||||||
|
mt.purgeOldTiles(world, rendered);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
found.clear();
|
found.clear();
|
||||||
rendered.clear();
|
rendered.clear();
|
||||||
@ -566,11 +576,9 @@ public class MapManager {
|
|||||||
total_render_ns.addAndGet(System.nanoTime()-rt0);
|
total_render_ns.addAndGet(System.nanoTime()-rt0);
|
||||||
rendercalls.incrementAndGet();
|
rendercalls.incrementAndGet();
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
// found.setFlag(tile.tileOrdinalX(),tile.tileOrdinalY(),false);
|
|
||||||
rendered.setFlag(tile.tileOrdinalX(), tile.tileOrdinalY(), true);
|
rendered.setFlag(tile.tileOrdinalX(), tile.tileOrdinalY(), true);
|
||||||
for (MapTile adjTile : map.getAdjecentTiles(tile)) {
|
for (MapTile adjTile : map.getAdjecentTiles(tile)) {
|
||||||
if (!found.getFlag(adjTile.tileOrdinalX(),adjTile.tileOrdinalY()) &&
|
if (!found.getFlag(adjTile.tileOrdinalX(),adjTile.tileOrdinalY())) {
|
||||||
!rendered.getFlag(adjTile.tileOrdinalX(),adjTile.tileOrdinalY())) {
|
|
||||||
found.setFlag(adjTile.tileOrdinalX(), adjTile.tileOrdinalY(), true);
|
found.setFlag(adjTile.tileOrdinalX(), adjTile.tileOrdinalY(), true);
|
||||||
renderQueue.add(adjTile);
|
renderQueue.add(adjTile);
|
||||||
}
|
}
|
||||||
@ -578,7 +586,6 @@ public class MapManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
// found.setFlag(tile.tileOrdinalX(), tile.tileOrdinalY(), false);
|
|
||||||
if(!cache.isEmpty()) {
|
if(!cache.isEmpty()) {
|
||||||
rendercnt++;
|
rendercnt++;
|
||||||
timeaccum += System.currentTimeMillis() - tstart;
|
timeaccum += System.currentTimeMillis() - tstart;
|
||||||
@ -1173,11 +1180,9 @@ public class MapManager {
|
|||||||
/**
|
/**
|
||||||
* Update map tile statistics
|
* Update map tile statistics
|
||||||
*/
|
*/
|
||||||
public void updateStatistics(MapTile tile, String subtype, boolean rendered, boolean updated, boolean transparent) {
|
public void updateStatistics(MapTile tile, String prefix, boolean rendered, boolean updated, boolean transparent) {
|
||||||
synchronized(lock) {
|
synchronized(lock) {
|
||||||
String k = tile.getKey();
|
String k = tile.getKey(prefix);
|
||||||
if(subtype != null)
|
|
||||||
k += "." + subtype;
|
|
||||||
MapStats ms = mapstats.get(k);
|
MapStats ms = mapstats.get(k);
|
||||||
if(ms == null) {
|
if(ms == null) {
|
||||||
ms = new MapStats();
|
ms = new MapStats();
|
||||||
|
@ -40,7 +40,7 @@ public abstract class MapTile {
|
|||||||
@Override
|
@Override
|
||||||
public abstract boolean equals(Object obj);
|
public abstract boolean equals(Object obj);
|
||||||
|
|
||||||
public abstract String getKey();
|
public abstract String getKey(String prefix);
|
||||||
|
|
||||||
public abstract boolean isBiomeDataNeeded();
|
public abstract boolean isBiomeDataNeeded();
|
||||||
public abstract boolean isHightestBlockYDataNeeded();
|
public abstract boolean isHightestBlockYDataNeeded();
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package org.dynmap;
|
package org.dynmap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.dynmap.utils.TileFlags;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
public abstract class MapType {
|
public abstract class MapType {
|
||||||
@ -81,4 +84,30 @@ public abstract class MapType {
|
|||||||
*/
|
*/
|
||||||
public abstract int[] zoomFileStepSequence();
|
public abstract int[] zoomFileStepSequence();
|
||||||
|
|
||||||
|
public void purgeOldTiles(DynmapWorld world, TileFlags rendered) { }
|
||||||
|
|
||||||
|
public interface FileCallback {
|
||||||
|
public void fileFound(File f, File parent, boolean day);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void walkMapTree(File root, FileCallback cb, boolean day) {
|
||||||
|
LinkedList<File> dirs = new LinkedList<File>();
|
||||||
|
String ext = "." + getImageFormat().getFileExt();
|
||||||
|
dirs.add(root);
|
||||||
|
while(dirs.isEmpty() == false) {
|
||||||
|
File dir = dirs.pop();
|
||||||
|
String[] lst = dir.list();
|
||||||
|
for(String fn : lst) {
|
||||||
|
if(fn.equals(".") || fn.equals(".."))
|
||||||
|
continue;
|
||||||
|
File f = new File(dir, fn);
|
||||||
|
if(f.isDirectory()) { /* If directory, add to list to process */
|
||||||
|
dirs.add(f);
|
||||||
|
}
|
||||||
|
else if(fn.endsWith(ext)) { /* Else, if matches suffix */
|
||||||
|
cb.fileFound(f, dir, day);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ public class FlatMap extends MapType {
|
|||||||
boolean tile_update = false;
|
boolean tile_update = false;
|
||||||
FileLockManager.getWriteLock(outputFile);
|
FileLockManager.getWriteLock(outputFile);
|
||||||
try {
|
try {
|
||||||
if((!outputFile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), null, t.x, t.y))) {
|
if((!outputFile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(prefix), null, t.x, t.y))) {
|
||||||
/* Wrap buffer as buffered image */
|
/* Wrap buffer as buffered image */
|
||||||
Debug.debug("saving image " + outputFile.getPath());
|
Debug.debug("saving image " + outputFile.getPath());
|
||||||
if(!outputFile.getParentFile().exists())
|
if(!outputFile.getParentFile().exists())
|
||||||
@ -316,7 +316,7 @@ public class FlatMap extends MapType {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + outputFile.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + outputFile.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(tile.getFilename()));
|
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(tile.getFilename()));
|
||||||
hashman.updateHashCode(tile.getKey(), null, t.x, t.y, crc);
|
hashman.updateHashCode(tile.getKey(prefix), null, t.x, t.y, crc);
|
||||||
tile.getDynmapWorld().enqueueZoomOutUpdate(outputFile);
|
tile.getDynmapWorld().enqueueZoomOutUpdate(outputFile);
|
||||||
tile_update = true;
|
tile_update = true;
|
||||||
}
|
}
|
||||||
@ -327,7 +327,7 @@ public class FlatMap extends MapType {
|
|||||||
FileLockManager.releaseWriteLock(outputFile);
|
FileLockManager.releaseWriteLock(outputFile);
|
||||||
DynmapBufferedImage.freeBufferedImage(im);
|
DynmapBufferedImage.freeBufferedImage(im);
|
||||||
}
|
}
|
||||||
MapManager.mapman.updateStatistics(tile, null, true, tile_update, !rendered);
|
MapManager.mapman.updateStatistics(tile, prefix, true, tile_update, !rendered);
|
||||||
|
|
||||||
/* If day too, handle it */
|
/* If day too, handle it */
|
||||||
if(night_and_day) {
|
if(night_and_day) {
|
||||||
@ -335,7 +335,7 @@ public class FlatMap extends MapType {
|
|||||||
crc = hashman.calculateTileHash(argb_buf_day);
|
crc = hashman.calculateTileHash(argb_buf_day);
|
||||||
FileLockManager.getWriteLock(dayfile);
|
FileLockManager.getWriteLock(dayfile);
|
||||||
try {
|
try {
|
||||||
if((!dayfile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), "day", t.x, t.y))) {
|
if((!dayfile.exists()) || (crc != hashman.getImageHashCode(tile.getKey(prefix), "day", t.x, t.y))) {
|
||||||
Debug.debug("saving image " + dayfile.getPath());
|
Debug.debug("saving image " + dayfile.getPath());
|
||||||
if(!dayfile.getParentFile().exists())
|
if(!dayfile.getParentFile().exists())
|
||||||
dayfile.getParentFile().mkdirs();
|
dayfile.getParentFile().mkdirs();
|
||||||
@ -347,7 +347,7 @@ public class FlatMap extends MapType {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + dayfile.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + dayfile.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(tile.getDayFilename()));
|
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(tile.getDayFilename()));
|
||||||
hashman.updateHashCode(tile.getKey(), "day", t.x, t.y, crc);
|
hashman.updateHashCode(tile.getKey(prefix), "day", t.x, t.y, crc);
|
||||||
tile.getDynmapWorld().enqueueZoomOutUpdate(dayfile);
|
tile.getDynmapWorld().enqueueZoomOutUpdate(dayfile);
|
||||||
tile_update = true;
|
tile_update = true;
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ public class FlatMap extends MapType {
|
|||||||
FileLockManager.releaseWriteLock(dayfile);
|
FileLockManager.releaseWriteLock(dayfile);
|
||||||
DynmapBufferedImage.freeBufferedImage(im_day);
|
DynmapBufferedImage.freeBufferedImage(im_day);
|
||||||
}
|
}
|
||||||
MapManager.mapman.updateStatistics(tile, "day", true, tile_update, !rendered);
|
MapManager.mapman.updateStatistics(tile, prefix+"_day", true, tile_update, !rendered);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rendered;
|
return rendered;
|
||||||
@ -574,7 +574,7 @@ public class FlatMap extends MapType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getKey(String prefix) {
|
||||||
return world.world.getName() + "." + map.getPrefix();
|
return world.world.getName() + "." + map.getPrefix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,17 +7,23 @@ import java.io.File;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.dynmap.Client;
|
||||||
import org.dynmap.ConfigurationNode;
|
import org.dynmap.ConfigurationNode;
|
||||||
import org.dynmap.DynmapChunk;
|
import org.dynmap.DynmapChunk;
|
||||||
|
import org.dynmap.DynmapPlugin;
|
||||||
import org.dynmap.DynmapWorld;
|
import org.dynmap.DynmapWorld;
|
||||||
import org.dynmap.Log;
|
import org.dynmap.Log;
|
||||||
import org.dynmap.MapManager;
|
import org.dynmap.MapManager;
|
||||||
import org.dynmap.MapTile;
|
import org.dynmap.MapTile;
|
||||||
import org.dynmap.MapType;
|
import org.dynmap.MapType;
|
||||||
|
import org.dynmap.debug.Debug;
|
||||||
import org.dynmap.kzedmap.MapTileRenderer;
|
import org.dynmap.kzedmap.MapTileRenderer;
|
||||||
import org.dynmap.utils.MapChunkCache;
|
import org.dynmap.utils.MapChunkCache;
|
||||||
|
import org.dynmap.utils.TileFlags;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
|
import com.avaje.ebean.text.StringParser;
|
||||||
|
|
||||||
public class HDMap extends MapType {
|
public class HDMap extends MapType {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
@ -270,4 +276,61 @@ public class HDMap extends MapType {
|
|||||||
public int getBackgroundARGBNight() {
|
public int getBackgroundARGBNight() {
|
||||||
return bgcolornight;
|
return bgcolornight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private HDMapTile fileToTile(DynmapWorld world, File f) {
|
||||||
|
String n = f.getName();
|
||||||
|
n = n.substring(0, n.lastIndexOf('.'));
|
||||||
|
if(n == null) return null;
|
||||||
|
String[] nt = n.split("_");
|
||||||
|
if(nt.length != 2) return null;
|
||||||
|
int xx, zz;
|
||||||
|
try {
|
||||||
|
xx = Integer.parseInt(nt[0]);
|
||||||
|
zz = Integer.parseInt(nt[1]);
|
||||||
|
} catch (NumberFormatException nfx) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new HDMapTile(world, perspective, xx, zz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void purgeOldTiles(final DynmapWorld world, final TileFlags rendered) {
|
||||||
|
File basedir = new File(world.worldtilepath, prefix); /* Get base directory for map */
|
||||||
|
FileCallback cb = new FileCallback() {
|
||||||
|
public void fileFound(File f, File parent, boolean day) {
|
||||||
|
String n = f.getName();
|
||||||
|
if(n.startsWith("z")) { /* If zoom file */
|
||||||
|
if(n.startsWith("z_")) { /* First tier of zoom? */
|
||||||
|
File ff = new File(parent, n.substring(2)); /* Make file for render tier, and drive update */
|
||||||
|
HDMapTile tile = fileToTile(world, ff); /* Parse it */
|
||||||
|
if(tile == null) return;
|
||||||
|
if(rendered.getFlag(tile.tx, tile.ty) || rendered.getFlag(tile.tx+1, tile.ty) ||
|
||||||
|
rendered.getFlag(tile.tx, tile.ty-1) || rendered.getFlag(tile.tx+1, tile.ty-1))
|
||||||
|
return;
|
||||||
|
world.enqueueZoomOutUpdate(ff);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
HDMapTile tile = fileToTile(world, f);
|
||||||
|
if(tile == null) return;
|
||||||
|
|
||||||
|
if(rendered.getFlag(tile.tx, tile.ty)) { /* If we rendered this tile, its good */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Debug.debug("clean up " + f.getPath());
|
||||||
|
/* Otherwise, delete tile */
|
||||||
|
f.delete();
|
||||||
|
/* Push updates, clear hash code, and signal zoom tile update */
|
||||||
|
MapManager.mapman.pushUpdate(world.world,
|
||||||
|
new Client.Tile(day?tile.getDayFilename(prefix, getImageFormat()):tile.getFilename(prefix, getImageFormat())));
|
||||||
|
MapManager.mapman.hashman.updateHashCode(tile.getKey(prefix), day?"day":null, tile.tx, tile.ty, -1);
|
||||||
|
world.enqueueZoomOutUpdate(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
walkMapTree(basedir, cb, false);
|
||||||
|
if(lighting.isNightAndDayEnabled()) {
|
||||||
|
basedir = new File(world.worldtilepath, prefix+"_day");
|
||||||
|
walkMapTree(basedir, cb, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ public class HDMapTile extends MapTile {
|
|||||||
return o.tx == tx && o.ty == ty && (perspective == o.perspective) && (o.getWorld() == getWorld());
|
return o.tx == tx && o.ty == ty && (perspective == o.perspective) && (o.getWorld() == getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey(String prefix) {
|
||||||
return getWorld().getName() + "." + perspective.getName();
|
return getWorld().getName() + "." + prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1186,7 +1186,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
try {
|
try {
|
||||||
if(rendered[i])
|
if(rendered[i])
|
||||||
renderone = true;
|
renderone = true;
|
||||||
if((!f.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), prefix, tile.tx, tile.ty))) {
|
if((!f.exists()) || (crc != hashman.getImageHashCode(tile.getKey(prefix), null, tile.tx, tile.ty))) {
|
||||||
/* Wrap buffer as buffered image */
|
/* Wrap buffer as buffered image */
|
||||||
Debug.debug("saving image " + f.getPath());
|
Debug.debug("saving image " + f.getPath());
|
||||||
if(!f.getParentFile().exists())
|
if(!f.getParentFile().exists())
|
||||||
@ -1199,7 +1199,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + f.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + f.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(fname));
|
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(fname));
|
||||||
hashman.updateHashCode(tile.getKey(), prefix, tile.tx, tile.ty, crc);
|
hashman.updateHashCode(tile.getKey(prefix), null, tile.tx, tile.ty, crc);
|
||||||
tile.getDynmapWorld().enqueueZoomOutUpdate(f);
|
tile.getDynmapWorld().enqueueZoomOutUpdate(f);
|
||||||
tile_update = true;
|
tile_update = true;
|
||||||
}
|
}
|
||||||
@ -1216,10 +1216,9 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
fname = tile.getDayFilename(prefix, fmt);
|
fname = tile.getDayFilename(prefix, fmt);
|
||||||
f = new File(tile.getDynmapWorld().worldtilepath, fname);
|
f = new File(tile.getDynmapWorld().worldtilepath, fname);
|
||||||
FileLockManager.getWriteLock(f);
|
FileLockManager.getWriteLock(f);
|
||||||
prefix = prefix+"_day";
|
|
||||||
tile_update = false;
|
tile_update = false;
|
||||||
try {
|
try {
|
||||||
if((!f.exists()) || (crc != hashman.getImageHashCode(tile.getKey(), prefix, tile.tx, tile.ty))) {
|
if((!f.exists()) || (crc != hashman.getImageHashCode(tile.getKey(prefix), "day", tile.tx, tile.ty))) {
|
||||||
/* Wrap buffer as buffered image */
|
/* Wrap buffer as buffered image */
|
||||||
Debug.debug("saving image " + f.getPath());
|
Debug.debug("saving image " + f.getPath());
|
||||||
if(!f.getParentFile().exists())
|
if(!f.getParentFile().exists())
|
||||||
@ -1232,7 +1231,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + f.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + f.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(fname));
|
MapManager.mapman.pushUpdate(tile.getWorld(), new Client.Tile(fname));
|
||||||
hashman.updateHashCode(tile.getKey(), prefix, tile.tx, tile.ty, crc);
|
hashman.updateHashCode(tile.getKey(prefix), "day", tile.tx, tile.ty, crc);
|
||||||
tile.getDynmapWorld().enqueueZoomOutUpdate(f);
|
tile.getDynmapWorld().enqueueZoomOutUpdate(f);
|
||||||
tile_update = true;
|
tile_update = true;
|
||||||
}
|
}
|
||||||
@ -1243,7 +1242,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
FileLockManager.releaseWriteLock(f);
|
FileLockManager.releaseWriteLock(f);
|
||||||
DynmapBufferedImage.freeBufferedImage(dayim[i]);
|
DynmapBufferedImage.freeBufferedImage(dayim[i]);
|
||||||
}
|
}
|
||||||
MapManager.mapman.updateStatistics(tile, prefix, true, tile_update, !rendered[i]);
|
MapManager.mapman.updateStatistics(tile, prefix+"_day", true, tile_update, !rendered[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return renderone;
|
return renderone;
|
||||||
|
@ -1048,7 +1048,7 @@ public class TexturePack {
|
|||||||
rslt.setTransparent();
|
rslt.setTransparent();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* If warer block, to watercolor tone op */
|
/* If water block, to watercolor tone op */
|
||||||
if((blkid == 8) || (blkid == 9)) {
|
if((blkid == 8) || (blkid == 9)) {
|
||||||
textop = COLORMOD_WATERTONED;
|
textop = COLORMOD_WATERTONED;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
int ty = mtile.py/KzedMap.tileHeight;
|
int ty = mtile.py/KzedMap.tileHeight;
|
||||||
FileLockManager.getWriteLock(fname);
|
FileLockManager.getWriteLock(fname);
|
||||||
try {
|
try {
|
||||||
if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), null, tx, ty))) {
|
if((!fname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(prefix), null, tx, ty))) {
|
||||||
Debug.debug("saving image " + fname.getPath());
|
Debug.debug("saving image " + fname.getPath());
|
||||||
if(!fname.getParentFile().exists())
|
if(!fname.getParentFile().exists())
|
||||||
fname.getParentFile().mkdirs();
|
fname.getParentFile().mkdirs();
|
||||||
@ -285,14 +285,14 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + fname.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getFilename()));
|
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getFilename()));
|
||||||
hashman.updateHashCode(mtile.getKey(), null, tx, ty, crc);
|
hashman.updateHashCode(mtile.getKey(prefix), null, tx, ty, crc);
|
||||||
updated_fname = true;
|
updated_fname = true;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
FileLockManager.releaseWriteLock(fname);
|
FileLockManager.releaseWriteLock(fname);
|
||||||
DynmapBufferedImage.freeBufferedImage(img);
|
DynmapBufferedImage.freeBufferedImage(img);
|
||||||
}
|
}
|
||||||
MapManager.mapman.updateStatistics(mtile, null, true, updated_fname, !rendered);
|
MapManager.mapman.updateStatistics(mtile, prefix, true, updated_fname, !rendered);
|
||||||
|
|
||||||
mtile.file = fname;
|
mtile.file = fname;
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
crc = hashman.calculateTileHash(img.argb_buf);
|
crc = hashman.calculateTileHash(img.argb_buf);
|
||||||
FileLockManager.getWriteLock(dfname);
|
FileLockManager.getWriteLock(dfname);
|
||||||
try {
|
try {
|
||||||
if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(), "day", tx, ty))) {
|
if((!dfname.exists()) || (crc != hashman.getImageHashCode(mtile.getKey(prefix), "day", tx, ty))) {
|
||||||
Debug.debug("saving image " + dfname.getPath());
|
Debug.debug("saving image " + dfname.getPath());
|
||||||
if(!dfname.getParentFile().exists())
|
if(!dfname.getParentFile().exists())
|
||||||
dfname.getParentFile().mkdirs();
|
dfname.getParentFile().mkdirs();
|
||||||
@ -315,14 +315,14 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||||||
Debug.error("Failed to save image (NullPointerException): " + dfname.getPath(), e);
|
Debug.error("Failed to save image (NullPointerException): " + dfname.getPath(), e);
|
||||||
}
|
}
|
||||||
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getDayFilename()));
|
MapManager.mapman.pushUpdate(mtile.getWorld(), new Client.Tile(mtile.getDayFilename()));
|
||||||
hashman.updateHashCode(mtile.getKey(), "day", tx, ty, crc);
|
hashman.updateHashCode(mtile.getKey(prefix), "day", tx, ty, crc);
|
||||||
updated_dfname = true;
|
updated_dfname = true;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
FileLockManager.releaseWriteLock(dfname);
|
FileLockManager.releaseWriteLock(dfname);
|
||||||
DynmapBufferedImage.freeBufferedImage(img_day);
|
DynmapBufferedImage.freeBufferedImage(img_day);
|
||||||
}
|
}
|
||||||
MapManager.mapman.updateStatistics(mtile, "day", true, updated_dfname, !rendered);
|
MapManager.mapman.updateStatistics(mtile, prefix+"_day", true, updated_dfname, !rendered);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we've already got the new tile, and we're on an async thread, just
|
// Since we've already got the new tile, and we're on an async thread, just
|
||||||
|
@ -98,8 +98,8 @@ public class KzedMapTile extends MapTile {
|
|||||||
return o.px == px && o.py == py && (o.map == map) && (o.getWorld() == getWorld());
|
return o.px == px && o.py == py && (o.map == map) && (o.getWorld() == getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey(String prefix) {
|
||||||
return getWorld().getName() + "." + renderer.getPrefix();
|
return getWorld().getName() + "." + prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -85,8 +85,8 @@ public class KzedZoomedMapTile extends MapTile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getKey() {
|
public String getKey(String prefix) {
|
||||||
return getWorld().getName() + ".z" + originalTile.renderer.getPrefix();
|
return getWorld().getName() + ".z" + prefix;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user