MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TransferToNetworkQueue

Method TransferToNetworkQueue

src/network/network_server.cpp:126–142  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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 {

Callers 1

SendMapMethod · 0.80

Calls 3

GetPacketTypeMethod · 0.80
emptyMethod · 0.45
SendPacketMethod · 0.45

Tested by

no test coverage detected