diff --git a/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js b/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js index df87adbd..0f5b9fdb 100644 --- a/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js +++ b/DynmapCore/src/main/resources/extracted/web/js/dynmaputils.js @@ -80,17 +80,6 @@ var DynmapTileLayer = L.TileLayer.extend({ _loadQueue: [], _loadingTiles: [], - getTileUrl: function(coords) { - var tileName = this.getTileName(coords), - url = this._cachedTileUrls[tileName]; - - if (!url) { - this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName); - } - - return url; - }, - createTile: function(coords, done) { var me = this, tile = document.createElement('img'); @@ -188,6 +177,24 @@ var DynmapTileLayer = L.TileLayer.extend({ L.TileLayer.prototype._removeTile.call(this, key); }, + getTileUrl: function(coords, timestamp) { + return this.getTileUrlFromName(this.getTileName(coords), timestamp); + }, + + getTileUrlFromName(tileName, timestamp) { + var url = this._cachedTileUrls[tileName]; + + if (!url) { + this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName); + } + + if(typeof timestamp !== 'undefined') { + url += (url.indexOf('?') === -1 ? '?timestamp=' + timestamp : '×tamp=' + timestamp); + } + + return url; + }, + getProjection: function() { return this.projection; }, @@ -207,26 +214,18 @@ var DynmapTileLayer = L.TileLayer.extend({ next.src = next.url; }, - onTileUpdated: function(tile, tileName) { - var src = this.dynmap.getTileUrl(tileName); - tile.attr('src', src); - tile.show(); - }, - getTileName: function(coords) { throw "getTileName not implemented"; }, - updateNamedTile: function(name) { + updateNamedTile: function(name, timestamp) { var tile = this._namedTiles[name]; - delete this._cachedTileUrls[name]; - if (tile) { - this.updateTile(tile); - } - }, - updateTile: function(tile) { - this._loadTile(tile, tile.tilePoint, this._map.getZoom()); + if (tile) { + tile.url = this.getTileUrlFromName(name, timestamp); + this._loadQueue.push(tile); + this._tickLoadQueue(); + } }, // Some helper functions. diff --git a/DynmapCore/src/main/resources/extracted/web/js/map.js b/DynmapCore/src/main/resources/extracted/web/js/map.js index 28223814..1f624f0f 100644 --- a/DynmapCore/src/main/resources/extracted/web/js/map.js +++ b/DynmapCore/src/main/resources/extracted/web/js/map.js @@ -695,7 +695,7 @@ DynMap.prototype = { swtch(update.type, { tile: function() { - me.onTileUpdated(update.name,update.timestamp); + me.maptype.updateNamedTile(update.name, update.timestamp); }, playerjoin: function() { $(me).trigger('playerjoin', [ update.playerName ]); @@ -742,25 +742,6 @@ DynMap.prototype = { } return tile; }, - onTileUpdated: function(tileName,timestamp) { - var me = this; - var prev = this.registeredTiles[tileName]; - var a_b = true; - if (prev && (prev.indexOf('upd=0') > 0)) - a_b = false; - var url = me.options.url.tiles; - if (a_b) { - if (url.indexOf('?') > 0) { - this.registeredTiles[tileName] = url + escape(me.world.name + '/' + tileName) + '&upd=0'; - } - else { - this.registeredTiles[tileName] = url + escape(me.world.name + '/' + tileName) + '?upd=0'; - } - } - else - this.registeredTiles[tileName] = url + me.world.name + '/' + tileName; - me.maptype.updateNamedTile(tileName); - }, addPlayer: function(update) { var me = this; var player = me.players[update.account] = {