Merge pull request #198 from mikeprimm/master

Eliminate initial player position flicker
This commit is contained in:
mikeprimm 2011-06-03 07:56:14 -07:00
commit 65f93393e6
6 changed files with 17 additions and 6 deletions

View File

@ -246,6 +246,10 @@ worlds:
# title: "World"
# Use 'enabled: false' to disable a certain world.
# enabled: false
# Use sendposition: false to prevent player positions from showing when on this world (if sendposition is globally enabled)
# sendposition: false
# Use sendhealth: false ot prevent player health from showing when on this world (if sendhealth is globally enabled)
# sendhealth: false
# # If world isn't contiguous chunks (due to teleporting, for example), fullrender needs to be given other locations to scan for tiles on each patch of chunks
# fullrenderlocations:
# - x: 10000

View File

@ -41,8 +41,8 @@ public class ClientUpdateComponent extends Component {
s(jp, "name", ChatColor.stripColor(p.getDisplayName()));
s(jp, "account", p.getName());
/* Don't leak player location for world not visible on maps, or if sendposition disbaled */
boolean player_visible = MapManager.mapman.worldsLookup.containsKey(p.getWorld().getName());
if(configuration.getBoolean("sendpositon", true) && player_visible) {
DynmapWorld pworld = MapManager.mapman.worldsLookup.get(p.getWorld().getName());
if(configuration.getBoolean("sendpositon", true) && (pworld != null) && pworld.sendposition) {
s(jp, "world", p.getWorld().getName());
s(jp, "x", pl.getX());
s(jp, "y", pl.getY());
@ -55,7 +55,7 @@ public class ClientUpdateComponent extends Component {
s(jp, "z", 0.0);
}
/* Only send health if enabled AND we're on visible world */
if (configuration.getBoolean("sendhealth", false) && player_visible) {
if (configuration.getBoolean("sendhealth", false) && (pworld != null) && pworld.sendhealth) {
s(jp, "health", p.getHealth());
s(jp, "armor", Armor.getArmorPoints(p));
}

View File

@ -13,4 +13,6 @@ public class DynmapWorld {
public ConfigurationNode configuration;
public List<Location> seedloc;
public int servertime;
public boolean sendposition;
public boolean sendhealth;
}

View File

@ -295,6 +295,8 @@ public class MapManager {
List<ConfigurationNode> loclist = worldConfiguration.getNodes("fullrenderlocations");
dynmapWorld.seedloc = new ArrayList<Location>();
dynmapWorld.servertime = (int)(w.getTime() % 24000);
dynmapWorld.sendposition = worldConfiguration.getBoolean("sendposition", true);
dynmapWorld.sendhealth = worldConfiguration.getBoolean("sendhealth", true);
if(loclist != null) {
for(ConfigurationNode loc : loclist) {
Location lx = new Location(w, loc.getDouble("x", 0), loc.getDouble("y", 64), loc.getDouble("z", 0));

View File

@ -91,7 +91,7 @@ DynMap.prototype = {
worlds: {},
registeredTiles: [],
players: {},
lasttimestamp: '0',
lasttimestamp: new Date().getUTCMilliseconds(), /* Pseudorandom - prevent cached '?0' */
servertime: 0,
serverday: false,
inittime: new Date().getTime(),

View File

@ -5,6 +5,9 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
player.marker = new CustomMarker(markerPosition, dynmap.map, function(div) {
var playerImage;
player.marker.toggle(dynmap.world === player.location.world);
$(div)
.addClass('Marker')
.addClass('playerMarker')
@ -58,8 +61,8 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
$(dynmap).bind('playerupdated', function(event, player) {
// Update the marker.
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
player.marker.setPosition(markerPosition);
player.marker.toggle(dynmap.world === player.location.world);
player.marker.setPosition(markerPosition);
// Update health
if (configuration.showplayerhealth) {
if (player.health !== undefined && player.armor !== undefined) {
@ -77,7 +80,7 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
for(name in dynmap.players) {
var player = dynmap.players[name];
// Turn off marker - let update turn it back on
player.marker.toggle(false);
player.marker.hide();
}
});
// Remove marker on map change - let update place it again