Network: Use unique_ptr for packets, use deque for packet queues

This commit is contained in:
Jonathan G Rennison
2020-05-06 21:13:31 +01:00
parent caa27cfa39
commit a1d85b812b
9 changed files with 62 additions and 84 deletions

View File

@@ -204,12 +204,11 @@ bool NetworkContentSocketHandler::ReceivePackets()
*
* What arbitrary number to choose is the ultimate question though.
*/
Packet *p;
std::unique_ptr<Packet> p;
static const int MAX_PACKETS_TO_RECEIVE = 42;
int i = MAX_PACKETS_TO_RECEIVE;
while (--i != 0 && (p = this->ReceivePacket()) != nullptr) {
bool cont = this->HandlePacket(p);
delete p;
bool cont = this->HandlePacket(p.get());
if (!cont) return true;
}