mirror of https://github.com/OpenTTD/OpenTTD
Codechange: use std::string_view over std::string for NetworkTextMessage
parent
a0e4dab771
commit
a0246bc8a7
|
@ -230,7 +230,7 @@ uint8_t NetworkSpectatorCount()
|
|||
/* 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 std::string &name, const std::string &str, StringParameter &&data)
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, std::string_view name, std::string_view str, StringParameter &&data)
|
||||
{
|
||||
std::string message;
|
||||
StringBuilder builder(message);
|
||||
|
|
|
@ -110,7 +110,7 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs);
|
|||
void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id);
|
||||
|
||||
void ShowNetworkError(StringID error_string);
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", StringParameter &&data = {});
|
||||
void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, std::string_view name, std::string_view str = {}, StringParameter &&data = {});
|
||||
uint NetworkCalculateLag(const NetworkClientSocket *cs);
|
||||
StringID GetNetworkErrorMsg(NetworkErrorCode err);
|
||||
bool NetworkMakeClientNameUnique(std::string &new_name);
|
||||
|
|
|
@ -86,6 +86,7 @@ struct StringParameter {
|
|||
inline StringParameter(uint64_t data) : data(data), type(0) {}
|
||||
|
||||
inline StringParameter(const char *data) : data(std::string{data}), type(0) {}
|
||||
inline StringParameter(std::string_view data) : data(std::string{data}), type(0) {}
|
||||
inline StringParameter(std::string &&data) : data(std::move(data)), type(0) {}
|
||||
inline StringParameter(const std::string &data) : data(data), type(0) {}
|
||||
|
||||
|
|
Loading…
Reference in New Issue