mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-19 13:03:11 +01:00
Apply some refactoring
This commit is contained in:
committed by
Michael Steenbeek
parent
386a399a51
commit
06afeeda9a
@@ -33,10 +33,7 @@ NetworkConnection::NetworkConnection()
|
||||
NetworkConnection::~NetworkConnection()
|
||||
{
|
||||
delete Socket;
|
||||
if (_lastDisconnectReason)
|
||||
{
|
||||
delete[] _lastDisconnectReason;
|
||||
}
|
||||
delete[] _lastDisconnectReason;
|
||||
}
|
||||
|
||||
sint32 NetworkConnection::ReadPacket()
|
||||
@@ -104,11 +101,7 @@ bool NetworkConnection::SendPacket(NetworkPacket& packet)
|
||||
{
|
||||
packet.BytesTransferred += sent;
|
||||
}
|
||||
if (packet.BytesTransferred == tosend.size())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return packet.BytesTransferred == tosend.size();
|
||||
}
|
||||
|
||||
void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool front)
|
||||
@@ -119,7 +112,7 @@ void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool
|
||||
if (front)
|
||||
{
|
||||
// If the first packet was already partially sent add new packet to second position
|
||||
if (_outboundPackets.size() > 0 && _outboundPackets.front()->BytesTransferred > 0)
|
||||
if (!_outboundPackets.empty() && _outboundPackets.front()->BytesTransferred > 0)
|
||||
{
|
||||
auto it = _outboundPackets.begin();
|
||||
it++; // Second position
|
||||
@@ -139,7 +132,7 @@ void NetworkConnection::QueuePacket(std::unique_ptr<NetworkPacket> packet, bool
|
||||
|
||||
void NetworkConnection::SendQueuedPackets()
|
||||
{
|
||||
while (_outboundPackets.size() > 0 && SendPacket(*(_outboundPackets.front()).get()))
|
||||
while (!_outboundPackets.empty() && SendPacket(*_outboundPackets.front()))
|
||||
{
|
||||
_outboundPackets.remove(_outboundPackets.front());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user