Permalink
Browse files

Update population messages for tooltip

1 parent ddcc039 commit c5ddb3f23ec1a2f5a4aa800ca451b55cea42efca @sork sork committed Mar 12, 2012
Showing with 25 additions and 10 deletions.
  1. +2 −2 client/js/game.js
  2. +3 −2 client/js/gameclient.js
  3. +5 −2 client/js/main.js
  4. +4 −0 server/js/main.js
  5. +5 −3 server/js/message.js
  6. +2 −0 server/js/metrics.js
  7. +4 −1 server/js/worldserver.js
View
@@ -1447,9 +1447,9 @@ function(InfoManager, BubbleManager, Renderer, Map, Animation, Sprite, AnimatedT
self.audioManager.playSound("chat");
});
- self.client.onPopulationChange(function(population) {
+ self.client.onPopulationChange(function(worldPlayers, totalPlayers) {
if(self.nbplayers_callback) {
- self.nbplayers_callback(population);
+ self.nbplayers_callback(worldPlayers, totalPlayers);
}
});
View
@@ -324,10 +324,11 @@ define(['player', 'entityfactory', 'lib/bison'], function(Player, EntityFactory,
},
receivePopulation: function(data) {
- var population = data[1];
+ var worldPlayers = data[1],
+ totalPlayers = data[2];
if(this.population_callback) {
- this.population_callback(population);
+ this.population_callback(worldPlayers, totalPlayers);
}
},
View
@@ -196,8 +196,11 @@ define(['jquery', 'app'], function($, App) {
$('#hitpoints').toggleClass('invincible');
});
- game.onNbPlayersChange(function(population) {
- $("#playercount").find("span.count").text(population);
+ game.onNbPlayersChange(function(worldPlayers, totalPlayers) {
+ $("#playercount").find("span.count").text(worldPlayers);
+
+ $("#instance-population").find("span").text(worldPlayers);
+ $("#world-population").find("span").text(totalPlayers);
});
game.onAchievementUnlock(function(id, name, description) {
View
@@ -43,6 +43,7 @@ function main(config) {
world = _.detect(worlds, function(world) {
return world.playerCount < config.nb_players_per_world;
});
+ world.updatePopulation();
connect();
}
});
@@ -54,6 +55,9 @@ function main(config) {
var onPopulationChange = function() {
metrics.updatePlayerCounters(worlds);
metrics.updateWorldDistribution(getWorldDistribution(worlds));
+ _.each(worlds, function(world) {
+ world.updatePopulation(metrics.totalPopulation);
+ });
};
_.each(_.range(config.nb_worlds), function(i) {
View
@@ -156,12 +156,14 @@ Messages.Damage = Message.extend({
});
Messages.Population = Message.extend({
- init: function(count) {
- this.count = count;
+ init: function(world, total) {
+ this.world = world;
+ this.total = total;
},
serialize: function() {
return [Types.Messages.POPULATION,
- this.count];
+ this.world,
+ this.total];
}
});
View
@@ -11,6 +11,7 @@ module.exports = Metrics = Class.extend({
this.client = new memcache.Client(config.memcached_port, config.memcached_host),
this.client.connect();
this.isReady = false;
+ this.totalPopulation = 0;
this.client.on('connect', function() {
log.info("Metrics enabled: memcached client connected to "+config.memcached_host+":"+config.memcached_port);
@@ -45,6 +46,7 @@ module.exports = Metrics = Class.extend({
numServers -= 1;
if(numServers === 0) {
self.client.set('total_players', total_players);
+ self.totalPopulation = total_players;
}
});
});
View
@@ -625,7 +625,6 @@ module.exports = World = cls.Class.extend({
setPlayerCount: function(count) {
this.playerCount = count;
- this.pushBroadcast(new Messages.Population(this.playerCount));
},
incrementPlayerCount: function() {
@@ -849,5 +848,9 @@ module.exports = World = cls.Class.extend({
area.addToArea(mob);
}
});
+ },
+
+ updatePopulation: function(totalPlayers) {
+ this.pushBroadcast(new Messages.Population(this.playerCount, totalPlayers ? totalPlayers : this.playerCount));
}
});

0 comments on commit c5ddb3f

Please sign in to comment.