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

Function findObjectHandle

src/OpenLoco/src/Objects/ObjectManager.cpp:179–201  ·  view source on GitHub ↗

0x004720EB Returns std::nullopt if not loaded

Source from the content-addressed store, hash-verified

177 // 0x004720EB
178 // Returns std::nullopt if not loaded
179 std::optional<LoadedObjectHandle> findObjectHandle(const ObjectHeader& header)
180 {
181 if ((header.flags & 0xFF) != 0xFF)
182 {
183 auto objectType = header.getType();
184 const auto& typedObjectList = getRepositoryItem(objectType);
185 auto maxObjectsForType = getMaxObjects(objectType);
186 for (LoadedObjectId i = 0; i < maxObjectsForType; i++)
187 {
188 auto obj = typedObjectList.objects[i];
189 if (obj != nullptr && obj != reinterpret_cast<Object*>(-1))
190 {
191 const auto& objHeader = typedObjectList.objectEntryExtendeds[i];
192
193 if (header == objHeader) // PERHAPS WRONG WAY ROUND
194 {
195 return { LoadedObjectHandle{ objectType, i } };
196 }
197 }
198 }
199 }
200 return std::nullopt;
201 }
202
203 // 0x0047206C
204 // Returns std::nullopt if not loaded

Callers 15

drawFunction · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85
loadSelectionListObjectsFunction · 0.85

Calls 2

getMaxObjectsFunction · 0.85
getTypeMethod · 0.45

Tested by

no test coverage detected