From 41ad1e4c9e2a70d0a8811f4b035f0d3018045e61 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 19 Feb 2008 17:37:01 +0000 Subject: client-to-server connection --- src/core/netserver.cc | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) (limited to 'src/core/netserver.cc') diff --git a/src/core/netserver.cc b/src/core/netserver.cc index ba8510d..3473e6a 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -38,9 +38,7 @@ NetServer::~NetServer() for (it = clients.begin(); it != clients.end(); it++) { // notify the game server server()->player_disconnect((*it)->player()); - - con_print << " " << (*it)->host() << ":" << (*it)->port() << " disconnected.\n"; - + con_print << (*it)->host() << ":" << (*it)->port() << " disconnected.\n"; delete (*it); } clients.clear(); @@ -160,7 +158,7 @@ NetClient *NetServer::find_client(Player const *player) // parse server messages /** - * The following incoming messages are parsed; + * The following incoming protocol messages are parsed; * * disconnect * help @@ -182,6 +180,15 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me return; } + // cmd + if (command == "cmd") { + if (message.size() > command.size()+1) { + std::string cmdline(message.substr(command.size()+1)); + server()->exec(client->player(), cmdline); + } + return; + } + // say if (command == "say") { if (message.size() > command.size()+1) { @@ -220,30 +227,14 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me } if (command == "help") { - send(client, "msg info Available commands:\n"); + send(client, "msg info Available protocol messages:\n"); send(client, "msg info help - shows this help message\n"); - send(client, "msg info name nickname - changes your nickname\n"); - send(client, "msg info say text - say something on the public channel\n"); + send(client, "msg info name [nickname] - changes your nickname\n"); + send(client, "msg info say [text] - say something on the public channel\n"); + send(client, "msg info cmd [text] - execute a game command\n"); send(client, "msg info list_players - shows a list of connected players\n"); send(client, "msg info disconnect - disconnect\n"); } - - // execute game functions - Func *function = Func::find(command); - if (function ) { - std::string args; - char c; - if (msgstream >> args) - while (msgstream >> c) - args += c; - if (function ->flags() && Func::Game) { - function->exec(client->player(), args); - } else { - // FIXME instant rcon - function->exec(args); - } - } - } } -- cgit v1.2.3