diff options
-rw-r--r-- | src/network/network_func.h | 2 | ||||
-rw-r--r-- | src/network/network_server.cpp | 12 | ||||
-rw-r--r-- | src/network/network_server.h | 2 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/network/network_func.h b/src/network/network_func.h index a50166e2a..6a21eb80a 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -77,7 +77,7 @@ bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_na void NetworkServerDoMove(ClientID client_id, CompanyID company_id); -void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string); +void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string); void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data = 0, bool from_admin = false); void NetworkServerKickClient(ClientID client_id, const char *reason); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index b770dbda3..d15263e53 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -785,7 +785,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGame() * @param colour The colour of the result. * @param command The command that was executed. */ -NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour, const char *command) +NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour, const std::string &command) { Packet *p = new Packet(PACKET_SERVER_RCON); @@ -1424,22 +1424,20 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(Packet *p) { if (this->status != STATUS_ACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - char command[NETWORK_RCONCOMMAND_LENGTH]; - if (_settings_client.network.rcon_password.empty()) return NETWORK_RECV_STATUS_OKAY; std::string password = p->Recv_string(NETWORK_PASSWORD_LENGTH); - p->Recv_string(command, sizeof(command)); + std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH); if (_settings_client.network.rcon_password.compare(password) != 0) { DEBUG(net, 1, "[rcon] Wrong password from client-id %d", this->client_id); return NETWORK_RECV_STATUS_OKAY; } - DEBUG(net, 3, "[rcon] Client-id %d executed: %s", this->client_id, command); + DEBUG(net, 3, "[rcon] Client-id %d executed: %s", this->client_id, command.c_str()); _redirect_console_to_client = this->client_id; - IConsoleCmdExec(command); + IConsoleCmdExec(command.c_str()); _redirect_console_to_client = INVALID_CLIENT_ID; return NETWORK_RECV_STATUS_OKAY; } @@ -2046,7 +2044,7 @@ void NetworkServerDoMove(ClientID client_id, CompanyID company_id) * @param colour_code The colour of the text. * @param string The actual reply. */ -void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const char *string) +void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string) { NetworkClientSocket::GetByClientID(client_id)->SendRConResult(colour_code, string); } diff --git a/src/network/network_server.h b/src/network/network_server.h index 98b2f9b6e..850b56007 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -89,7 +89,7 @@ public: NetworkRecvStatus SendQuit(ClientID client_id); NetworkRecvStatus SendShutdown(); NetworkRecvStatus SendNewGame(); - NetworkRecvStatus SendRConResult(uint16 colour, const char *command); + NetworkRecvStatus SendRConResult(uint16 colour, const std::string &command); NetworkRecvStatus SendMove(ClientID client_id, CompanyID company_id); NetworkRecvStatus SendClientInfo(NetworkClientInfo *ci); |