Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 9d3e6775be665a79dea1135613715013c381b642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
   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/net.h"
#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(const 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);
}

}