diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/gameconnection.cc | 16 | ||||
-rw-r--r-- | src/core/gameconnection.h | 9 | ||||
-rw-r--r-- | src/core/gameinterface.cc | 3 | ||||
-rw-r--r-- | src/core/gameinterface.h | 6 | ||||
-rw-r--r-- | src/core/gameserver.cc | 10 | ||||
-rw-r--r-- | src/core/gameserver.h | 9 | ||||
-rw-r--r-- | src/core/zone.h | 2 |
7 files changed, 44 insertions, 11 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc index 2dc0e32..3384418 100644 --- a/src/core/gameconnection.cc +++ b/src/core/gameconnection.cc @@ -74,6 +74,22 @@ GameConnection::~GameConnection() connection_instance = 0; } + +unsigned long GameConnection::timestamp() const +{ + return connection_timestamp; +} + +float GameConnection::time() const +{ + return ((float)(connection_timestamp) / 1000.0f); +} + +bool GameConnection::interactive() const +{ + return true; +} + Info *GameConnection::info(const std::string &label) { // check if we already have the info record diff --git a/src/core/gameconnection.h b/src/core/gameconnection.h index 5880f9b..22af910 100644 --- a/src/core/gameconnection.h +++ b/src/core/gameconnection.h @@ -18,7 +18,7 @@ class GameConnection : public GameInterface { public: GameConnection(std::string const &connectionstr); - ~GameConnection(); + virtual ~GameConnection(); /*----- inspectors ------------------------------------------------ */ @@ -29,10 +29,13 @@ public: inline bool error() const { return !connection_running; } /// returns true if the game is running an interactive module - inline bool interactive() const { return true; } + virtual bool interactive() const; + + /// return the current game time in seconds + virtual float time() const; /// return the current game time - inline unsigned long timestamp() const { return connection_timestamp; } + virtual unsigned long timestamp() const; /*----- mutators -------------------------------------------------- */ diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index 1ed0a67..4b66489 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -114,6 +114,7 @@ void GameInterface::clear() // remove all zones for (Zone::Registry::iterator it = Zone::registry().begin(); it != Zone::registry().end(); it++) { Zone *zone = (*it).second; + con_debug " removing zone " << zone->label() << std::endl; delete zone; } Zone::registry().clear(); @@ -174,7 +175,7 @@ Player *GameInterface::find_player(const std::string &search) } } - if (search.size() <3) + if (search.size() < 3) return 0; for (std::list<Player *>:: iterator it = game_players.begin(); it != game_players.end(); it++) { diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index 7d3e086..dbb235e 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -42,9 +42,6 @@ public: /// show a list of connected players void list_players(); - /// return the current game time, in seconds - float time() const { return ((float)(timestamp()) / 1000.0f); } - /*----- virtual inspectors --------------------------------------- */ /// returns true if the game server can run a time frime @@ -53,6 +50,9 @@ public: /// returns true if the game is running an interactive module virtual bool interactive() const = 0; + /// return the current game time in seconds + virtual float time() const = 0; + /// return the current game time virtual unsigned long timestamp() const = 0; diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index b82946b..b222524 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -226,6 +226,16 @@ GameServer::~GameServer() server_instance = 0; } +unsigned long GameServer::timestamp() const +{ + return server_timestamp; +} + +float GameServer::time() const +{ + return ((float)(server_timestamp) / 1000.0f); +} + Info *GameServer::info(const std::string &label) { return Info::find(label); diff --git a/src/core/gameserver.h b/src/core/gameserver.h index ac5f19e..a8d96db 100644 --- a/src/core/gameserver.h +++ b/src/core/gameserver.h @@ -23,7 +23,7 @@ class GameServer : public GameInterface { public: GameServer(); - ~GameServer(); + virtual ~GameServer(); /*----- inspectors ------------------------------------------------ */ @@ -36,8 +36,11 @@ public: /// returns true if the game is running an interactive module virtual bool interactive() const; - /// current server game time - virtual inline unsigned long timestamp() const { return server_timestamp; } + /// return the current game time in seconds + virtual float time() const; + + /// return the current game time + virtual unsigned long timestamp() const; /// current module inline const Module *module() const { return server_module; } diff --git a/src/core/zone.h b/src/core/zone.h index f93cea2..32463df 100644 --- a/src/core/zone.h +++ b/src/core/zone.h @@ -69,7 +69,7 @@ public: Zone(std::istream & is); /// delete a zone - ~Zone(); + virtual ~Zone(); /* ---- inspectors ----------------------------------------- */ |