mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 15:54:31 +01:00
Move kTransientObjectTypes, kIntransientObjectTypes out of header
This commit is contained in:
@@ -82,7 +82,7 @@ static Widget _inventionListDragWidgets[] = {
|
||||
static void ResearchRidesSetup()
|
||||
{
|
||||
// Reset all objects to not required
|
||||
for (auto objectType : TransientObjectTypes)
|
||||
for (auto objectType : getTransientObjectTypes())
|
||||
{
|
||||
auto maxObjects = object_entry_group_counts[EnumValue(objectType)];
|
||||
for (int32_t i = 0; i < maxObjects; i++)
|
||||
|
||||
@@ -125,7 +125,7 @@ void SetupInUseSelectionFlags()
|
||||
{
|
||||
auto& objectMgr = OpenRCT2::GetContext()->GetObjectManager();
|
||||
|
||||
for (auto objectType : TransientObjectTypes)
|
||||
for (auto objectType : getTransientObjectTypes())
|
||||
{
|
||||
for (int32_t i = 0; i < object_entry_group_counts[EnumValue(objectType)]; i++)
|
||||
{
|
||||
|
||||
@@ -7,24 +7,45 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ObjectTypes.h"
|
||||
|
||||
#include "../util/Util.h"
|
||||
#include "Object.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
// Object types that can be saved in a park file.
|
||||
static constexpr std::array<const ObjectType, kNumTransientObjectTypes> kTransientObjectTypes = {
|
||||
ObjectType::Ride, ObjectType::SmallScenery, ObjectType::LargeScenery, ObjectType::Walls,
|
||||
ObjectType::Banners, ObjectType::Paths, ObjectType::PathAdditions, ObjectType::SceneryGroup,
|
||||
ObjectType::ParkEntrance, ObjectType::Water, ObjectType::TerrainSurface, ObjectType::TerrainEdge,
|
||||
ObjectType::Station, ObjectType::Music, ObjectType::FootpathSurface, ObjectType::FootpathRailings,
|
||||
};
|
||||
|
||||
// Object types that cannot be saved in a park file.
|
||||
static constexpr std::array<const ObjectType, kNumIntransientObjectTypes> kIntransientObjectTypes = {
|
||||
ObjectType::ScenarioText,
|
||||
ObjectType::Audio,
|
||||
};
|
||||
|
||||
static_assert(kNumTransientObjectTypes + kNumIntransientObjectTypes == static_cast<size_t>(ObjectType::Count));
|
||||
|
||||
bool ObjectTypeIsTransient(ObjectType type)
|
||||
{
|
||||
return std::find(TransientObjectTypes.begin(), TransientObjectTypes.end(), type) != std::end(TransientObjectTypes);
|
||||
return std::find(kTransientObjectTypes.begin(), kTransientObjectTypes.end(), type) != std::end(kTransientObjectTypes);
|
||||
}
|
||||
|
||||
bool ObjectTypeIsIntransient(ObjectType type)
|
||||
{
|
||||
return std::find(IntransientObjectTypes.begin(), IntransientObjectTypes.end(), type) != std::end(IntransientObjectTypes);
|
||||
return std::find(kIntransientObjectTypes.begin(), kIntransientObjectTypes.end(), type) != std::end(kIntransientObjectTypes);
|
||||
}
|
||||
|
||||
size_t GetObjectTypeLimit(ObjectType type)
|
||||
std::span<const ObjectType> getTransientObjectTypes()
|
||||
{
|
||||
auto index = EnumValue(type);
|
||||
if (index >= EnumValue(ObjectType::Count))
|
||||
return 0;
|
||||
return static_cast<size_t>(object_entry_group_counts[index]);
|
||||
return kTransientObjectTypes;
|
||||
}
|
||||
|
||||
std::span<const ObjectType> getIntransientObjectTypes()
|
||||
{
|
||||
return kIntransientObjectTypes;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
#include <span>
|
||||
|
||||
using ObjectEntryIndex = uint16_t;
|
||||
constexpr ObjectEntryIndex OBJECT_ENTRY_INDEX_NULL = std::numeric_limits<ObjectEntryIndex>::max();
|
||||
@@ -66,17 +67,10 @@ constexpr std::array ObjectTypes = {
|
||||
// Not using EnumValue to reduce header includes
|
||||
static_assert(ObjectTypes.size() == static_cast<uint8_t>(ObjectType::Count));
|
||||
|
||||
// Object types that can be saved in a park file.
|
||||
constexpr std::array<ObjectType, 16> TransientObjectTypes = {
|
||||
ObjectType::Ride, ObjectType::SmallScenery, ObjectType::LargeScenery, ObjectType::Walls,
|
||||
ObjectType::Banners, ObjectType::Paths, ObjectType::PathAdditions, ObjectType::SceneryGroup,
|
||||
ObjectType::ParkEntrance, ObjectType::Water, ObjectType::TerrainSurface, ObjectType::TerrainEdge,
|
||||
ObjectType::Station, ObjectType::Music, ObjectType::FootpathSurface, ObjectType::FootpathRailings,
|
||||
};
|
||||
|
||||
// Object types that cannot be saved in a park file.
|
||||
constexpr std::array<ObjectType, 2> IntransientObjectTypes = { ObjectType::ScenarioText, ObjectType::Audio };
|
||||
static constexpr size_t kNumTransientObjectTypes = 16;
|
||||
static constexpr size_t kNumIntransientObjectTypes = 2;
|
||||
|
||||
bool ObjectTypeIsTransient(ObjectType type);
|
||||
bool ObjectTypeIsIntransient(ObjectType type);
|
||||
size_t GetObjectTypeLimit(ObjectType type);
|
||||
std::span<const ObjectType> getTransientObjectTypes();
|
||||
std::span<const ObjectType> getIntransientObjectTypes();
|
||||
|
||||
@@ -382,8 +382,8 @@ namespace OpenRCT2
|
||||
auto objectList = objManager.GetLoadedObjects();
|
||||
|
||||
// Write number of object sub lists
|
||||
cs.Write(static_cast<uint16_t>(TransientObjectTypes.size()));
|
||||
for (auto objectType : TransientObjectTypes)
|
||||
cs.Write(static_cast<uint16_t>(getTransientObjectTypes().size()));
|
||||
for (auto objectType : getTransientObjectTypes())
|
||||
{
|
||||
// Write sub list
|
||||
const auto& list = objectList.GetList(objectType);
|
||||
|
||||
Reference in New Issue
Block a user