diff options
author | rubidium42 <rubidium@openttd.org> | 2021-05-14 18:12:37 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-05-15 10:20:50 +0200 |
commit | e6703eac6853851f310923760b194ee4c875251b (patch) | |
tree | 57efb2579076de6bd1d15fc7b0b56f956122ef64 | |
parent | 44ca7d93773fb816da6d353c9cde6ab14dae993a (diff) | |
download | openttd-e6703eac6853851f310923760b194ee4c875251b.tar.xz |
Codechange: [Network] Let NetworkTextMessage use std::string
-rw-r--r-- | src/network/network.cpp | 4 | ||||
-rw-r--r-- | src/network/network_client.cpp | 4 | ||||
-rw-r--r-- | src/network/network_internal.h | 2 | ||||
-rw-r--r-- | src/network/network_server.cpp | 10 |
4 files changed, 10 insertions, 10 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp index 2c5390dc0..abc8bdbc0 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -214,7 +214,7 @@ bool NetworkCompanyIsPassworded(CompanyID company_id) /* This puts a text-message to the console, or in the future, the chat-box, * (to keep it all a bit more general) * If 'self_send' is true, this is the client who is sending the message */ -void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str, int64 data) +void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64 data) { StringID strid; switch (action) { @@ -369,7 +369,7 @@ void NetworkHandlePauseChange(PauseMode prev_mode, PauseMode changed_mode) char buffer[DRAW_STRING_BUFFER]; GetString(buffer, str, lastof(buffer)); - NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, nullptr, buffer); + NetworkTextMessage(NETWORK_ACTION_SERVER_MESSAGE, CC_DEFAULT, false, "", buffer); break; } diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index b6da3dc18..ba9b16d85 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -1078,7 +1078,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_ERROR_QUIT(Pack NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id); if (ci != nullptr) { - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, nullptr, GetNetworkErrorMsg((NetworkErrorCode)p->Recv_uint8())); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", GetNetworkErrorMsg((NetworkErrorCode)p->Recv_uint8())); delete ci; } @@ -1095,7 +1095,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p) NetworkClientInfo *ci = NetworkClientInfo::GetByClientID(client_id); if (ci != nullptr) { - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, nullptr, STR_NETWORK_MESSAGE_CLIENT_LEAVING); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", STR_NETWORK_MESSAGE_CLIENT_LEAVING); delete ci; } else { DEBUG(net, 1, "Unknown client (%d) is leaving the game", client_id); diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 7412d9232..d1db971a3 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -114,7 +114,7 @@ void NetworkFreeLocalCommandQueue(); void NetworkSyncCommandQueue(NetworkClientSocket *cs); void ShowNetworkError(StringID error_string); -void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const char *name, const char *str = "", int64 data = 0); +void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64 data = 0); uint NetworkCalculateLag(const NetworkClientSocket *cs); StringID GetNetworkErrorMsg(NetworkErrorCode err); bool NetworkFindName(char *new_name, const char *last); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 91ab8bd9c..85015fce1 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -262,7 +262,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta this->GetClientName(client_name, lastof(client_name)); - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, STR_NETWORK_ERROR_CLIENT_CONNECTION_LOST); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", STR_NETWORK_ERROR_CLIENT_CONNECTION_LOST); /* Inform other clients of this... strange leaving ;) */ for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { @@ -453,7 +453,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err if (error == NETWORK_ERROR_KICKED && reason != nullptr) { NetworkTextMessage(NETWORK_ACTION_KICKED, CC_DEFAULT, false, client_name, reason, strid); } else { - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, strid); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid); } for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { @@ -1021,7 +1021,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MAP_OK(Packet * this->GetClientName(client_name, lastof(client_name)); - NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, client_name, nullptr, this->client_id); + NetworkTextMessage(NETWORK_ACTION_JOIN, CC_DEFAULT, false, client_name, "", this->client_id); InvalidateWindowData(WC_CLIENT_LIST, 0); /* Mark the client as pre-active, and wait for an ACK @@ -1144,7 +1144,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, str); - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, strid); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid); for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { if (new_cs->status >= STATUS_AUTHORIZED) { @@ -1170,7 +1170,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_QUIT(Packet *p) this->GetClientName(client_name, lastof(client_name)); - NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, nullptr, STR_NETWORK_MESSAGE_CLIENT_LEAVING); + NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", STR_NETWORK_MESSAGE_CLIENT_LEAVING); for (NetworkClientSocket *new_cs : NetworkClientSocket::Iterate()) { if (new_cs->status >= STATUS_AUTHORIZED && new_cs != this) { |