From 4a2bad92171ff8a9a248599f47087cfe39e93653 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 18 May 2008 09:21:20 +0000 Subject: OpenAL support --- src/core/application.cc | 11 +++++++++++ src/core/application.h | 8 ++++++++ src/core/gameserver.cc | 25 +++++++++++++++---------- src/core/netconnection.cc | 5 +++-- 4 files changed, 37 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/application.cc b/src/core/application.cc index 67bb952..db97af8 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -377,4 +377,15 @@ void Application::load_commandline(int count, char **arguments) cmd() << '\n'; } +void Application::notify_sound(const char *name) +{ + // the default implementation does nothing. + // Dedicated servers don't need sounds +} + +void Application::notify_message(std::string const & message) +{ + con_print << message << std::endl; +} + } diff --git a/src/core/application.h b/src/core/application.h index bec53d9..aad3ac9 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -56,6 +56,14 @@ public: /// quit the application without proper shutdown virtual void quit(int status); +/*----- notifications --------------------------------------------- */ + + /// sound notifications from the core to the application + virtual void notify_sound(const char * name); + + /// text notifications from the core to the application + virtual void notify_message(std::string const & message); + /*----- static --------------------------------------------------- */ /// a pointer to the current application instance diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index fb828e2..54d667b 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -8,6 +8,7 @@ #include "auxiliary/functions.h" #include "sys/sys.h" +#include "core/application.h" #include "core/cvar.h" #include "core/func.h" #include "core/gameserver.h" @@ -143,15 +144,19 @@ void GameServer::say(Player *player, std::string const &message) if (!message.size()) return; - // send to console - con_print << "^B" << player->name() << "^F:^B " << message << std::endl; + std::string notification("^B"); + notification.append(player->name()); + notification.append("^F:^B "); + notification.append(message); + + // send to application + application()->notify_message(notification); + application()->notify_sound("ui/chat.wav"); // broadcast to remote clients if (server_network) { - std::string netmessage("msg public ^B"); - netmessage.append(player->name()); - netmessage.append("^F:^B "); - netmessage.append(message); + std::string netmessage("msg public "); + netmessage.append(notification); netmessage += '\n'; server_network->broadcast(netmessage); } @@ -159,8 +164,8 @@ void GameServer::say(Player *player, std::string const &message) void GameServer::broadcast(std::string const & message, Player *ignore_player) { - // send to console - con_print << message << "\n"; + // send to application + application()->notify_message(message); // broadcast to remote clients if (server_network) { @@ -173,9 +178,9 @@ void GameServer::broadcast(std::string const & message, Player *ignore_player) void GameServer::send(Player *player, std::string message) { - // send to console + // send to application if (player->id() == localplayer()->id()) { - con_print << message << "\n"; + application()->notify_message(message); } // send to remote clients diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 22614d2..8da8b1b 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -283,12 +283,13 @@ void NetConnection::parse_incoming_message(const std::string & message) if (msgstream >> level) { if (level =="info") { if (message.size() > 9) { - con_print << message.substr(9) << std::endl; + application()->notify_message(message.substr(9)); } } else if (level == "public") { // FIXME - separate sender nickname if (message.size() > 11) { - con_print << message.substr(11) << std::endl; + application()->notify_message(message.substr(11)); + application()->notify_sound("ui/chat.wav"); } } -- cgit v1.2.3