1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-23 23:04:36 +01:00

Implement handling of new object types

This commit is contained in:
Ted John
2021-04-01 01:13:31 +01:00
parent 638bbebe59
commit fce02c21c3
14 changed files with 380 additions and 227 deletions

View File

@@ -56,6 +56,123 @@ int32_t object_entry_group_encoding[] = {
};
// clang-format on
ObjectList::const_iterator::const_iterator(const ObjectList* parent, bool end)
{
_parent = parent;
_subList = _parent->_subLists.size();
_index = 0;
}
void ObjectList::const_iterator::MoveToNextEntry()
{
do
{
if (_subList < _parent->_subLists.size())
{
auto subListSize = _parent->_subLists[_subList].size();
if (_index < subListSize)
{
_index++;
if (_index == subListSize)
{
_subList++;
_index = 0;
}
}
}
else
{
break;
}
} while (!_parent->_subLists[_subList][_index].HasValue());
}
ObjectList::const_iterator& ObjectList::const_iterator::operator++()
{
MoveToNextEntry();
return *this;
}
ObjectList::const_iterator ObjectList::const_iterator::operator++(int)
{
return *this;
}
const ObjectEntryDescriptor& ObjectList::const_iterator::operator*()
{
return _parent->_subLists[_subList][_index];
}
bool ObjectList::const_iterator::operator==(const_iterator& rhs)
{
return _parent == rhs._parent && _subList == rhs._subList && _index == rhs._index;
}
bool ObjectList::const_iterator::operator!=(const_iterator& rhs)
{
return !(*this == rhs);
}
ObjectList::const_iterator ObjectList::begin() const
{
return const_iterator(this, false);
}
ObjectList::const_iterator ObjectList::end() const
{
return const_iterator(this, true);
}
std::vector<ObjectEntryDescriptor>& ObjectList::GetList(ObjectType type)
{
auto index = static_cast<size_t>(type);
while (_subLists.size() <= index)
{
_subLists.resize(static_cast<size_t>(index) + 1);
}
return _subLists[index];
}
std::vector<ObjectEntryDescriptor>& ObjectList::GetList(ObjectType type) const
{
return const_cast<ObjectList*>(this)->GetList(type);
}
const ObjectEntryDescriptor& ObjectList::GetObject(ObjectType type, ObjectEntryIndex index) const
{
const auto& subList = GetList(type);
if (subList.size() > index)
{
return subList[index];
}
static ObjectEntryDescriptor placeholder;
return placeholder;
}
void ObjectList::Add(const ObjectEntryDescriptor& entry)
{
auto& subList = GetList(entry.GetType());
subList.push_back(entry);
}
void ObjectList::SetObject(ObjectEntryIndex index, const ObjectEntryDescriptor& entry)
{
auto& subList = GetList(entry.GetType());
if (subList.size() <= index)
{
subList.resize(static_cast<size_t>(index) + 1);
}
subList[index] = entry;
}
void ObjectList::SetObject(ObjectType type, ObjectEntryIndex index, std::string_view identifier)
{
auto entry = ObjectEntryDescriptor(identifier);
entry.Type = type;
SetObject(index, entry);
}
bool object_entry_is_empty(const rct_object_entry* entry)
{
uint64_t a, b;