Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gameserver.cc25
-rw-r--r--src/core/gameserver.h3
2 files changed, 26 insertions, 2 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 46cb742..3bcc4fe 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -27,6 +27,11 @@ void func_who(Player *player, std::string const &args)
server()->list_players(player);
}
+void func_time(Player *player, std::string const &args)
+{
+ server()->showtime(player);
+}
+
GameServer *GameServer::server_instance = 0;
GameServer::GameServer() : GameInterface()
@@ -69,8 +74,9 @@ GameServer::GameServer() : GameInterface()
server_network = 0;
}
- Func::add("say", (GameFuncPtr) func_say);
- Func::add("who", (GameFuncPtr) func_who);
+ Func::add("say",func_say);
+ Func::add("time", func_time);
+ Func::add("who", func_who);
if (!Cvar::sv_dedicated->value()) {
player_connect(localplayer());
@@ -101,6 +107,7 @@ GameServer::~GameServer()
}
Func::remove("say");
+ Func::remove("time");
Func::remove("who");
server_instance = 0;
@@ -179,6 +186,20 @@ void GameServer::say(Player *player, std::string const &message)
}
}
+void GameServer::showtime(Player *player)
+{
+ 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;
+
+ std::stringstream str;
+ str << "Uptime " << minutes << ":" << seconds << " Local time " << syshours << ":" << sysminutes << ":" << sysseconds;
+ send(player, str.str());
+}
+
void GameServer::broadcast(std::string const & message, Player *ignore_player)
{
// send to application
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index 025ea4d..a7ee159 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -49,6 +49,9 @@ public:
/// a player sends a chat message on the public channel
void say(Player *player, std::string const &args);
+ /// a player requests the current time
+ void showtime(Player *player);
+
/// broadcast a message to all players
void broadcast(std::string const & message, Player *ignore_player = 0);