MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / FindSpareSlot

Method FindSpareSlot

src/openrct2/object/ObjectManager.cpp:403–419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

401 }
402
403 std::optional<ObjectEntryIndex> FindSpareSlot(ObjectType objectType)
404 {
405 auto& list = GetObjectList(objectType);
406 auto it = std::find(list.begin(), list.end(), nullptr);
407 if (it != list.end())
408 {
409 return static_cast<ObjectEntryIndex>(std::distance(list.begin(), it));
410 }
411
412 auto maxSize = getObjectEntryGroupCount(objectType);
413 if (list.size() < static_cast<size_t>(maxSize))
414 {
415 list.emplace_back();
416 return static_cast<ObjectEntryIndex>(list.size() - 1);
417 }
418 return std::nullopt;
419 }
420
421 size_t GetLoadedObjectIndex(const Object* object)
422 {

Callers

nothing calls this directly

Calls 4

getObjectEntryGroupCountFunction · 0.85
endMethod · 0.65
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected