mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 01:57:53 +01:00
Set timestamps when rendering starts
- Currently only implemented for FileTreeMapStorage
This commit is contained in:
parent
40fb487fcd
commit
476aa0c133
@ -128,6 +128,7 @@ public abstract class DynmapWorld {
|
||||
private static final int[] stepseq = { 3, 1, 2, 0 };
|
||||
|
||||
private void processZoomFile(MapTypeState mts, MapStorageTile tile, boolean firstVariant) {
|
||||
final long startTimestamp = System.currentTimeMillis();
|
||||
int step = 1 << tile.zoom;
|
||||
MapStorageTile ztile = tile.getZoomOutTile();
|
||||
int width = 128, height = 128;
|
||||
@ -238,7 +239,7 @@ public abstract class DynmapWorld {
|
||||
}
|
||||
}
|
||||
else /* if (!ztile.matchesHashCode(crc)) */ {
|
||||
ztile.write(crc, zIm);
|
||||
ztile.write(crc, zIm, startTimestamp);
|
||||
MapManager.mapman.pushUpdate(this, new Client.Tile(ztile.getURI()));
|
||||
enqueueZoomOutUpdate(ztile);
|
||||
}
|
||||
|
@ -1178,6 +1178,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||
|
||||
@Override
|
||||
public boolean render(MapChunkCache cache, HDMapTile tile, String mapname) {
|
||||
final long startTimestamp = System.currentTimeMillis();
|
||||
Color rslt = new Color();
|
||||
MapIterator mapiter = cache.getIterator(0, 0, 0);
|
||||
DynmapWorld world = tile.getDynmapWorld();
|
||||
@ -1305,7 +1306,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||
if(mtile.matchesHashCode(crc) == false) {
|
||||
/* Wrap buffer as buffered image */
|
||||
if(rendered[i]) {
|
||||
mtile.write(crc, im[i].buf_img);
|
||||
mtile.write(crc, im[i].buf_img, startTimestamp);
|
||||
}
|
||||
else {
|
||||
mtile.delete();
|
||||
@ -1336,7 +1337,7 @@ public class IsoHDPerspective implements HDPerspective {
|
||||
if(mtile.matchesHashCode(crc) == false) {
|
||||
/* Wrap buffer as buffered image */
|
||||
if(rendered[i]) {
|
||||
mtile.write(crc, dayim[i].buf_img);
|
||||
mtile.write(crc, dayim[i].buf_img, startTimestamp);
|
||||
}
|
||||
else {
|
||||
mtile.delete();
|
||||
|
@ -57,7 +57,7 @@ public abstract class MapStorageTile {
|
||||
* @param encImage - output stream for encoded image
|
||||
* @return true if write succeeded
|
||||
*/
|
||||
public abstract boolean write(long hash, BufferOutputStream encImage);
|
||||
public abstract boolean write(long hash, BufferOutputStream encImage, long timestamp);
|
||||
/**
|
||||
* Write tile from image
|
||||
*
|
||||
@ -65,10 +65,10 @@ public abstract class MapStorageTile {
|
||||
* @param image - image to be encoded
|
||||
* @return true if write succeeded
|
||||
*/
|
||||
public boolean write(long hash, BufferedImage image) {
|
||||
public boolean write(long hash, BufferedImage image, long timestamp) {
|
||||
BufferOutputStream bos = ImageIOManager.imageIOEncode(image, map.getImageFormat());
|
||||
if (bos != null) {
|
||||
return write(hash, bos);
|
||||
return write(hash, bos, timestamp);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -78,7 +78,7 @@ public abstract class MapStorageTile {
|
||||
* @return true if write succeeded
|
||||
*/
|
||||
public boolean delete() {
|
||||
return write(-1, (BufferOutputStream) null);
|
||||
return write(-1, (BufferOutputStream) null, -1);
|
||||
}
|
||||
/**
|
||||
* Get write lock on tile
|
||||
|
@ -136,7 +136,7 @@ public class FileTreeMapStorage extends MapStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean write(long hash, BufferOutputStream encImage) {
|
||||
public boolean write(long hash, BufferOutputStream encImage, long timestamp) {
|
||||
File ff = getTileFile(map.getImageFormat().getEncoding());
|
||||
List<File> ffalt = getTileFilesAltFormats();
|
||||
File ffpar = ff.getParentFile();
|
||||
@ -158,7 +158,7 @@ public class FileTreeMapStorage extends MapStorage {
|
||||
if (ffpar.exists() == false) {
|
||||
ffpar.mkdirs();
|
||||
}
|
||||
if (replaceFile(ff, encImage.buf, encImage.len) == false) {
|
||||
if (replaceFile(ff, encImage.buf, encImage.len, timestamp) == false) {
|
||||
return false;
|
||||
}
|
||||
hashmap.updateHashCode(world.getName() + "." + map.getPrefix(), x, y, hash);
|
||||
@ -627,8 +627,12 @@ public class FileTreeMapStorage extends MapStorage {
|
||||
public String getTilesURI(boolean login_enabled) {
|
||||
return login_enabled?"standalone/tiles.php?tile=":"tiles/";
|
||||
}
|
||||
|
||||
|
||||
private boolean replaceFile(File f, byte[] b, int len) {
|
||||
return replaceFile(f, b, len, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private boolean replaceFile(File f, byte[] b, int len, long timestamp) {
|
||||
boolean done = false;
|
||||
File fold = new File(f.getPath() + ".old");
|
||||
File fnew = new File(f.getPath() + ".new");
|
||||
@ -649,6 +653,8 @@ public class FileTreeMapStorage extends MapStorage {
|
||||
else {
|
||||
fnew.renameTo(f);
|
||||
}
|
||||
// Use the supplied timestamp
|
||||
f.setLastModified(timestamp);
|
||||
done = true;
|
||||
} catch (IOException iox) {
|
||||
if (raf != null) { try { raf.close(); } catch (IOException x) {} }
|
||||
|
Loading…
Reference in New Issue
Block a user