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

Method DownloadSelectedContentFallback

src/network/network_content.cpp:338–362  ·  view source on GitHub ↗

* Initiate downloading the content over the fallback protocol. * @param content The content to download. */

Source from the content-addressed store, hash-verified

336 * @param content The content to download.
337 */
338void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const ContentIDList &content)
339{
340 uint count = (uint)content.size();
341 const ContentID *content_ids = content.data();
342 this->Connect();
343
344 while (count > 0) {
345 /* We can "only" send a limited number of IDs in a single packet.
346 * A packet begins with the packet size and a byte for the type.
347 * Then this packet adds a uint16_t for the count in this packet.
348 * The rest of the packet can be used for the IDs. */
349 uint p_count = std::min<uint>(count, (TCP_MTU - sizeof(PacketSize) - sizeof(uint8_t) - sizeof(uint16_t)) / sizeof(uint32_t));
350
351 auto p = std::make_unique<Packet>(this, PACKET_CONTENT_CLIENT_CONTENT, TCP_MTU);
352 p->Send_uint16(p_count);
353
354 for (uint i = 0; i < p_count; i++) {
355 p->Send_uint32(content_ids[i]);
356 }
357
358 this->SendPacket(std::move(p));
359 count -= p_count;
360 content_ids += p_count;
361 }
362}
363
364/**
365 * Determine the full filename of a piece of content information

Callers 1

Calls 6

ConnectMethod · 0.95
Send_uint16Method · 0.80
Send_uint32Method · 0.80
sizeMethod · 0.45
dataMethod · 0.45
SendPacketMethod · 0.45

Tested by

no test coverage detected