mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 22:13:07 +01:00
Improve network module in more C++ way
This commit is contained in:
@@ -20,15 +20,11 @@
|
||||
constexpr size_t NETWORK_DISCONNECT_REASON_BUFFER_SIZE = 256;
|
||||
constexpr size_t NetworkBufferSize = 1024 * 64; // 64 KiB, maximum packet size.
|
||||
|
||||
NetworkConnection::NetworkConnection()
|
||||
NetworkConnection::NetworkConnection() noexcept
|
||||
{
|
||||
ResetLastPacketTime();
|
||||
}
|
||||
|
||||
NetworkConnection::~NetworkConnection()
|
||||
{
|
||||
}
|
||||
|
||||
NetworkReadPacket NetworkConnection::ReadPacket()
|
||||
{
|
||||
size_t bytesRead = 0;
|
||||
@@ -155,7 +151,7 @@ void NetworkConnection::QueuePacket(NetworkPacket&& packet, bool front)
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkConnection::Disconnect()
|
||||
void NetworkConnection::Disconnect() noexcept
|
||||
{
|
||||
ShouldDisconnect = true;
|
||||
}
|
||||
@@ -173,12 +169,12 @@ void NetworkConnection::SendQueuedPackets()
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkConnection::ResetLastPacketTime()
|
||||
void NetworkConnection::ResetLastPacketTime() noexcept
|
||||
{
|
||||
_lastPacketTime = platform_get_ticks();
|
||||
}
|
||||
|
||||
bool NetworkConnection::ReceivedPacketRecently()
|
||||
bool NetworkConnection::ReceivedPacketRecently() const noexcept
|
||||
{
|
||||
# ifndef DEBUG
|
||||
if (platform_get_ticks() > _lastPacketTime + 7000)
|
||||
@@ -189,7 +185,7 @@ bool NetworkConnection::ReceivedPacketRecently()
|
||||
return true;
|
||||
}
|
||||
|
||||
const utf8* NetworkConnection::GetLastDisconnectReason() const
|
||||
const utf8* NetworkConnection::GetLastDisconnectReason() const noexcept
|
||||
{
|
||||
return this->_lastDisconnectReason.c_str();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user