mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Introduce const ObjectList::FindLegacy (#23315)
This commit is contained in:
parent
2f450212a5
commit
a55a690db3
2 changed files with 19 additions and 3 deletions
|
@ -170,12 +170,27 @@ void ObjectList::SetObject(ObjectType type, ObjectEntryIndex index, std::string_
|
||||||
SetObject(index, entry);
|
SetObject(index, entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectEntryIndex ObjectList::Find(ObjectType type, std::string_view identifier)
|
ObjectEntryIndex ObjectList::Find(ObjectType type, std::string_view identifier) const
|
||||||
{
|
{
|
||||||
auto& subList = GetList(type);
|
auto& subList = GetList(type);
|
||||||
for (size_t i = 0; i < subList.size(); i++)
|
for (size_t i = 0; i < subList.size(); i++)
|
||||||
{
|
{
|
||||||
if (subList[i].Identifier == identifier)
|
if (subList[i].Generation == ObjectGeneration::JSON && subList[i].Identifier == identifier)
|
||||||
|
{
|
||||||
|
return static_cast<ObjectEntryIndex>(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return OBJECT_ENTRY_INDEX_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Intended to be used to find non-custom legacy objects. For internal use only.
|
||||||
|
ObjectEntryIndex ObjectList::FindLegacy(ObjectType type, std::string_view identifier) const
|
||||||
|
{
|
||||||
|
auto& subList = GetList(type);
|
||||||
|
for (size_t i = 0; i < subList.size(); i++)
|
||||||
|
{
|
||||||
|
if (subList[i].Generation == ObjectGeneration::DAT && subList[i].Entry.GetName() == identifier
|
||||||
|
&& subList[i].Entry.GetSourceGame() != ObjectSourceGame::Custom)
|
||||||
{
|
{
|
||||||
return static_cast<ObjectEntryIndex>(i);
|
return static_cast<ObjectEntryIndex>(i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ public:
|
||||||
const ObjectEntryDescriptor& GetObject(ObjectType type, ObjectEntryIndex index) const;
|
const ObjectEntryDescriptor& GetObject(ObjectType type, ObjectEntryIndex index) const;
|
||||||
void SetObject(ObjectEntryIndex index, const ObjectEntryDescriptor& entry);
|
void SetObject(ObjectEntryIndex index, const ObjectEntryDescriptor& entry);
|
||||||
void SetObject(ObjectType type, ObjectEntryIndex index, std::string_view identifier);
|
void SetObject(ObjectType type, ObjectEntryIndex index, std::string_view identifier);
|
||||||
ObjectEntryIndex Find(ObjectType type, std::string_view identifier);
|
ObjectEntryIndex Find(ObjectType type, std::string_view identifier) const;
|
||||||
|
ObjectEntryIndex FindLegacy(ObjectType type, std::string_view identifier) const;
|
||||||
|
|
||||||
struct const_iterator
|
struct const_iterator
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue