diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/application.cc | 8 | ||||
-rw-r--r-- | src/core/gameconnection.h | 8 | ||||
-rw-r--r-- | src/core/gameinterface.h | 9 | ||||
-rw-r--r-- | src/core/gameserver.cc | 37 | ||||
-rw-r--r-- | src/core/gameserver.h | 11 |
5 files changed, 33 insertions, 40 deletions
diff --git a/src/core/application.cc b/src/core/application.cc index 3f08a36..3b30962 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -378,15 +378,11 @@ void Application::disconnect() void Application::frame(float seconds) { + application_time += seconds; + // execute commands in the buffer CommandBuffer::exec(); - application_time += seconds; - - // don't run zero lenght time frames - //if (seconds == 0.0f) - // return; - if (!connected()) return; diff --git a/src/core/gameconnection.h b/src/core/gameconnection.h index 973d96f..95df9f3 100644 --- a/src/core/gameconnection.h +++ b/src/core/gameconnection.h @@ -23,14 +23,16 @@ public: /*----- inspectors ------------------------------------------------ */ /// returns true if the game connection can run a time frime - inline bool running() { return connection_running; } + inline bool running() const { return connection_running; } /// returns true if the game connection can not run a time frime - inline bool error() { return !connection_running; } + inline bool error() const { return !connection_running; } /// returns true if the game is running an interactive module - inline bool interactive() { return true; } + inline bool interactive() const { return true; } + /// return the current game time + inline float time() const { return game_clientframetime; } /*----- mutators -------------------------------------------------- */ diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index b6d7cb6..fea86fe 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -26,7 +26,7 @@ public: typedef std::list<Player *> Players; /*----- inspectors ---------------------------------------------- */ - + /// return the local player inline Player *localplayer() { return &game_localplayer; } @@ -52,10 +52,13 @@ public: /*----- virtual inspectors --------------------------------------- */ /// returns true if the game server can run a time frime - virtual bool running() = 0; + virtual bool running() const = 0; /// returns true if the game is running an interactive module - virtual bool interactive() = 0; + virtual bool interactive() const = 0; + + /// return the current game time + virtual float time() const = 0; /*----- mutators ------------------------------------------------- */ diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 4037c70..b6767ad 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -35,7 +35,18 @@ void func_who(std::string const &args) void func_time(std::string const &args) { - server()->showtime(); + using namespace std; + + int minutes = (int) floorf(server()->time() / 60.0f); + int seconds = (int) floorf(server()->time() - (float) minutes* 60.0f); + + int syshours = sys::time() / 3600; + int sysminutes = (sys::time() - syshours * 3600) / 60; + int sysseconds = sys::time() % 60; + + con_print << + "Uptime " << minutes << ":" << setfill('0') << setw(2) << seconds << + " Local time " << setfill(' ') << setw(2) << syshours << ":" << setfill('0') << setw(2) << sysminutes << ":" << setw(2) << sysseconds << setfill(' ') << std::endl; } void func_mute(std::string const &args) @@ -220,7 +231,7 @@ void GameServer::abort() server_running = false; } -bool GameServer::interactive() +bool GameServer::interactive() const { if (!server_module) { return false; @@ -229,22 +240,6 @@ bool GameServer::interactive() } } -void GameServer::showtime() -{ - using namespace std; - - int minutes = (int) floorf(server_time / 60.0f); - int seconds = (int) floorf(server_time - (float) minutes* 60.0f); - - int syshours = sys::time() / 3600; - int sysminutes = (sys::time() - syshours * 3600) / 60; - int sysseconds = sys::time() % 60; - - con_print << - "Uptime " << minutes << ":" << setfill('0') << setw(2) << seconds << - " Server localtime " << setfill(' ') << setw(2) << syshours << ":" << setfill('0') << setw(2) << sysminutes << ":" << setw(2) << sysseconds << setfill(' ') << std::endl; -} - Player *GameServer::find_player(std::string const search) { using aux::lowercase; @@ -497,20 +492,20 @@ void GameServer::exec(Player *player, std::string const & cmdline) if ((function ->flags() & Func::Game) == Func::Game) { function->exec(player, args); return; + } else if ((function->flags() & Func::Shared) == Func::Shared) { // enable rcon buffering - console()->buffer_rcon(true); + console()->set_rcon(true); function->exec(args); char line[MAXCMDSIZE]; - while(console()->buffer().getline(line, MAXCMDSIZE-1)) { send(player, std::string(line)); } // disable rcon buffering - console()->buffer_rcon(false); + console()->set_rcon(false); return; } } diff --git a/src/core/gameserver.h b/src/core/gameserver.h index 0dfdd9d..550dd99 100644 --- a/src/core/gameserver.h +++ b/src/core/gameserver.h @@ -28,19 +28,16 @@ public: /*----- inspectors ------------------------------------------------ */ /// returns true if the game server can run a time frime - inline bool running() { return server_running; } + inline bool running() const { return server_running; } /// returns true if the game server can not run a time frime - inline bool error() { return !server_running; } + inline bool error() const { return !server_running; } /// returns true if the game is running an interactive module - bool interactive(); - - /// show the current time - void showtime(); + virtual bool interactive() const; /// current server game time - inline float time() const { return server_time; } + virtual inline float time() const { return server_time; } /*----- mutators -------------------------------------------------- */ |