diff options
author | Stijn Buys <ingar@osirion.org> | 2008-11-08 16:51:28 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-11-08 16:51:28 +0000 |
commit | 6cd1a38f1d3a0a45846d63a75475400372af1277 (patch) | |
tree | 35bc79e34fe727fc387103a183f80b203c6dfa12 /src/core/netplayer.cc | |
parent | 731dfb8f3ca9c34e4160021cb221c3056c00dbf9 (diff) |
moved message functions into Player class
Diffstat (limited to 'src/core/netplayer.cc')
-rw-r--r-- | src/core/netplayer.cc | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/core/netplayer.cc b/src/core/netplayer.cc new file mode 100644 index 0000000..24a597f --- /dev/null +++ b/src/core/netplayer.cc @@ -0,0 +1,76 @@ +/* + net/netplayer.cc + This file is part of the Osirion project and is distributed under + the terms of the GNU General Public License version 2 +*/ + +#include <string> + +#include "core/netplayer.h" +#include "sys/sys.h" + +namespace core +{ + +NetPlayer::NetPlayer(NetClient *client) : Player() +{ + + player_client = client; +} + +NetPlayer::~NetPlayer() +{ +} + +void NetPlayer::sound(const std::string name) +{ + std::string msg("msg snd "); + msg.append(name); + msg += '\n'; + + player_client->send_raw(msg); +} + +void NetPlayer::message(Message::Channel channel, const std::string text) +{ + if (!text.size()) + return; + + std::string msg_channel; + switch(channel) { + case core::Message::Info: // Info message + msg_channel.assign("info"); + break; + + case core::Message::Local: // Chat message in the local zone + msg_channel.assign("local"); + break; + + case core::Message::Public: // Public chat message + msg_channel.assign("public"); + break; + + case core::Message::Private: // Private chat message + msg_channel.assign("private"); + break; + + case core::Message::RCon: // RCon message + msg_channel.assign("rcon"); + break; + + default: + con_warn << "message on unknown channel " << channel << "!" << std::endl; + return; + break; + } + + std::string msg("msg "); + msg.append(msg_channel); + msg += ' '; + msg.append(text); + msg += '\n'; + + player_client->send_raw(msg); +} + +} |