diff options
author | truelight <truelight@openttd.org> | 2005-01-15 20:09:16 +0000 |
---|---|---|
committer | truelight <truelight@openttd.org> | 2005-01-15 20:09:16 +0000 |
commit | 24c9e6ff66c6386a182b0fe5eef5f371793b468e (patch) | |
tree | be21df9ed89b0080e4d32a5e54c3f2dffd9f3437 /network_client.c | |
parent | e6d31cb89c43feebcd114d197166588e7ede72d3 (diff) | |
download | openttd-24c9e6ff66c6386a182b0fe5eef5f371793b468e.tar.xz |
(svn r1527) -Add: RCon (Remote Connection). A server can set:
'set rcon_pw <password>'
Which enables rcon. A client can now do:
'rcon <password> "<command>"'
The command will be executed on the server. (guru3)
-Fix: 'kick 1' did crash dedicated servers
-Fix: server password is now correctly saved
!!Warning!!: do not give your rcon password to people you do not thrust!
Diffstat (limited to 'network_client.c')
-rw-r--r-- | network_client.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/network_client.c b/network_client.c index cf64e1485..29821a5a5 100644 --- a/network_client.c +++ b/network_client.c @@ -10,6 +10,7 @@ #include "gfx.h" #include "window.h" #include "settings.h" +#include "console.h" // This file handles all the client-commands @@ -246,6 +247,14 @@ DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_QUIT)(const char *leavemsg) NetworkSend_Packet(p, MY_CLIENT); } +DEF_CLIENT_SEND_COMMAND_PARAM(PACKET_CLIENT_RCON)(const char *pass, const char *command) +{ + Packet *p = NetworkSend_Init(PACKET_CLIENT_RCON); + NetworkSend_string(p, pass); + NetworkSend_string(p, command); + NetworkSend_Packet(p, MY_CLIENT); +} + // ********** // Receiving functions @@ -741,6 +750,18 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_NEWGAME) return NETWORK_RECV_STATUS_SERVER_ERROR; } +DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_RCON) +{ + char rcon_out[NETWORK_RCONCOMMAND_LENGTH]; + uint16 color_code; + + color_code = NetworkRecv_uint16(MY_CLIENT, p); + NetworkRecv_string(MY_CLIENT, p, rcon_out, sizeof(rcon_out)); + + IConsolePrint(color_code, rcon_out); + + return NETWORK_RECV_STATUS_OKAY; +} @@ -782,6 +803,8 @@ static NetworkClientPacket* const _network_client_packet[] = { RECEIVE_COMMAND(PACKET_SERVER_ERROR_QUIT), RECEIVE_COMMAND(PACKET_SERVER_SHUTDOWN), RECEIVE_COMMAND(PACKET_SERVER_NEWGAME), + RECEIVE_COMMAND(PACKET_SERVER_RCON), + NULL, /*PACKET_CLIENT_RCON,*/ }; // If this fails, check the array above with network_data.h |