Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-06-15 17:39:34 +0000
committerStijn Buys <ingar@osirion.org>2008-06-15 17:39:34 +0000
commitebb56ee4815325675ee878782e2ffa2f40da03d0 (patch)
tree6da7f2179aea3f526b1c3e5ac2738a8128278f2d /src
parent7b07ebcb0351cef57aa2397f49ef25979fab7472 (diff)
time command, alRewindSource for ui sounds
Diffstat (limited to 'src')
-rw-r--r--src/audio/audio.cc1
-rw-r--r--src/audio/sources.h2
-rw-r--r--src/core/gameserver.cc25
-rw-r--r--src/core/gameserver.h3
4 files changed, 29 insertions, 2 deletions
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);