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