diff options
Diffstat (limited to 'src/game-server/accountconnection.cpp')
-rw-r--r-- | src/game-server/accountconnection.cpp | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/game-server/accountconnection.cpp b/src/game-server/accountconnection.cpp index 9a2084df..4219b33d 100644 --- a/src/game-server/accountconnection.cpp +++ b/src/game-server/accountconnection.cpp @@ -21,9 +21,10 @@ * $Id$ */ +#include "game-server/accountconnection.hpp" + #include "configuration.h" #include "defines.h" -#include "game-server/accountconnection.hpp" #include "game-server/character.hpp" #include "game-server/gamehandler.hpp" #include "game-server/map.hpp" @@ -260,6 +261,49 @@ void AccountConnection::banCharacter(Character *ch, int duration) send(msg); } +void AccountConnection::sendStatistics() +{ + MessageOut msg(GAMSG_STATISTICS); + MapManager::Maps const &maps = MapManager::getMaps(); + for (MapManager::Maps::const_iterator i = maps.begin(), + i_end = maps.end(); i != i_end; ++i) + { + MapComposite *m = i->second; + if (!m->isActive()) continue; + msg.writeShort(i->first); + int nbThings = 0, nbMonsters = 0; + typedef std::vector< Thing * > Things; + Things const &things = m->getEverything(); + std::vector< int > players; + for (Things::const_iterator j = things.begin(), + j_end = things.end(); j != j_end; ++j) + { + Thing *t = *j; + switch (t->getType()) + { + case OBJECT_CHARACTER: + players.push_back + (static_cast< Character * >(t)->getDatabaseID()); + break; + case OBJECT_MONSTER: + ++nbMonsters; + break; + default: + ++nbThings; + } + } + msg.writeShort(nbThings); + msg.writeShort(nbMonsters); + msg.writeShort(players.size()); + for (std::vector< int >::const_iterator j = players.begin(), + j_end = players.end(); j != j_end; ++j) + { + msg.writeLong(*j); + } + } + send(msg); +} + #if 0 void AccountConnection::playerCreateGuild(int id, const std::string &guildName) { |