MCPcopy Create free account
hub / github.com/Norbyte/bg3se / UpdateFromEmbeddedCache

Method UpdateFromEmbeddedCache

BG3Updater/Updater.cpp:365–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365void ScriptExtenderUpdater::UpdateFromEmbeddedCache()
366{
367 Manifest manifest;
368 ManifestFetcher manifestFetcher(fetcher_, config_);
369 auto result = manifestFetcher.LoadEmbedded(manifest);
370 if (!result) {
371 DEBUG("Failed to load embedded manifest: %s", result.error().Message.c_str());
372 return;
373 }
374
375 // Pick a version to load from the local cache
376 auto localRes = cache_->GetManifest().FindResourceVersionWithOverrides(UPDATER_RESOURCE_NAME, gameVersion_, config_);
377
378 // Pick a version to load from the embedded manifest
379 auto embeddedRes = manifest.FindResourceVersionWithOverrides(UPDATER_RESOURCE_NAME, gameVersion_, config_);
380
381 if (!embeddedRes) {
382 DEBUG("Not extracting embedded resource - doesn't match current game version");
383 return;
384 }
385
386 // Don't unpack if the embedded resource is already available
387 if (localRes && localRes->Digest == embeddedRes->Digest) {
388 DEBUG("Not extracting embedded resource - already available in local cache");
389 return;
390 }
391
392 // Don't unpack if the embedded resource is not newer than the one in the local cache
393 if (localRes && *embeddedRes < *localRes) {
394 DEBUG("Not extracting embedded resource - less recent than version in local cache");
395 return;
396 }
397
398 auto packageBinary = GetExeResource(IDR_LOCAL_SE_PACKAGE);
399 if (!packageBinary || packageBinary->empty()) {
400 DEBUG("Not extracting embedded resource - embedded package blob is missing or empty");
401 return;
402 }
403
404 auto const& resource = manifest.Resources[UPDATER_RESOURCE_NAME];
405 cache_->UpdateLocalPackage(resource, *embeddedRes, *packageBinary);
406}
407
408bool ScriptExtenderUpdater::IsCompleted() const
409{

Callers

nothing calls this directly

Calls 5

GetExeResourceFunction · 0.85
LoadEmbeddedMethod · 0.80
UpdateLocalPackageMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected