MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / createIndex

Function createIndex

src/OpenLoco/src/Objects/ObjectIndex.cpp:466–495  ·  view source on GitHub ↗

0x0047118B

Source from the content-addressed store, hash-verified

464
465 // 0x0047118B
466 static void createIndex(const ObjectFoldersState& currentState)
467 {
468 Input::processMessagesMini();
469 const auto progressString = _isFirstTime ? StringIds::starting_for_the_first_time : StringIds::checking_object_files;
470 Ui::ProgressBar::begin(progressString);
471
472 // Reset
473 reloadAll();
474 _installedObjectList.clear();
475
476 // Create new index by iterating all DAT files and processing
477 IndexHeader header{};
478 header.version = kCurrentIndexVersion;
479 const auto vanillaObjectPath = Environment::getPathNoWarning(Environment::PathId::vanillaObjects);
480 addObjectsInFolder(vanillaObjectPath, false, currentState.vanillaInstall.numObjects);
481 const auto objectPath = Environment::getPathNoWarning(Environment::PathId::objects);
482 addObjectsInFolder(objectPath, true, currentState.install.numObjects);
483 const auto customObjectPath = Environment::getPathNoWarning(Environment::PathId::customObjects);
484 addObjectsInFolder(customObjectPath, true, currentState.customObjects.numObjects);
485 std::ranges::sort(_installedObjectList, {}, [](const auto& entry) { return entry._name; });
486
487 // New index creation completed. Reset and save result.
488 reloadAll();
489 header.fileSize = 0;
490 header.numObjects = static_cast<uint32_t>(_installedObjectList.size());
491 header.state = currentState;
492 saveIndex(header);
493
494 Ui::ProgressBar::end();
495 }
496
497 static bool tryLoadIndex(const ObjectFoldersState& currentState)
498 {

Callers 1

loadIndexFunction · 0.70

Calls 9

processMessagesMiniFunction · 0.85
beginFunction · 0.85
reloadAllFunction · 0.85
getPathNoWarningFunction · 0.85
addObjectsInFolderFunction · 0.85
endFunction · 0.85
saveIndexFunction · 0.70
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected