diff options
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/network_admin.cpp | 12 | ||||
-rw-r--r-- | src/network/network_admin.h | 4 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index c58996711..82c9881bf 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -514,11 +514,9 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Pack { if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - char json[NETWORK_GAMESCRIPT_JSON_LENGTH]; + std::string json = p->Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH); - p->Recv_string(json, sizeof(json)); - - DEBUG(net, 6, "[admin] GameScript JSON from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), json); + DEBUG(net, 6, "[admin] GameScript JSON from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), json.c_str()); Game::NewEvent(new ScriptEventAdminPort(json)); return NETWORK_RECV_STATUS_OKAY; @@ -561,12 +559,12 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendConsole(const char *origi * Send GameScript JSON output. * @param json The JSON string. */ -NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const char *json) +NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const std::string_view json) { /* At the moment we cannot transmit anything larger than MTU. So we limit * the maximum amount of json data that can be sent. Account also for * the trailing \0 of the string */ - if (strlen(json) + 1 >= NETWORK_GAMESCRIPT_JSON_LENGTH) return NETWORK_RECV_STATUS_OKAY; + if (json.size() + 1 >= NETWORK_GAMESCRIPT_JSON_LENGTH) return NETWORK_RECV_STATUS_OKAY; Packet *p = new Packet(ADMIN_PACKET_SERVER_GAMESCRIPT); @@ -941,7 +939,7 @@ void NetworkAdminConsole(const char *origin, const char *string) * Send GameScript JSON to the admin network (if they did opt in for the respective update). * @param json The JSON data as received from the GameScript. */ -void NetworkAdminGameScript(const char *json) +void NetworkAdminGameScript(const std::string_view json) { for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::IterateActive()) { if (as->update_frequency[ADMIN_UPDATE_GAMESCRIPT] & ADMIN_FREQUENCY_AUTOMATIC) { diff --git a/src/network/network_admin.h b/src/network/network_admin.h index 0e443d08f..189acb6f9 100644 --- a/src/network/network_admin.h +++ b/src/network/network_admin.h @@ -64,7 +64,7 @@ public: NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data); NetworkRecvStatus SendRcon(uint16 colour, const char *command); NetworkRecvStatus SendConsole(const char *origin, const char *command); - NetworkRecvStatus SendGameScript(const char *json); + NetworkRecvStatus SendGameScript(const std::string_view json); NetworkRecvStatus SendCmdNames(); NetworkRecvStatus SendCmdLogging(ClientID client_id, const CommandPacket *cp); NetworkRecvStatus SendRconEnd(const char *command); @@ -110,7 +110,7 @@ void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_i void NetworkAdminUpdate(AdminUpdateFrequency freq); void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const char *string); void NetworkAdminConsole(const char *origin, const char *string); -void NetworkAdminGameScript(const char *json); +void NetworkAdminGameScript(const std::string_view json); void NetworkAdminCmdLogging(const NetworkClientSocket *owner, const CommandPacket *cp); #endif /* NETWORK_ADMIN_H */ |