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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user