1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-02-03 04:05:49 +01:00

Remove ObjectType++ operator, ensure ObjectTypes size

This commit is contained in:
Hielke Morsink
2022-06-30 23:13:40 +02:00
committed by GitHub
parent 43562a6899
commit 8e509d9669
4 changed files with 9 additions and 14 deletions

View File

@@ -1273,18 +1273,19 @@ static int32_t cc_object_count(InteractiveConsole& console, [[maybe_unused]] con
"Paths", "Path Additions", "Scenery groups", "Park entrances", "Water",
};
for (ObjectType i = ObjectType::Ride; i < ObjectType::ScenarioText; i++)
for (auto objectType : ObjectTypes)
{
int32_t entryGroupIndex = 0;
for (; entryGroupIndex < object_entry_group_counts[EnumValue(i)]; entryGroupIndex++)
for (; entryGroupIndex < object_entry_group_counts[EnumValue(objectType)]; entryGroupIndex++)
{
if (object_entry_get_chunk(i, entryGroupIndex) == nullptr)
if (object_entry_get_chunk(objectType, entryGroupIndex) == nullptr)
{
break;
}
}
console.WriteFormatLine(
"%s: %d/%d", object_type_names[EnumValue(i)], entryGroupIndex, object_entry_group_counts[EnumValue(i)]);
"%s: %d/%d", object_type_names[EnumValue(objectType)], entryGroupIndex,
object_entry_group_counts[EnumValue(objectType)]);
}
return 0;

View File

@@ -28,11 +28,6 @@
using namespace OpenRCT2;
ObjectType& operator++(ObjectType& d, int)
{
return d = (d == ObjectType::Count) ? ObjectType::Ride : static_cast<ObjectType>(static_cast<uint8_t>(d) + 1);
}
ObjectEntryDescriptor::ObjectEntryDescriptor(const rct_object_entry& newEntry)
{
if (!newEntry.IsEmpty())

View File

@@ -53,9 +53,7 @@ enum class ObjectType : uint8_t
None = 255
};
ObjectType& operator++(ObjectType& d, int);
constexpr std::array<ObjectType, EnumValue(ObjectType::Count)> ObjectTypes = {
constexpr std::array ObjectTypes = {
ObjectType::Ride,
ObjectType::SmallScenery,
ObjectType::LargeScenery,
@@ -75,6 +73,7 @@ constexpr std::array<ObjectType, EnumValue(ObjectType::Count)> ObjectTypes = {
ObjectType::FootpathRailings,
ObjectType::Audio,
};
static_assert(ObjectTypes.size() == EnumValue(ObjectType::Count));
// Object types that can be saved in a park file.
constexpr std::array<ObjectType, 16> TransientObjectTypes = {

View File

@@ -140,7 +140,7 @@ public:
ObjectList GetLoadedObjects() override
{
ObjectList objectList;
for (auto objectType = ObjectType::Ride; objectType < ObjectType::Count; objectType++)
for (auto objectType : ObjectTypes)
{
auto maxObjectsOfType = static_cast<ObjectEntryIndex>(object_entry_group_counts[EnumValue(objectType)]);
for (ObjectEntryIndex i = 0; i < maxObjectsOfType; i++)
@@ -512,7 +512,7 @@ private:
std::vector<ObjectToLoad> requiredObjects;
std::vector<ObjectEntryDescriptor> missingObjects;
for (auto objectType = ObjectType::Ride; objectType < ObjectType::Count; objectType++)
for (auto objectType : ObjectTypes)
{
auto& descriptors = objectList.GetList(objectType);
auto maxSize = static_cast<size_t>(object_entry_group_counts[EnumValue(objectType)]);