Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-02-04 13:23:05 +0000
committerStijn Buys <ingar@osirion.org>2011-02-04 13:23:05 +0000
commita69521970793424754421c8a5fba2eb465e817e6 (patch)
treef44f178a27f621f0f11ed5959418d83ee399ffcd /src/core/gameinterface.h
parent7129e31075e021112ba6a859af29513e69671626 (diff)
Made time(), timestamp() and related methods non-virtual, corrects a crash when
the dedicated server quits.
Diffstat (limited to 'src/core/gameinterface.h')
-rw-r--r--src/core/gameinterface.h55
1 files changed, 40 insertions, 15 deletions
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