Use std::string for CommandContainer text instead of giant static buffer

Use move semantics for CommandContainer instance where feasible
This commit is contained in:
Jonathan G Rennison
2018-08-13 12:16:41 +01:00
parent 957cff34dc
commit 940314a3c7
10 changed files with 90 additions and 42 deletions

View File

@@ -1144,7 +1144,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_COMMAND(Packet
if (GetCommandFlags(cp.cmd) & CMD_CLIENT_ID) cp.p2 = this->client_id;
this->incoming_queue.Append(&cp);
this->incoming_queue.Append(std::move(cp));
return NETWORK_RECV_STATUS_OKAY;
}
@@ -1799,10 +1799,9 @@ void NetworkServerSetCompanyPassword(CompanyID company_id, const char *password,
*/
static void NetworkHandleCommandQueue(NetworkClientSocket *cs)
{
CommandPacket *cp;
std::unique_ptr<CommandPacket> cp;
while ((cp = cs->outgoing_queue.Pop()) != NULL) {
cs->SendCommand(cp);
free(cp);
cs->SendCommand(cp.get());
}
}