mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string_view for sending chat messages
parent
bb259b8e77
commit
26de3404a4
|
@ -440,7 +440,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats()
|
|||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data)
|
||||
NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data)
|
||||
{
|
||||
auto p = std::make_unique<Packet>(this, ADMIN_PACKET_SERVER_CHAT);
|
||||
|
||||
|
@ -980,7 +980,7 @@ void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bc
|
|||
/**
|
||||
* Send chat to the admin network (if they did opt in for the respective update).
|
||||
*/
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin)
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data, bool from_admin)
|
||||
{
|
||||
if (from_admin) return;
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
NetworkRecvStatus SendCompanyEconomy();
|
||||
NetworkRecvStatus SendCompanyStats();
|
||||
|
||||
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data);
|
||||
NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data);
|
||||
NetworkRecvStatus SendRcon(uint16_t colour, const std::string_view command);
|
||||
NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command);
|
||||
NetworkRecvStatus SendGameScript(const std::string_view json);
|
||||
|
@ -113,7 +113,7 @@ void NetworkAdminCompanyNew(const Company *company);
|
|||
void NetworkAdminCompanyUpdate(const Company *company);
|
||||
void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr);
|
||||
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, std::string_view msg, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkAdminUpdate(AdminUpdateFrequency freq);
|
||||
void NetworkServerSendAdminRcon(AdminID admin_index, TextColour colour_code, const std::string_view string);
|
||||
void NetworkAdminConsole(const std::string_view origin, const std::string_view string);
|
||||
|
|
|
@ -251,7 +251,7 @@ void NetworkDrawChatMessage()
|
|||
* @param type The type of destination.
|
||||
* @param dest The actual destination index.
|
||||
*/
|
||||
static void SendChat(const std::string &buf, DestType type, int dest)
|
||||
static void SendChat(std::string_view buf, DestType type, int dest)
|
||||
{
|
||||
if (buf.empty()) return;
|
||||
if (!_network_server) {
|
||||
|
|
|
@ -401,7 +401,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand(const CommandPacke
|
|||
}
|
||||
|
||||
/** Send a chat-packet over the network */
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data)
|
||||
NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data)
|
||||
{
|
||||
Debug(net, 9, "Client::SendChat(): action={}, type={}, dest={}", action, type, dest);
|
||||
|
||||
|
@ -1328,7 +1328,7 @@ void NetworkUpdateClientName(const std::string &client_name)
|
|||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data)
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data)
|
||||
{
|
||||
MyClient::SendChat(action, type, dest, msg, data);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
static NetworkRecvStatus SendAuthResponse();
|
||||
|
||||
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data);
|
||||
static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data);
|
||||
static NetworkRecvStatus SendSetName(const std::string &name);
|
||||
static NetworkRecvStatus SendRCon(std::string_view password, std::string_view command);
|
||||
static NetworkRecvStatus SendMove(CompanyID company);
|
||||
|
|
|
@ -54,7 +54,7 @@ bool NetworkClientConnectGame(const std::string &connection_string, CompanyID de
|
|||
void NetworkClientJoinGame();
|
||||
void NetworkClientRequestMove(CompanyID company);
|
||||
void NetworkClientSendRcon(std::string_view password, std::string_view command);
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data = 0);
|
||||
void NetworkClientSendChat(NetworkAction action, DestType type, int dest, std::string_view msg, int64_t data = 0);
|
||||
bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio);
|
||||
uint NetworkMaxCompaniesAllowed();
|
||||
bool NetworkMaxCompaniesReached();
|
||||
|
@ -76,8 +76,8 @@ bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_na
|
|||
bool NetworkCanJoinCompany(CompanyID company_id);
|
||||
void NetworkServerDoMove(ClientID client_id, CompanyID company_id);
|
||||
void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, std::string_view string);
|
||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg);
|
||||
void NetworkServerSendChat(NetworkAction action, DestType type, int dest, std::string_view msg, ClientID from_id, int64_t data = 0, bool from_admin = false);
|
||||
void NetworkServerSendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg);
|
||||
|
||||
void NetworkServerKickClient(ClientID client_id, std::string_view reason);
|
||||
uint NetworkServerKickOrBanIP(ClientID client_id, bool ban, std::string_view reason);
|
||||
|
|
|
@ -677,7 +677,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand(const CommandPacke
|
|||
* @param msg The actual message.
|
||||
* @param data Arbitrary extra data.
|
||||
*/
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data)
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, std::string_view msg, int64_t data)
|
||||
{
|
||||
Debug(net, 9, "client[{}] SendChat(): action={}, client_id={}, self_send={}", this->client_id, action, client_id, self_send);
|
||||
|
||||
|
@ -702,7 +702,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action,
|
|||
* @param user Name of the user who sent the message.
|
||||
* @param msg The actual message.
|
||||
*/
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
|
||||
NetworkRecvStatus ServerNetworkGameSocketHandler::SendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg)
|
||||
{
|
||||
Debug(net, 9, "client[{}] SendExternalChat(): source={}", this->client_id, source);
|
||||
|
||||
|
@ -1250,7 +1250,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet &p)
|
|||
* @param data Arbitrary data.
|
||||
* @param from_admin Whether the origin is an admin or not.
|
||||
*/
|
||||
void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const std::string &msg, ClientID from_id, int64_t data, bool from_admin)
|
||||
void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, std::string_view msg, ClientID from_id, int64_t data, bool from_admin)
|
||||
{
|
||||
const NetworkClientInfo *ci, *ci_own, *ci_to;
|
||||
|
||||
|
@ -1367,7 +1367,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
|
|||
* @param user Name of the user who sent the message.
|
||||
* @param msg The actual message.
|
||||
*/
|
||||
void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg)
|
||||
void NetworkServerSendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg)
|
||||
{
|
||||
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
|
||||
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) cs->SendExternalChat(source, colour, user, msg);
|
||||
|
|
|
@ -94,8 +94,8 @@ public:
|
|||
|
||||
NetworkRecvStatus SendClientInfo(NetworkClientInfo *ci);
|
||||
NetworkRecvStatus SendError(NetworkErrorCode error, std::string_view reason = {});
|
||||
NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data);
|
||||
NetworkRecvStatus SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg);
|
||||
NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, std::string_view msg, int64_t data);
|
||||
NetworkRecvStatus SendExternalChat(std::string_view source, TextColour colour, std::string_view user, std::string_view msg);
|
||||
NetworkRecvStatus SendJoin(ClientID client_id);
|
||||
NetworkRecvStatus SendFrame();
|
||||
NetworkRecvStatus SendSync();
|
||||
|
|
Loading…
Reference in New Issue