Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
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
parentcc0a133a616aeff57887b27497e4a978b5697c04 (diff)
standard hail
-rw-r--r--osirion.kdevelop.pcsbin696918 -> 696918 bytes
-rw-r--r--osirion.kdevses15
-rw-r--r--src/audio/Makefile.am4
-rw-r--r--src/audio/audio.cc23
-rw-r--r--src/audio/buffers.cc2
-rw-r--r--src/audio/buffers.h3
-rw-r--r--src/client/client.cc6
-rw-r--r--src/client/client.h5
-rw-r--r--src/client/console.cc28
-rw-r--r--src/client/console.h12
-rw-r--r--src/core/gameserver.cc38
-rw-r--r--src/core/gameserver.h6
-rw-r--r--src/core/netconnection.cc7
-rw-r--r--src/game/game.cc25
-rw-r--r--src/sys/consoleinterface.cc3
15 files changed, 114 insertions, 63 deletions
diff --git a/osirion.kdevelop.pcs b/osirion.kdevelop.pcs
index e3f4194..1c3bec8 100644
--- a/osirion.kdevelop.pcs
+++ b/osirion.kdevelop.pcs
Binary files differ
diff --git a/osirion.kdevses b/osirion.kdevses
index d2d7511..e8415d1 100644
--- a/osirion.kdevses
+++ b/osirion.kdevses
@@ -1,20 +1,7 @@
<?xml version = '1.0' encoding = 'UTF-8'?>
<!DOCTYPE KDevPrjSession>
<KDevPrjSession>
- <DocsAndViews NumberOfDocuments="4" >
- <Doc0 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/netconnection.cc" >
- <View0 Encoding="" Type="Source" />
- </Doc0>
- <Doc1 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/audio/audio.cc" >
- <View0 Encoding="" Type="Source" />
- </Doc1>
- <Doc2 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/application.h" >
- <View0 Encoding="" Type="Source" />
- </Doc2>
- <Doc3 NumberOfViews="1" URL="file:///home/ingar/projects/osirion/osirion-work/src/core/application.cc" >
- <View0 Encoding="" line="378" Type="Source" />
- </Doc3>
- </DocsAndViews>
+ <DocsAndViews NumberOfDocuments="0" />
<pluginList>
<kdevdebugger>
<breakpointList/>
diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am
index d1524cf..f1116d8 100644
--- a/src/audio/Makefile.am
+++ b/src/audio/Makefile.am
@@ -2,5 +2,5 @@ INCLUDES = -I$(top_srcdir)/src
METASOURCES = AUTO
noinst_LTLIBRARIES = libaudio.la
libaudio_la_LDFLAGS = -avoid-version -no-undefined
-noinst_HEADERS = audio.h buffers.h pcm.h wav.h
-libaudio_la_SOURCES = audio.cc buffers.cc pcm.cc wav.cc
+noinst_HEADERS = audio.h buffers.h pcm.h sources.h wav.h
+libaudio_la_SOURCES = audio.cc buffers.cc pcm.cc sources.cc wav.cc
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index 3bd3c62..308667b 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -7,6 +7,7 @@
#include "audio/audio.h"
#include "audio/buffers.h"
#include "audio/pcm.h"
+#include "audio/sources.h"
#include "sys/sys.h"
namespace audio
@@ -15,8 +16,6 @@ namespace audio
ALCdevice *audio_device = 0;
ALCcontext *audio_context = 0;
-ALuint source = 0;
-
void init()
{
con_print << "^BInitializing audio...";
@@ -37,12 +36,12 @@ void init()
alGetError();
Buffers::init();
+
+ Sources::init();
//con_debug << " device ^B" << alcGetString(audio_device, ALC_DEFAULT_DEVICE_SPECIFIER) << std::endl;
- load("ui/chat");
-
- // default sound source
- alGenSources(1, &source);
+ load("com/chat");
+ load("com/hail");
}
void load (const char *name)
@@ -54,6 +53,10 @@ void shutdown()
{
con_print << "^BShutting down audio...";
+ Sources::shutdown();
+
+ Buffers::shutdown();
+
if (audio_context) {
alcMakeContextCurrent(0);
alcDestroyContext(audio_context);
@@ -64,14 +67,14 @@ void shutdown()
alcCloseDevice(audio_device);
audio_device = 0;
}
-
- alDeleteSources(1, &source);
}
void play(const char *name)
{
- Buffers::bind(source, std::string(name));
- alSourcePlay(source);
+ if (Sources::available(0)) {
+ Buffers::bind(Sources::ui(), std::string(name));
+ alSourcePlay(Sources::ui());
+ }
}
}
diff --git a/src/audio/buffers.cc b/src/audio/buffers.cc
index 9223380..f7fbbb5 100644
--- a/src/audio/buffers.cc
+++ b/src/audio/buffers.cc
@@ -23,7 +23,7 @@ void Buffers::init()
alGenBuffers(MAXBUFFERS, buffers);
if ((error = alGetError()) != AL_NO_ERROR) {
- con_warn << "Error " << error << " initializing OpenAL bufers!" << std::endl;
+ con_warn << "Error " << error << " initializing OpenAL buffers!" << std::endl;
return;
}
}
diff --git a/src/audio/buffers.h b/src/audio/buffers.h
index e61ba7b..53137e9 100644
--- a/src/audio/buffers.h
+++ b/src/audio/buffers.h
@@ -23,7 +23,6 @@ class Buffers {
public:
static void init();
static void shutdown();
- static void clear();
/// find previously loaded PCM data
static size_t find(std::string name);
@@ -35,6 +34,8 @@ public:
static void bind(ALuint source, std::string name);
private:
+ static void clear();
+
typedef std::map<std::string, size_t>::iterator iterator;
static std::map<std::string, size_t> registry;
diff --git a/src/client/client.cc b/src/client/client.cc
index ed31c65..80b983e 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -166,5 +166,11 @@ void Client::notify_sound(const char * name)
audio::play(name);
}
+void Client::notify_message(std::string const & message)
+{
+ con_print << message << std::endl;
+ console()->notify(message);
+}
+
} // namespace client
diff --git a/src/client/client.h b/src/client/client.h
index 57488ec..8bd6d45 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -28,8 +28,11 @@ public:
/// quit the client
virtual void quit(int status);
- /// sound notifications from the core to the application
+ /// sound notifications from the core
virtual void notify_sound(const char * name);
+
+ /// text notifications from the core
+ virtual void notify_message(std::string const & message);
};
diff --git a/src/client/console.cc b/src/client/console.cc
index ac977f2..db2aa83 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -102,7 +102,7 @@ void Console::toggle()
} else {
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_ShowCursor(SDL_DISABLE);
- clear_notify();
+ //clear_notify();
}
setkeyboardmode(visible());
@@ -527,28 +527,12 @@ void Console::clear_notify()
notify_pos = 0;
}
-void Console::flush()
+void Console::notify(std::string const & message)
{
- char line[MAXCMDSIZE];
-
- while(consoleinterface_buffer.getline(line, MAXCMDSIZE-1)) {
-
- while (consoleinterface_text.size() >= sys::MAXCONLINES) {
- consoleinterface_text.pop_front();
- }
- consoleinterface_text.push_back(std::string(line));
-
- // save notification
- notify_text[notify_pos] = line;
- notify_time[notify_pos] = core::application()->time();
- notify_pos = (notify_pos+1) % MAXNOTIFYLINES;
-
- // print to stdout
- print_ansi(line);
- std::cout << std::endl;
- }
-
- consoleinterface_buffer.clear();
+ // save notification
+ notify_text[notify_pos] = message;
+ notify_time[notify_pos] = core::application()->time();
+ notify_pos = (notify_pos+1) % MAXNOTIFYLINES;
}
} // namespace client
diff --git a/src/client/console.h b/src/client/console.h
index 5bdbde6..533a8be 100644
--- a/src/client/console.h
+++ b/src/client/console.h
@@ -20,11 +20,8 @@ public:
Console();
virtual ~Console();
- virtual void flush();
-
- void draw_console();
-
- void draw_notify();
+ /// add notification
+ void notify(std::string const &message);
/// clear notifications
void clear_notify();
@@ -56,6 +53,11 @@ public:
/// shutdown the client console
static void shutdown();
+protected:
+ void draw_console();
+
+ void draw_notify();
+
private:
// notifications
size_t notify_pos;
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") {
diff --git a/src/game/game.cc b/src/game/game.cc
index aa78e41..ea72ce0 100644
--- a/src/game/game.cc
+++ b/src/game/game.cc
@@ -102,6 +102,15 @@ void func_buy(core::Player *player, std::string const &args)
core::server()->send(player, "Usage: buy <" + helpstr + "^N>");
}
}
+
+/// a player sends standard hails
+void func_hail(core::Player *player, std::string const &args)
+{
+ core::server()->send(player, "You broadcast a standard standard hail.");
+ core::server()->broadcast("^B" + player->name() + " ^Bbroadcasts a standard hail!", player);
+ core::server()->broadcast_sound("com/hail");
+}
+
/*----- Game ------------------------------------------------------ */
Game::Game() : core::Module("Project::OSiRiON")
@@ -253,16 +262,24 @@ void Game::init()
if (!default_shipmodel) {
con_error << "No default ship model in ini/ships.ini!\n";
+ abort();
return;
}
// add engine game functions
- core::Func::add("buy", (core::GameFuncPtr) func_buy);
- core::Func::add("join", (core::GameFuncPtr) func_join);
- core::Func::add("spectate", (core::GameFuncPtr) func_spectate);
+ core::Func *func = 0;
+ func = core::Func::add("buy", (core::GameFuncPtr) func_buy);
+ func->set_info("buy a ship");
+ func = core::Func::add("join", (core::GameFuncPtr) func_join);
+ func->set_info("join the game");
+ func = core::Func::add("hail", (core::GameFuncPtr) func_hail);
+ func->set_info("send a standard hail");
+ func = core::Func::add("spectate", (core::GameFuncPtr) func_spectate);
+ func->set_info("leave the game and spectate");
// add engine core functions
- core::Func::add("list_ship", (core::FuncPtr) func_list_ship);
+ func = core::Func::add("list_ship", (core::FuncPtr) func_list_ship);
+ func->set_info("list ship statistics");
// add engine game variables
core::Cvar::set("g_testgamevariable", "1", core::Cvar::Game);
diff --git a/src/sys/consoleinterface.cc b/src/sys/consoleinterface.cc
index a300ea1..eaecdea 100644
--- a/src/sys/consoleinterface.cc
+++ b/src/sys/consoleinterface.cc
@@ -161,6 +161,9 @@ void ConsoleInterface::print_ansi(const char *line)
}
c++;
}
+
+ if (consoleinterface_ansi)
+ std::cout << "\033[0;39m";
}
} // namespace sys