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

Function findObjectHandleFuzzy

src/OpenLoco/src/Objects/ObjectManager.cpp:205–246  ·  view source on GitHub ↗

0x0047206C Returns std::nullopt if not loaded

Source from the content-addressed store, hash-verified

203 // 0x0047206C
204 // Returns std::nullopt if not loaded
205 std::optional<LoadedObjectHandle> findObjectHandleFuzzy(const ObjectHeader& header)
206 {
207 auto res = findObjectHandle(header);
208 if (res.has_value())
209 {
210 return res;
211 }
212
213 auto objectType = header.getType();
214 const auto& typedObjectList = getRepositoryItem(objectType);
215 auto maxObjectsForType = getMaxObjects(objectType);
216 for (LoadedObjectId i = 0; i < maxObjectsForType; i++)
217 {
218 auto obj = typedObjectList.objects[i];
219 if (obj == nullptr || obj != reinterpret_cast<Object*>(-1))
220 {
221 continue;
222 }
223 const auto& objHeader = typedObjectList.objectEntryExtendeds[i];
224
225 if (!objHeader.isCustom())
226 {
227 continue;
228 }
229 if (header.getType() != objHeader.getType())
230 {
231 continue;
232 }
233 if (header.getName() != objHeader.getName())
234 {
235 continue;
236 }
237 if (header.getFuzzyFlags() != objHeader.getFuzzyFlags())
238 {
239 continue;
240 }
241
242 return { LoadedObjectHandle{ objectType, i } };
243 }
244
245 return std::nullopt;
246 }
247
248 enum class ObjectProcedure
249 {

Callers 3

loadMethod · 0.85
loadMethod · 0.85
loadMethod · 0.85

Calls 6

findObjectHandleFunction · 0.85
getMaxObjectsFunction · 0.85
isCustomMethod · 0.80
getNameMethod · 0.80
getFuzzyFlagsMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected