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

Method load

src/OpenLoco/src/Objects/CargoObject.cpp:25–47  ·  view source on GitHub ↗

0x0042F4D0

Source from the content-addressed store, hash-verified

23
24 // 0x0042F4D0
25 void CargoObject::load(const LoadedObjectHandle& handle, std::span<const std::byte> data, ObjectManager::DependentObjects*)
26 {
27 auto remainingData = data.subspan(sizeof(CargoObject));
28
29 auto loadString = [&remainingData, &handle](StringId& dst, uint8_t num) {
30 auto strRes = ObjectManager::loadStringTable(remainingData, handle, num);
31 dst = strRes.str;
32 remainingData = remainingData.subspan(strRes.tableLength);
33 };
34
35 // Load object strings
36 loadString(name, 0);
37 loadString(unitsAndCargoName, 1);
38 loadString(unitNameSingular, 2);
39 loadString(unitNamePlural, 3);
40
41 // Load images
42 auto imageRes = ObjectManager::loadImageTable(remainingData);
43 unitInlineSprite = imageRes.imageOffset;
44
45 // Ensure we've loaded the entire object
46 assert(remainingData.size() == imageRes.tableLength);
47 }
48
49 // 0x0042F514
50 void CargoObject::unload()

Callers

nothing calls this directly

Calls 3

loadStringTableFunction · 0.85
loadImageTableFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected