1
0
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:
skdltmxn
2022-02-10 05:57:25 +09:00
committed by GitHub
parent 052da74760
commit 29083f4cb2
19 changed files with 120 additions and 171 deletions

View File

@@ -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();
}