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

Method DownloadSelectedContent

src/network/network_content.cpp:292–316  ·  view source on GitHub ↗

* Actually begin downloading the content we selected. * @param[out] files The number of files we are going to download. * @param[out] bytes The number of bytes we are going to download. * @param fallback Whether to use the fallback or not. */

Source from the content-addressed store, hash-verified

290 * @param fallback Whether to use the fallback or not.
291 */
292void ClientNetworkContentSocketHandler::DownloadSelectedContent(uint &files, uint &bytes, bool fallback)
293{
294 bytes = 0;
295
296 ContentIDList content;
297 for (const auto &ci : this->infos) {
298 if (!ci->IsSelected() || ci->state == ContentInfo::State::AlreadyHere) continue;
299
300 content.push_back(ci->id);
301 bytes += ci->filesize;
302 }
303
304 files = (uint)content.size();
305
306 /* If there's nothing to download, do nothing. */
307 if (files == 0) return;
308
309 this->is_cancelled = false;
310
311 if (fallback) {
312 this->DownloadSelectedContentFallback(content);
313 } else {
314 this->DownloadSelectedContentHTTP(content);
315 }
316}
317
318/**
319 * Initiate downloading the content over HTTP.

Callers 4

OnFailureMethod · 0.95
OnReceiveContentInfoMethod · 0.80
ConContentFunction · 0.80

Calls 5

IsSelectedMethod · 0.80
push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected