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>2008-02-19 17:37:01 +0000
committerStijn Buys <ingar@osirion.org>2008-02-19 17:37:01 +0000
commit41ad1e4c9e2a70d0a8811f4b035f0d3018045e61 (patch)
treeabe7fa4544c22ba0cfa6375fd56f2e596f1bf626 /src/core/netserver.cc
parent7daaf66869b7b9f85f71b1aa5e9a1b4c40710f33 (diff)
client-to-server connection
Diffstat (limited to 'src/core/netserver.cc')
-rw-r--r--src/core/netserver.cc39
1 files changed, 15 insertions, 24 deletions
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);
- }
- }
-
}
}