Have per-world control of sending player position and health, prevent

player icon flicker on addplayer (even when not on world or position
is obfuscated)
This commit is contained in:
Mike Primm 2011-06-03 08:42:24 -05:00
parent 6a50b2ebcd
commit 38163133cb
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)
# sendpositon: 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

@ -2,7 +2,9 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
var me = this;
$(dynmap).bind('playeradded', function(event, player) {
// Create the player-marker.
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
var markerPosition = null;
if(dynmap.world === player.location.world)
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;
$(div)
@ -50,6 +52,7 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
}
}
});
});
$(dynmap).bind('playerremoved', function(event, player) {
// Remove the marker.
@ -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) {