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>2011-02-10 18:07:24 +0000
committerStijn Buys <ingar@osirion.org>2011-02-10 18:07:24 +0000
commit9ff5cf6184b9c5183c1f55cfa6c0d08586eb02c9 (patch)
treed50dd2d8ed48acfbb7063d4c073f77cb195106f7 /src/core/netserver.cc
parenta255dbc032d15a4f5024bc60baa19c45ebceecc6 (diff)
Added a local chat channel. The say command defaults to zone chat, global messages can be send with the shout command.
Removed NonSolid flag fro race objects, have race use the local chat channel. Updated to network protocol version 22. Updated developer documentation.
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r--src/core/netserver.cc36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc
index 937d91b..f58f2d4 100644
--- a/src/core/netserver.cc
+++ b/src/core/netserver.cc
@@ -41,6 +41,8 @@ namespace core
NetServer::NetServer(std::string const host, unsigned int const port)
{
con_print << "^BInitializing network server..." << std::endl;
+
+ con_debug << " protocol version " << PROTOCOLVERSION << std::endl;
// initialize variables
netserver_fd = -1;
@@ -280,7 +282,7 @@ void NetServer::receive()
NetClient * NetServer::client_connect(std::string const host, int const port)
{
- con_print << "Client " << host << ":" << port << " connected\n";
+ //con_print << "Client " << host << ":" << port << " connected\n";
NetClient *client = new NetClient(host, port, fd());
if (client->error()) {
@@ -651,8 +653,7 @@ void NetServer::send_inventory_update(NetClient *client, Entity *entity, const u
* inf
* pif
* ping
- * say <text>
- * priv <player> <text>
+ * msg <channel> <text>
* info <id>
* req <id>
* inv <id>
@@ -863,15 +864,26 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me
}
return;
- } else if (command.compare("say") == 0 ) {
- if (message.size() > command.size() + 1) {
- server()->say(client->player(), message.substr(command.size() + 1));
- }
- return;
-
- } else if (command.compare("priv") == 0 ) {
- if (message.size() > command.size() + 1) {
- server()->private_message(client->player(), message.substr(command.size() + 1));
+ } else if (command.compare("msg") == 0 ) {
+ std::string channel;
+ msgstream >> channel;
+
+ if (!channel.size())
+ return;
+
+ const size_t subpos = command.size() + channel.size() + 2;
+ if (message.size() <= subpos)
+ return;
+
+ if (channel.compare("public") == 0) {
+ server()->shout(client->player(), message.substr(subpos));
+
+ } else if (channel.compare("local") == 0) {
+ server()->say(client->player(), message.substr(subpos));
+
+ } else if (channel.compare("private") == 0) {
+
+ server()->say(client->player(), message.substr(subpos));
}
return;
}