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

Function load

src/OpenLoco/src/Objects/ObjectManager.cpp:550–574  ·  view source on GitHub ↗

0x00471BC5

Source from the content-addressed store, hash-verified

548
549 // 0x00471BC5
550 static bool load(const ObjectHeader& header, LoadedObjectId id)
551 {
552 auto preLoadObj = findAndPreLoadObject(header);
553 if (!preLoadObj.has_value())
554 {
555 return false;
556 }
557
558 if (getTotalNumImages() >= Gfx::G1ExpectedCount::kObjects + Gfx::G1ExpectedCount::kTemporaryObjects + Gfx::G1ExpectedCount::kDisc)
559 {
560 free(preLoadObj->object);
561 // Too many objects loaded and no free image space
562 return false;
563 }
564
565 _objectRepository[enumValue(preLoadObj->header.getType())].objects[id] = preLoadObj->object;
566 auto& extendedHeader = _objectRepository[enumValue(preLoadObj->header.getType())].objectEntryExtendeds[id];
567 extendedHeader = ObjectEntry2{
568 preLoadObj->header, static_cast<uint32_t>(preLoadObj->objectData.size())
569 };
570
571 callObjectLoad({ preLoadObj->header.getType(), id }, *preLoadObj->object, preLoadObj->objectData);
572
573 return true;
574 }
575
576 static std::optional<LoadedObjectId> findFreeObjectId(const ObjectType type)
577 {

Callers 2

loadSelectionListObjectsFunction · 0.70
loadAllFunction · 0.70

Calls 7

findAndPreLoadObjectFunction · 0.85
getTotalNumImagesFunction · 0.85
enumValueFunction · 0.85
callObjectLoadFunction · 0.85
findFreeObjectIdFunction · 0.85
getTypeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected