From a69521970793424754421c8a5fba2eb465e817e6 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 4 Feb 2011 13:23:05 +0000 Subject: Made time(), timestamp() and related methods non-virtual, corrects a crash when the dedicated server quits. --- src/core/gameinterface.h | 55 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'src/core/gameinterface.h') diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index 98894e7..369b828 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -53,37 +53,50 @@ public: /// show a list of connected players void list_players(); - /*----- virtual inspectors --------------------------------------- */ - /// returns true if the game server can run a time frime - virtual bool running() const = 0; + inline bool running() const { + return game_running; + } + + inline bool error() const { + return !game_running; + } /// 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; + inline bool interactive() const { + return game_interactive; + } - /// return the current game time - virtual unsigned long timestamp() const = 0; + /// return the current game time, in seconds + inline float time() const { + return ((float)(game_timestamp) / 1000.0f); + } + /** + * @brief return the current game time, in milliseconds. + * 1000 milliseconds equals one second. + */ + inline unsigned long timestamp() const { + return game_timestamp; + } + + /*----- virtual inspectors --------------------------------------- */ + /// request info record with id virtual Info *request_info(const unsigned int id) = 0; /// request inventory for entity with id virtual Inventory *request_inventory(Entity *entity) = 0; - void set_playerlist_timestamp(const unsigned long timestamp); - - /*----- mutators ------------------------------------------------- */ /// clear all game variables, game functions and entities void clear(); - - /*----- virtual mutators ------------------------------------------ */ - + void set_playerlist_timestamp(const unsigned long timestamp); + + virtual void abort(); + /// run one game time frame /// @param timestamp current application time virtual void frame(unsigned long timestamp) = 0; @@ -99,6 +112,18 @@ protected: /// timestamp of the time the playerlist was last changed unsigned long game_playerlist_timestamp; + + void set_timestamp(unsigned long timestamp); + + void set_running(const bool running); + + void set_interactive(const bool interactive); + +private: + bool game_running; + bool game_interactive; + + unsigned long game_timestamp; }; /// global local player instance -- cgit v1.2.3