Hide player positions when on disabled worlds, add sendposition flat

to ClientComponent to avoid leaking position data, even when markers
are off, fix problem with stale player marker positions during/right
after map changes
This commit is contained in:
Mike Primm 2011-06-03 00:39:21 -05:00
parent 969c3631a8
commit 58c600b65f
4 changed files with 49 additions and 7 deletions

View file

@ -58,8 +58,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.toggle(dynmap.world === player.location.world);
player.marker.setPosition(markerPosition);
player.marker.toggle(dynmap.world === player.location.world);
// Update health
if (configuration.showplayerhealth) {
if (player.health !== undefined && player.armor !== undefined) {
@ -71,4 +71,23 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
}
}
});
// Remove marker on start of map change
$(dynmap).bind('mapchanging', function(event) {
var name;
for(name in dynmap.players) {
var player = dynmap.players[name];
// Turn off marker - let update turn it back on
player.marker.toggle(false);
}
});
// Remove marker on map change - let update place it again
$(dynmap).bind('mapchanged', function(event) {
var name;
for(name in dynmap.players) {
var player = dynmap.players[name];
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);
}
});
};