summaryrefslogtreecommitdiff
path: root/src/game-server
diff options
context:
space:
mode:
Diffstat (limited to 'src/game-server')
-rw-r--r--src/game-server/accountconnection.cpp46
-rw-r--r--src/game-server/accountconnection.hpp7
-rw-r--r--src/game-server/main-game.cpp1
3 files changed, 52 insertions, 2 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)
{
diff --git a/src/game-server/accountconnection.hpp b/src/game-server/accountconnection.hpp
index b591df16..59652dd5 100644
--- a/src/game-server/accountconnection.hpp
+++ b/src/game-server/accountconnection.hpp
@@ -64,7 +64,12 @@ class AccountConnection : public Connection
/**
* Sends ban message.
*/
- void banCharacter(Character *, int);
+ void banCharacter(Character *, int);
+
+ /**
+ * Gathers statistics and sends them.
+ */
+ void sendStatistics();
#if 0
/**
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index 0325f28c..db8fee45 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -301,6 +301,7 @@ int main(int argc, char *argv[])
// Print world time at 10 second intervals to show we're alive
if (worldTime % 100 == 0) {
LOG_INFO("World time: " << worldTime);
+ accountHandler->sendStatistics();
}
// Handle all messages that are in the message queues