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>2008-02-18 17:52:15 +0000
committerStijn Buys <ingar@osirion.org>2008-02-18 17:52:15 +0000
commit0b8582a9aa825024edbd0a21c6287bfcccec28de (patch)
tree2d9a46c60b028300b1b9133b84764b6c39964c33 /src/core/gameserver.h
parent982562fa19bb87a3dab352e562f386f61c171b7b (diff)
core redesign, part II
Diffstat (limited to 'src/core/gameserver.h')
-rw-r--r--src/core/gameserver.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
new file mode 100644
index 0000000..ba64f2e
--- /dev/null
+++ b/src/core/gameserver.h
@@ -0,0 +1,75 @@
+/*
+ core/gameserver.h
+ This file is part of the Osirion project and is distributed under
+ the terms of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CORE_GAMESERVER_H__
+#define __INCLUDED_CORE_GAMESERVER_H__
+
+#include "core/gameinterface.h"
+#include "core/module.h"
+#include "core/netserver.h"
+
+namespace core
+{
+
+/// the core game server
+/** the core game server runs the game module. Network access is enabled
+ * for the dedicated server or the client with private server enabled.
+ */
+class GameServer : public GameInterface
+{
+public:
+ GameServer();
+ ~GameServer();
+
+/*----- inspectors ------------------------------------------------ */
+
+ /// returns true if the game server can run a time frime
+ bool running();
+
+ /// returns true if the game server can not run a time frime
+ inline bool error() { return !server_running; }
+
+/*----- mutators -------------------------------------------------- */
+
+ /// is called when a player connects to the game server
+ void player_connect(Player *player);
+
+ /// a caleld when a player disconnects from the game server
+ void player_disconnect(Player *player);
+
+ /// run a game server time frame
+ void frame(float seconds);
+
+ /// a player sends a chat message on the public channel
+ void say(Player *player, std::string const &args);
+
+ /// broadcast a message to all players
+ void broadcast(std::string const & message, int ignoreplayer = -1);
+
+ /// send a message to a single player
+ void send(Player const *player, std::string message);
+
+/*----- static ---------------------------------------------------- */
+
+ /// retuen the current game server
+ static inline GameServer *instance() { return server_instance; }
+
+protected:
+ /// abort runing
+ void abort();
+private:
+ bool server_running;
+ Module *server_module;
+ static GameServer *server_instance;
+ NetServer *server_network;
+
+};
+
+inline GameServer *server() { return GameServer::instance(); }
+
+}
+
+#endif // __INCLUDED_CORE_GAMESERVER_H__