* Transfer all packets from here to the network's queue while holding * the lock on our mutex. * @return True iff the last packet of the map has been sent. */
| 124 | * @return True iff the last packet of the map has been sent. |
| 125 | */ |
| 126 | bool TransferToNetworkQueue() |
| 127 | { |
| 128 | /* Unsafe check for the queue being empty or not. */ |
| 129 | if (this->packets.empty()) return false; |
| 130 | |
| 131 | std::lock_guard<std::mutex> lock(this->mutex); |
| 132 | |
| 133 | while (!this->packets.empty()) { |
| 134 | bool last_packet = this->packets.front()->GetPacketType() == PACKET_SERVER_MAP_DONE; |
| 135 | this->cs->SendPacket(std::move(this->packets.front())); |
| 136 | this->packets.pop_front(); |
| 137 | |
| 138 | if (last_packet) return true; |
| 139 | } |
| 140 | |
| 141 | return false; |
| 142 | } |
| 143 | |
| 144 | void Write(uint8_t *buf, size_t size) override |
| 145 | { |
no test coverage detected