Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-05-18 19:22:39 +0000
committerStijn Buys <ingar@osirion.org>2008-05-18 19:22:39 +0000
commit2f4c20a0b6fa0397d623d883ee48ba59563f1e2f (patch)
tree2186c4ada36a9bc832a89c662029d3b12bf1840e /src/core
parentcc0a133a616aeff57887b27497e4a978b5697c04 (diff)
standard hail
Diffstat (limited to 'src/core')
-rw-r--r--src/core/gameserver.cc38
-rw-r--r--src/core/gameserver.h6
-rw-r--r--src/core/netconnection.cc7
3 files changed, 48 insertions, 3 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc
index 54d667b..85c00ab 100644
--- a/src/core/gameserver.cc
+++ b/src/core/gameserver.cc
@@ -151,7 +151,7 @@ void GameServer::say(Player *player, std::string const &message)
// send to application
application()->notify_message(notification);
- application()->notify_sound("ui/chat.wav");
+ application()->notify_sound("com/chat");
// broadcast to remote clients
if (server_network) {
@@ -165,7 +165,8 @@ void GameServer::say(Player *player, std::string const &message)
void GameServer::broadcast(std::string const & message, Player *ignore_player)
{
// send to application
- application()->notify_message(message);
+ if (ignore_player != game()->localplayer())
+ application()->notify_message(message);
// broadcast to remote clients
if (server_network) {
@@ -176,6 +177,21 @@ void GameServer::broadcast(std::string const & message, Player *ignore_player)
}
}
+void GameServer::broadcast_sound(std::string const & sound, Player *ignore_player)
+{
+ // send to application
+ if (ignore_player != game()->localplayer())
+ application()->notify_sound(sound.c_str());
+
+ // broadcast to remote clients
+ if (server_network) {
+ std::string netmessage("msg snd ");
+ netmessage.append(sound);
+ netmessage += '\n';
+ server_network->broadcast(netmessage, ignore_player);
+ }
+}
+
void GameServer::send(Player *player, std::string message)
{
// send to application
@@ -195,6 +211,24 @@ void GameServer::send(Player *player, std::string message)
}
}
+void GameServer::send_sound(Player *player, std::string sound)
+{
+ if (player->id() == localplayer()->id()) {
+ application()->notify_sound(sound.c_str());
+ }
+
+ // send to remote clients
+ if (server_network) {
+ NetClient *client = server_network->find_client(player);
+ if (client) {
+ std::string netmessage("msg snd ");
+ netmessage.append(sound);
+ netmessage += '\n';
+ server_network->send(client, netmessage);
+ }
+ }
+}
+
void GameServer::exec(Player *player, std::string const & cmdline)
{
std::string command;
diff --git a/src/core/gameserver.h b/src/core/gameserver.h
index bcd9cc3..c35ef74 100644
--- a/src/core/gameserver.h
+++ b/src/core/gameserver.h
@@ -52,9 +52,15 @@ public:
/// broadcast a message to all players
void broadcast(std::string const & message, Player *ignore_player = 0);
+ /// broadcast a sound to all players
+ void broadcast_sound(std::string const & sound, Player *ignore_player = 0);
+
/// send a message to a single player
void send(Player *player, std::string message);
+ /// send a sound to a single player
+ void send_sound(Player *player, std::string sound);
+
/// a player sends a command to the game server
void exec(Player *player, std::string const &cmdline);
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc
index 8da8b1b..aa3db1a 100644
--- a/src/core/netconnection.cc
+++ b/src/core/netconnection.cc
@@ -265,6 +265,7 @@ void NetConnection::transmit()
* disconnect
* msg info <text>
* msg public <name> <text>
+ * msg snd <soundname>
* die
* ent
* frame
@@ -289,9 +290,13 @@ void NetConnection::parse_incoming_message(const std::string & message)
// FIXME - separate sender nickname
if (message.size() > 11) {
application()->notify_message(message.substr(11));
- application()->notify_sound("ui/chat.wav");
+ application()->notify_sound("com/chat.wav");
}
+ } else if (level == "snd") {
+ if (message.size() > 8) {
+ application()->notify_sound(message.substr(8).c_str());
+ }
}
}
} else if (command == "connect") {