From ebb56ee4815325675ee878782e2ffa2f40da03d0 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 15 Jun 2008 17:39:34 +0000 Subject: time command, alRewindSource for ui sounds --- src/audio/audio.cc | 1 + src/audio/sources.h | 2 ++ src/core/gameserver.cc | 25 +++++++++++++++++++++++-- src/core/gameserver.h | 3 +++ 4 files changed, 29 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/audio/audio.cc b/src/audio/audio.cc index 308667b..842395f 100644 --- a/src/audio/audio.cc +++ b/src/audio/audio.cc @@ -72,6 +72,7 @@ void shutdown() void play(const char *name) { if (Sources::available(0)) { + alSourceRewind(Sources::ui()); Buffers::bind(Sources::ui(), std::string(name)); alSourcePlay(Sources::ui()); } diff --git a/src/audio/sources.h b/src/audio/sources.h index f3d6470..08a2a41 100644 --- a/src/audio/sources.h +++ b/src/audio/sources.h @@ -25,6 +25,8 @@ public: static bool available(size_t index) { return source_available[index]; } + static ALuint source(size_t index) { return sources[index]; } + /// the sources for user interface sounds static inline ALuint ui() { return sources[0]; } 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); -- cgit v1.2.3