From 9ff5cf6184b9c5183c1f55cfa6c0d08586eb02c9 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 10 Feb 2011 18:07:24 +0000 Subject: 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. --- src/core/netserver.cc | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'src/core/netserver.cc') 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 - * priv + * msg * info * req * inv @@ -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; } -- cgit v1.2.3