diff options
author | Rubidium <rubidium@openttd.org> | 2021-04-20 18:50:46 +0200 |
---|---|---|
committer | rubidium42 <rubidium42@users.noreply.github.com> | 2021-04-24 20:42:01 +0200 |
commit | 3abefdf56190ef55d8680acb1aeab9f1b2fc8108 (patch) | |
tree | 779a93162e2a0875ff2c12a8783f30b07c538df1 /src/network/network_server.cpp | |
parent | f71fb0f54af443cee37d3c41a0d4f39a24617741 (diff) | |
download | openttd-3abefdf56190ef55d8680acb1aeab9f1b2fc8108.tar.xz |
Codechange: remove public access to the next pointer in Packet
Diffstat (limited to 'src/network/network_server.cpp')
-rw-r--r-- | src/network/network_server.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 5301bd084..80a9c56a0 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -79,9 +79,7 @@ struct PacketWriter : SaveFilter { /* This must all wait until the Destroy function is called. */ while (this->packets != nullptr) { - Packet *p = this->packets->next; - delete this->packets; - this->packets = p; + delete Packet::PopFromQueue(&this->packets); } delete this->current; @@ -132,11 +130,7 @@ struct PacketWriter : SaveFilter { { std::lock_guard<std::mutex> lock(this->mutex); - Packet *p = this->packets; - this->packets = p->next; - p->next = nullptr; - - return p; + return Packet::PopFromQueue(&this->packets); } /** Append the current packet to the queue. */ @@ -144,12 +138,7 @@ struct PacketWriter : SaveFilter { { if (this->current == nullptr) return; - Packet **p = &this->packets; - while (*p != nullptr) { - p = &(*p)->next; - } - *p = this->current; - + Packet::AddToQueue(&this->packets, this->current); this->current = nullptr; } @@ -158,7 +147,8 @@ struct PacketWriter : SaveFilter { { if (this->current == nullptr) return; - this->current->next = this->packets; + /* Reversed from AppendQueue so the queue gets added to the current one. */ + Packet::AddToQueue(&this->current, this->packets); this->packets = this->current; this->current = nullptr; } |