1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 23:04:36 +01:00

Use std::string_view where appropriate in network code

Co-authored-by: Ted John <ted@brambles.org>
This commit is contained in:
ζeh Matt
2021-09-17 23:46:58 +03:00
parent 77141f57b0
commit 2529568bfc
14 changed files with 77 additions and 83 deletions

View File

@@ -27,7 +27,6 @@ NetworkConnection::NetworkConnection()
NetworkConnection::~NetworkConnection()
{
delete[] _lastDisconnectReason;
}
NetworkReadPacket NetworkConnection::ReadPacket()
@@ -192,23 +191,12 @@ bool NetworkConnection::ReceivedPacketRecently()
const utf8* NetworkConnection::GetLastDisconnectReason() const
{
return this->_lastDisconnectReason;
return this->_lastDisconnectReason.c_str();
}
void NetworkConnection::SetLastDisconnectReason(const utf8* src)
void NetworkConnection::SetLastDisconnectReason(std::string_view src)
{
if (src == nullptr)
{
delete[] _lastDisconnectReason;
_lastDisconnectReason = nullptr;
return;
}
if (_lastDisconnectReason == nullptr)
{
_lastDisconnectReason = new utf8[NETWORK_DISCONNECT_REASON_BUFFER_SIZE];
}
String::Set(_lastDisconnectReason, NETWORK_DISCONNECT_REASON_BUFFER_SIZE, src);
_lastDisconnectReason = src;
}
void NetworkConnection::SetLastDisconnectReason(const rct_string_id string_id, void* args)