diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 89103ad7da..0deb4120fc 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -198,7 +198,8 @@ static ScenerySelection window_scenery_tab_entries[SCENERY_WINDOW_TABS][SCENERY_ * Was part of 0x006DFA00 * The same code repeated five times for every scenery entry type */ -static void init_scenery_entry(rct_scenery_entry* sceneryEntry, const ScenerySelection& selection, uint8_t sceneryTabId) +static void init_scenery_entry( + rct_scenery_entry* sceneryEntry, const ScenerySelection& selection, ObjectEntryIndex sceneryTabId) { Guard::ArgumentInRange(selection.EntryIndex, 0, WINDOW_SCENERY_TAB_SELECTION_UNDEFINED); if (scenery_is_invented(selection) || gCheatsIgnoreResearchStatus) @@ -278,7 +279,7 @@ void window_scenery_init() } // small scenery - for (uint16_t sceneryId = 0; sceneryId < MAX_SMALL_SCENERY_OBJECTS; sceneryId++) + for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_SMALL_SCENERY_OBJECTS; sceneryId++) { rct_scenery_entry* sceneryEntry = get_small_scenery_entry(sceneryId); if (sceneryEntry == nullptr) @@ -288,7 +289,7 @@ void window_scenery_init() } // large scenery - for (uint16_t sceneryId = 0; sceneryId < MAX_LARGE_SCENERY_OBJECTS; sceneryId++) + for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_LARGE_SCENERY_OBJECTS; sceneryId++) { rct_scenery_entry* sceneryEntry = get_large_scenery_entry(sceneryId); if (sceneryEntry == nullptr) @@ -298,7 +299,7 @@ void window_scenery_init() } // walls - for (uint16_t sceneryId = 0; sceneryId < MAX_WALL_SCENERY_OBJECTS; sceneryId++) + for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_WALL_SCENERY_OBJECTS; sceneryId++) { rct_scenery_entry* sceneryEntry = get_wall_entry(sceneryId); if (sceneryEntry == nullptr) @@ -308,7 +309,7 @@ void window_scenery_init() } // banners - for (uint16_t sceneryId = 0; sceneryId < MAX_BANNER_OBJECTS; sceneryId++) + for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_BANNER_OBJECTS; sceneryId++) { rct_scenery_entry* sceneryEntry = get_banner_entry(sceneryId); if (sceneryEntry == nullptr) @@ -318,7 +319,7 @@ void window_scenery_init() } // path bits - for (uint16_t sceneryId = 0; sceneryId < MAX_PATH_ADDITION_OBJECTS; sceneryId++) + for (ObjectEntryIndex sceneryId = 0; sceneryId < MAX_PATH_ADDITION_OBJECTS; sceneryId++) { rct_scenery_entry* sceneryEntry = get_footpath_item_entry(sceneryId); if (sceneryEntry == nullptr) diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 665b8f66eb..2d060f9dee 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -298,7 +298,7 @@ namespace Editor for (BannerIndex i = 0; i < MAX_BANNERS; i++) { auto banner = GetBanner(i); - if (banner->type == BANNER_NULL) + if (banner->IsNull()) { banner->flags &= ~BANNER_FLAG_LINKED_TO_RIDE; } diff --git a/src/openrct2/EditorObjectSelectionSession.cpp b/src/openrct2/EditorObjectSelectionSession.cpp index 1cdb1119f5..919204a282 100644 --- a/src/openrct2/EditorObjectSelectionSession.cpp +++ b/src/openrct2/EditorObjectSelectionSession.cpp @@ -125,7 +125,7 @@ void setup_in_use_selection_flags() tile_element_iterator_begin(&iter); do { - uint16_t type; + ObjectEntryIndex type; switch (iter.element->GetType()) { diff --git a/src/openrct2/actions/BannerPlaceAction.hpp b/src/openrct2/actions/BannerPlaceAction.hpp index f35194b9a2..8190d75271 100644 --- a/src/openrct2/actions/BannerPlaceAction.hpp +++ b/src/openrct2/actions/BannerPlaceAction.hpp @@ -19,7 +19,7 @@ DEFINE_GAME_ACTION(BannerPlaceAction, GAME_COMMAND_PLACE_BANNER, GameActionResul { private: CoordsXYZD _loc; - uint8_t _bannerType{ std::numeric_limits::max() }; + ObjectEntryIndex _bannerType{ BANNER_NULL }; BannerIndex _bannerIndex{ BANNER_INDEX_NULL }; uint8_t _primaryColour; @@ -91,7 +91,7 @@ public: } auto banner = GetBanner(_bannerIndex); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("Banner index in use, bannerIndex = %u", _bannerIndex); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); @@ -129,7 +129,7 @@ public: } auto banner = GetBanner(_bannerIndex); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("Banner index in use, bannerIndex = %u", _bannerIndex); return MakeResult(GA_ERROR::INVALID_PARAMETERS, STR_CANT_POSITION_THIS_HERE); diff --git a/src/openrct2/actions/FootpathPlaceAction.hpp b/src/openrct2/actions/FootpathPlaceAction.hpp index ec06560f57..5cb4e0feba 100644 --- a/src/openrct2/actions/FootpathPlaceAction.hpp +++ b/src/openrct2/actions/FootpathPlaceAction.hpp @@ -28,12 +28,12 @@ DEFINE_GAME_ACTION(FootpathPlaceAction, GAME_COMMAND_PLACE_PATH, GameActionResul private: CoordsXYZ _loc; uint8_t _slope; - uint8_t _type; + ObjectEntryIndex _type; Direction _direction = INVALID_DIRECTION; public: FootpathPlaceAction() = default; - FootpathPlaceAction(const CoordsXYZ& loc, uint8_t slope, uint8_t type, Direction direction = INVALID_DIRECTION) + FootpathPlaceAction(const CoordsXYZ& loc, uint8_t slope, ObjectEntryIndex type, Direction direction = INVALID_DIRECTION) : _loc(loc) , _slope(slope) , _type(type) diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.hpp b/src/openrct2/actions/LargeSceneryPlaceAction.hpp index d12fdc3985..ca88b302ab 100644 --- a/src/openrct2/actions/LargeSceneryPlaceAction.hpp +++ b/src/openrct2/actions/LargeSceneryPlaceAction.hpp @@ -48,7 +48,7 @@ DEFINE_GAME_ACTION(LargeSceneryPlaceAction, GAME_COMMAND_PLACE_LARGE_SCENERY, La { private: CoordsXYZD _loc; - uint8_t _sceneryType{ std::numeric_limits::max() }; + ObjectEntryIndex _sceneryType{ OBJECT_ENTRY_INDEX_NULL }; uint8_t _primaryColour; uint8_t _secondaryColour; BannerIndex _bannerId{ BANNER_INDEX_NULL }; @@ -56,7 +56,7 @@ private: public: LargeSceneryPlaceAction() = default; - LargeSceneryPlaceAction(const CoordsXYZD& loc, uint8_t sceneryType, uint8_t primaryColour, uint8_t secondaryColour) + LargeSceneryPlaceAction(const CoordsXYZD& loc, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour) : _loc(loc) , _sceneryType(sceneryType) , _primaryColour(primaryColour) @@ -138,7 +138,7 @@ public: } auto banner = GetBanner(_bannerId); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("No free banners available"); return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); @@ -253,7 +253,7 @@ public: } auto banner = GetBanner(_bannerId); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("No free banners available"); return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 7915d84d8b..53612e2a72 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -140,7 +140,7 @@ private: for (BannerIndex i = 0; i < MAX_BANNERS; i++) { auto banner = GetBanner(i); - if (banner->type != BANNER_NULL && banner->flags & BANNER_FLAG_LINKED_TO_RIDE && banner->ride_index == _rideIndex) + if (!banner->IsNull() && banner->flags & BANNER_FLAG_LINKED_TO_RIDE && banner->ride_index == _rideIndex) { banner->flags &= ~BANNER_FLAG_LINKED_TO_RIDE; banner->text = {}; diff --git a/src/openrct2/actions/SmallSceneryRemoveAction.hpp b/src/openrct2/actions/SmallSceneryRemoveAction.hpp index 43b6550e89..2a6ef4ba6b 100644 --- a/src/openrct2/actions/SmallSceneryRemoveAction.hpp +++ b/src/openrct2/actions/SmallSceneryRemoveAction.hpp @@ -28,12 +28,12 @@ DEFINE_GAME_ACTION(SmallSceneryRemoveAction, GAME_COMMAND_REMOVE_SCENERY, GameAc private: CoordsXYZ _loc; uint8_t _quadrant; - uint8_t _sceneryType; + ObjectEntryIndex _sceneryType; public: SmallSceneryRemoveAction() = default; - SmallSceneryRemoveAction(const CoordsXYZ& location, uint8_t quadrant, uint8_t sceneryType) + SmallSceneryRemoveAction(const CoordsXYZ& location, uint8_t quadrant, ObjectEntryIndex sceneryType) : _loc(location) , _quadrant(quadrant) , _sceneryType(sceneryType) diff --git a/src/openrct2/actions/SmallScenerySetColourAction.hpp b/src/openrct2/actions/SmallScenerySetColourAction.hpp index bdabda65ed..60720bfa3a 100644 --- a/src/openrct2/actions/SmallScenerySetColourAction.hpp +++ b/src/openrct2/actions/SmallScenerySetColourAction.hpp @@ -32,7 +32,7 @@ DEFINE_GAME_ACTION(SmallScenerySetColourAction, GAME_COMMAND_SET_SCENERY_COLOUR, private: CoordsXYZ _loc; uint8_t _quadrant; - uint8_t _sceneryType; + ObjectEntryIndex _sceneryType; uint8_t _primaryColour; uint8_t _secondaryColour; @@ -40,7 +40,7 @@ public: SmallScenerySetColourAction() = default; SmallScenerySetColourAction( - const CoordsXYZ& loc, uint8_t quadrant, uint8_t sceneryType, uint8_t primaryColour, uint8_t secondaryColour) + const CoordsXYZ& loc, uint8_t quadrant, ObjectEntryIndex sceneryType, uint8_t primaryColour, uint8_t secondaryColour) : _loc(loc) , _quadrant(quadrant) , _sceneryType(sceneryType) diff --git a/src/openrct2/actions/WallPlaceAction.hpp b/src/openrct2/actions/WallPlaceAction.hpp index dc98b22fdc..b8993a0a37 100644 --- a/src/openrct2/actions/WallPlaceAction.hpp +++ b/src/openrct2/actions/WallPlaceAction.hpp @@ -260,7 +260,7 @@ public: } auto banner = GetBanner(_bannerId); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("No free banners available"); return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); @@ -351,7 +351,7 @@ public: } auto banner = GetBanner(_bannerId); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { log_error("No free banners available"); return std::make_unique(GA_ERROR::NO_FREE_ELEMENTS); diff --git a/src/openrct2/interface/InteractiveConsole.cpp b/src/openrct2/interface/InteractiveConsole.cpp index a23c4eee9d..1c026c40e1 100644 --- a/src/openrct2/interface/InteractiveConsole.cpp +++ b/src/openrct2/interface/InteractiveConsole.cpp @@ -1251,7 +1251,7 @@ static int32_t cc_show_limits(InteractiveConsole& console, [[maybe_unused]] cons for (BannerIndex i = 0; i < MAX_BANNERS; ++i) { auto banner = GetBanner(i); - if (banner->type != BANNER_NULL) + if (!banner->IsNull()) { bannerCount++; } diff --git a/src/openrct2/object/BannerObject.cpp b/src/openrct2/object/BannerObject.cpp index dd9e06afe1..32d58cc1d8 100644 --- a/src/openrct2/object/BannerObject.cpp +++ b/src/openrct2/object/BannerObject.cpp @@ -23,8 +23,8 @@ void BannerObject::ReadLegacy(IReadObjectContext* context, IStream* stream) _legacyType.banner.scrolling_mode = stream->ReadValue(); _legacyType.banner.flags = stream->ReadValue(); _legacyType.banner.price = stream->ReadValue(); - _legacyType.banner.scenery_tab_id = stream->ReadValue(); - stream->Seek(1, STREAM_SEEK_CURRENT); + _legacyType.banner.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; + stream->Seek(2, STREAM_SEEK_CURRENT); GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); diff --git a/src/openrct2/object/FootpathItemObject.cpp b/src/openrct2/object/FootpathItemObject.cpp index 7b35bbbdca..38b0135e9f 100644 --- a/src/openrct2/object/FootpathItemObject.cpp +++ b/src/openrct2/object/FootpathItemObject.cpp @@ -27,8 +27,8 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream _legacyType.path_bit.draw_type = stream->ReadValue(); _legacyType.path_bit.tool_id = stream->ReadValue(); _legacyType.path_bit.price = stream->ReadValue(); - _legacyType.path_bit.scenery_tab_id = stream->ReadValue(); - stream->Seek(1, STREAM_SEEK_CURRENT); + _legacyType.path_bit.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; + stream->Seek(2, STREAM_SEEK_CURRENT); GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); diff --git a/src/openrct2/object/ObjectList.h b/src/openrct2/object/ObjectList.h index 63128e896a..62021445e0 100644 --- a/src/openrct2/object/ObjectList.h +++ b/src/openrct2/object/ObjectList.h @@ -17,7 +17,7 @@ #include "../world/Water.h" #include "ObjectLimits.h" -void get_type_entry_index(size_t index, uint8_t* outObjectType, uint16_t* outEntryIndex); +void get_type_entry_index(size_t index, uint8_t* outObjectType, ObjectEntryIndex* outEntryIndex); const rct_object_entry* get_loaded_object_entry(size_t index); void* get_loaded_object_chunk(size_t index); uint8_t object_entry_get_type(const rct_object_entry* objectEntry); diff --git a/src/openrct2/object/WallObject.cpp b/src/openrct2/object/WallObject.cpp index dd2304f7e0..64ba0dd5ba 100644 --- a/src/openrct2/object/WallObject.cpp +++ b/src/openrct2/object/WallObject.cpp @@ -25,7 +25,8 @@ void WallObject::ReadLegacy(IReadObjectContext* context, IStream* stream) _legacyType.wall.height = stream->ReadValue(); _legacyType.wall.flags2 = stream->ReadValue(); _legacyType.wall.price = stream->ReadValue(); - _legacyType.wall.scenery_tab_id = stream->ReadValue(); + _legacyType.wall.scenery_tab_id = OBJECT_ENTRY_INDEX_NULL; + stream->Seek(1, STREAM_SEEK_CURRENT); _legacyType.wall.scrolling_mode = stream->ReadValue(); GetStringTable().Read(context, stream, OBJ_STRING_ID_NAME); diff --git a/src/openrct2/peep/Guest.cpp b/src/openrct2/peep/Guest.cpp index 9de72c660b..0bcf29292f 100644 --- a/src/openrct2/peep/Guest.cpp +++ b/src/openrct2/peep/Guest.cpp @@ -971,7 +971,7 @@ void Guest::Tick128UpdateGuest(int32_t index) // Check if the footpath has a queue line TV monitor on it if (tileElement->AsPath()->HasAddition() && !tileElement->AsPath()->AdditionIsGhost()) { - uint8_t pathSceneryIndex = tileElement->AsPath()->GetAdditionEntryIndex(); + auto pathSceneryIndex = tileElement->AsPath()->GetAdditionEntryIndex(); rct_scenery_entry* sceneryEntry = get_footpath_item_entry(pathSceneryIndex); if (sceneryEntry != nullptr && sceneryEntry->path_bit.flags & PATH_BIT_FLAG_IS_QUEUE_SCREEN) { diff --git a/src/openrct2/rct1/S4Importer.cpp b/src/openrct2/rct1/S4Importer.cpp index 519a67c9ac..7a81b361ed 100644 --- a/src/openrct2/rct1/S4Importer.cpp +++ b/src/openrct2/rct1/S4Importer.cpp @@ -2063,7 +2063,7 @@ private: } else { - uint8_t railingsEntryIndex; + ObjectEntryIndex railingsEntryIndex; switch (src2->GetRCT1SupportType()) { case RCT1_PATH_SUPPORT_TYPE_COATED_WOOD: @@ -2083,10 +2083,10 @@ private: } // Additions - uint8_t additionType = dst2->GetAddition(); + ObjectEntryIndex additionType = dst2->GetAddition(); if (additionType != RCT1_PATH_ADDITION_NONE) { - uint8_t normalisedType = RCT1::NormalisePathAddition(additionType); + ObjectEntryIndex normalisedType = RCT1::NormalisePathAddition(additionType); entryIndex = _pathAdditionTypeToEntryMap[normalisedType]; if (additionType != normalisedType) { diff --git a/src/openrct2/rct12/RCT12.h b/src/openrct2/rct12/RCT12.h index d773c20c04..8f9a3717a2 100644 --- a/src/openrct2/rct12/RCT12.h +++ b/src/openrct2/rct12/RCT12.h @@ -57,6 +57,9 @@ constexpr const uint8_t RCT12_TILE_ELEMENT_SURFACE_TERRAIN_MASK = 0xE0; // constexpr uint16_t const RCT12_XY8_UNDEFINED = 0xFFFF; +using RCT12ObjectEntryIndex = uint8_t; +constexpr const RCT12ObjectEntryIndex RCT12_OBJECT_ENTRY_INDEX_NULL = 255; + // Everything before this point has been researched constexpr const uint32_t RCT12_RESEARCHED_ITEMS_SEPARATOR = 0xFFFFFFFF; // Everything before this point and after separator still requires research @@ -357,7 +360,7 @@ private: }; public: - uint8_t GetEntryIndex() const; + RCT12ObjectEntryIndex GetEntryIndex() const; uint8_t GetQueueBannerDirection() const; bool IsSloped() const; uint8_t GetSlopeDirection() const; @@ -374,7 +377,7 @@ public: uint8_t GetRCT1PathType() const; uint8_t GetRCT1SupportType() const; - void SetPathEntryIndex(uint8_t newIndex); + void SetPathEntryIndex(RCT12ObjectEntryIndex newIndex); void SetQueueBannerDirection(uint8_t direction); void SetSloped(bool isSloped); void SetSlopeDirection(uint8_t newSlope); @@ -468,14 +471,14 @@ private: uint8_t colour_1; // 6 uint8_t colour_2; // 7 public: - uint8_t GetEntryIndex() const; + RCT12ObjectEntryIndex GetEntryIndex() const; uint8_t GetAge() const; uint8_t GetSceneryQuadrant() const; colour_t GetPrimaryColour() const; colour_t GetSecondaryColour() const; bool NeedsSupports() const; - void SetEntryIndex(uint8_t newIndex); + void SetEntryIndex(RCT12ObjectEntryIndex newIndex); void SetAge(uint8_t newAge); void SetSceneryQuadrant(uint8_t newQuadrant); void SetPrimaryColour(colour_t colour); @@ -514,7 +517,7 @@ private: uint8_t colour_1; // 6 0b_2221_1111 2 = colour_2 (uses flags for rest of colour2), 1 = colour_1 uint8_t animation; // 7 0b_dfff_ft00 d = direction, f = frame num, t = across track flag (not used) public: - uint8_t GetEntryIndex() const; + RCT12ObjectEntryIndex GetEntryIndex() const; uint8_t GetSlope() const; colour_t GetPrimaryColour() const; colour_t GetSecondaryColour() const; @@ -527,7 +530,7 @@ public: int32_t GetRCT1WallType(int32_t edge) const; colour_t GetRCT1WallColour() const; - void SetEntryIndex(uint8_t newIndex); + void SetEntryIndex(RCT12ObjectEntryIndex newIndex); void SetSlope(uint8_t newslope); void SetPrimaryColour(colour_t newColour); void SetSecondaryColour(colour_t newColour); @@ -777,7 +780,7 @@ struct RCT12ResearchItem uint32_t rawValue; struct { - uint8_t entryIndex; + RCT12ObjectEntryIndex entryIndex; uint8_t baseRideType; uint8_t type; // 0: scenery entry, 1: ride entry uint8_t flags; @@ -793,8 +796,5 @@ assert_struct_size(RCT12ResearchItem, 5); #pragma pack(pop) -using RCT12ObjectEntryIndex = uint8_t; -constexpr const RCT12ObjectEntryIndex RCT12_OBJECT_ENTRY_INDEX_NULL = 255; - ObjectEntryIndex RCTEntryIndexToOpenRCT2EntryIndex(RCT12ObjectEntryIndex index); RCT12ObjectEntryIndex OpenRCT2EntryIndexToRCTEntryIndex(ObjectEntryIndex index); diff --git a/src/openrct2/rct2/RCT2.h b/src/openrct2/rct2/RCT2.h index d42e070fc3..7e764acfc0 100644 --- a/src/openrct2/rct2/RCT2.h +++ b/src/openrct2/rct2/RCT2.h @@ -103,7 +103,7 @@ struct rct2_ride uint8_t type; // 0x000 // pointer to static info. for example, wild mouse type is 0x36, subtype is // 0x4c. - uint8_t subtype; // 0x001 + RCT12ObjectEntryIndex subtype; // 0x001 uint16_t pad_002; // 0x002 uint8_t mode; // 0x004 uint8_t colour_scheme_type; // 0x005 diff --git a/src/openrct2/world/Banner.h b/src/openrct2/world/Banner.h index 2daea0670f..407f9d4b91 100644 --- a/src/openrct2/world/Banner.h +++ b/src/openrct2/world/Banner.h @@ -21,7 +21,7 @@ struct WallElement; using BannerIndex = uint16_t; -constexpr uint8_t BANNER_NULL = 255; +constexpr ObjectEntryIndex BANNER_NULL = OBJECT_ENTRY_INDEX_NULL; constexpr size_t MAX_BANNERS = 250; constexpr BannerIndex BANNER_INDEX_NULL = static_cast(-1); @@ -29,7 +29,7 @@ constexpr uint8_t SCROLLING_MODE_NONE = 255; struct Banner { - uint8_t type = BANNER_NULL; + ObjectEntryIndex type = BANNER_NULL; uint8_t flags{}; std::string text; uint8_t colour{}; diff --git a/src/openrct2/world/Footpath.cpp b/src/openrct2/world/Footpath.cpp index 8c9fd33a82..d85e04df2a 100644 --- a/src/openrct2/world/Footpath.cpp +++ b/src/openrct2/world/Footpath.cpp @@ -1535,7 +1535,7 @@ uint8_t PathElement::GetAddition() const return Additions; } -uint8_t PathElement::GetAdditionEntryIndex() const +ObjectEntryIndex PathElement::GetAdditionEntryIndex() const { return GetAddition() - 1; } diff --git a/src/openrct2/world/Fountain.cpp b/src/openrct2/world/Fountain.cpp index 0de687c430..37a0fff9f3 100644 --- a/src/openrct2/world/Fountain.cpp +++ b/src/openrct2/world/Fountain.cpp @@ -263,7 +263,7 @@ bool JumpingFountain::IsJumpingFountain(const int32_t newType, const CoordsXYZ& if (!tileElement->AsPath()->HasAddition()) continue; - const uint8_t additionIndex = tileElement->AsPath()->GetAdditionEntryIndex(); + const auto additionIndex = tileElement->AsPath()->GetAdditionEntryIndex(); rct_scenery_entry* sceneryEntry = get_footpath_item_entry(additionIndex); if (sceneryEntry != nullptr && sceneryEntry->path_bit.flags & pathBitFlagMask) { diff --git a/src/openrct2/world/Scenery.cpp b/src/openrct2/world/Scenery.cpp index 5d248eef22..169f6e73ea 100644 --- a/src/openrct2/world/Scenery.cpp +++ b/src/openrct2/world/Scenery.cpp @@ -229,7 +229,7 @@ void scenery_remove_ghost_tool_placement() } } -rct_scenery_entry* get_wall_entry(int32_t entryIndex) +rct_scenery_entry* get_wall_entry(ObjectEntryIndex entryIndex) { rct_scenery_entry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); @@ -241,7 +241,7 @@ rct_scenery_entry* get_wall_entry(int32_t entryIndex) return result; } -rct_scenery_entry* get_banner_entry(int32_t entryIndex) +rct_scenery_entry* get_banner_entry(ObjectEntryIndex entryIndex) { rct_scenery_entry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); @@ -253,7 +253,7 @@ rct_scenery_entry* get_banner_entry(int32_t entryIndex) return result; } -rct_scenery_entry* get_footpath_item_entry(int32_t entryIndex) +rct_scenery_entry* get_footpath_item_entry(ObjectEntryIndex entryIndex) { rct_scenery_entry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); @@ -265,7 +265,7 @@ rct_scenery_entry* get_footpath_item_entry(int32_t entryIndex) return result; } -rct_scenery_group_entry* get_scenery_group_entry(int32_t entryIndex) +rct_scenery_group_entry* get_scenery_group_entry(ObjectEntryIndex entryIndex) { rct_scenery_group_entry* result = nullptr; auto& objMgr = OpenRCT2::GetContext()->GetObjectManager(); diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index 824f11367c..8fc76d456b 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -23,20 +23,17 @@ #pragma pack(push, 1) struct rct_small_scenery_entry { - uint32_t flags; // 0x06 - uint8_t height; // 0x0A - uint8_t tool_id; // 0x0B - int16_t price; // 0x0C - int16_t removal_price; // 0x0E - uint8_t* frame_offsets; // 0x10 - uint16_t animation_delay; // 0x14 - uint16_t animation_mask; // 0x16 - uint16_t num_frames; // 0x18 - uint8_t scenery_tab_id; // 0x1A + uint32_t flags; // 0x06 + uint8_t height; // 0x0A + uint8_t tool_id; // 0x0B + int16_t price; // 0x0C + int16_t removal_price; // 0x0E + uint8_t* frame_offsets; // 0x10 + uint16_t animation_delay; // 0x14 + uint16_t animation_mask; // 0x16 + uint16_t num_frames; // 0x18 + ObjectEntryIndex scenery_tab_id; // 0x1A }; -#ifdef PLATFORM_32BIT -assert_struct_size(rct_small_scenery_entry, 21); -#endif struct rct_large_scenery_tile { @@ -83,19 +80,16 @@ enum LARGE_SCENERY_TEXT_FLAGS struct rct_large_scenery_entry { - uint8_t tool_id; // 0x06 - uint8_t flags; // 0x07 - int16_t price; // 0x08 - int16_t removal_price; // 0x0A - rct_large_scenery_tile* tiles; // 0x0C - uint8_t scenery_tab_id; // 0x10 - uint8_t scrolling_mode; // 0x11 - rct_large_scenery_text* text; // 0x12 - uint32_t text_image; // 0x16 + uint8_t tool_id; + uint8_t flags; + int16_t price; + int16_t removal_price; + rct_large_scenery_tile* tiles; + ObjectEntryIndex scenery_tab_id; + uint8_t scrolling_mode; + rct_large_scenery_text* text; + uint32_t text_image; }; -#ifdef PLATFORM_32BIT -assert_struct_size(rct_large_scenery_entry, 20); -#endif enum LARGE_SCENERY_FLAGS { @@ -108,15 +102,14 @@ enum LARGE_SCENERY_FLAGS struct rct_wall_scenery_entry { - uint8_t tool_id; // 0x06 - uint8_t flags; // 0x07 - uint8_t height; // 0x08 - uint8_t flags2; // 0x09 - int16_t price; // 0x0A - uint8_t scenery_tab_id; // 0x0C - uint8_t scrolling_mode; // 0x0D 0xFF if no scrolling + uint8_t tool_id; + uint8_t flags; + uint8_t height; + uint8_t flags2; + int16_t price; + ObjectEntryIndex scenery_tab_id; + uint8_t scrolling_mode; }; -assert_struct_size(rct_wall_scenery_entry, 8); enum WALL_SCENERY_FLAGS { @@ -141,22 +134,20 @@ enum WALL_SCENERY_2_FLAGS struct rct_path_bit_scenery_entry { - uint16_t flags; // 0x06 - uint8_t draw_type; // 0x08 - uint8_t tool_id; // 0x09 - int16_t price; // 0x0A - uint8_t scenery_tab_id; // 0x0C + uint16_t flags; // 0x06 + uint8_t draw_type; // 0x08 + uint8_t tool_id; // 0x09 + int16_t price; // 0x0A + ObjectEntryIndex scenery_tab_id; // 0x0C }; -assert_struct_size(rct_path_bit_scenery_entry, 7); struct rct_banner_scenery_entry { - uint8_t scrolling_mode; // 0x06 - uint8_t flags; // 0x07 - int16_t price; // 0x08 - uint8_t scenery_tab_id; // 0x0A + uint8_t scrolling_mode; // 0x06 + uint8_t flags; // 0x07 + int16_t price; // 0x08 + ObjectEntryIndex scenery_tab_id; // 0x0A }; -assert_struct_size(rct_banner_scenery_entry, 5); struct rct_scenery_entry { @@ -171,9 +162,6 @@ struct rct_scenery_entry rct_banner_scenery_entry banner; }; }; -#ifdef PLATFORM_32BIT -assert_struct_size(rct_scenery_entry, 6 + 21); -#endif #pragma pack(pop) @@ -269,10 +257,10 @@ void scenery_update_tile(const CoordsXY& sceneryPos); void scenery_set_default_placement_configuration(); void scenery_remove_ghost_tool_placement(); -rct_scenery_entry* get_wall_entry(int32_t entryIndex); -rct_scenery_entry* get_banner_entry(int32_t entryIndex); -rct_scenery_entry* get_footpath_item_entry(int32_t entryIndex); -rct_scenery_group_entry* get_scenery_group_entry(int32_t entryIndex); +rct_scenery_entry* get_wall_entry(ObjectEntryIndex entryIndex); +rct_scenery_entry* get_banner_entry(ObjectEntryIndex entryIndex); +rct_scenery_entry* get_footpath_item_entry(ObjectEntryIndex entryIndex); +rct_scenery_group_entry* get_scenery_group_entry(ObjectEntryIndex entryIndex); int32_t wall_entry_get_door_sound(const rct_scenery_entry* wallEntry); diff --git a/src/openrct2/world/ScenerySelection.h b/src/openrct2/world/ScenerySelection.h index 71303d9a75..7c3a7a83b2 100644 --- a/src/openrct2/world/ScenerySelection.h +++ b/src/openrct2/world/ScenerySelection.h @@ -9,6 +9,8 @@ #pragma once +#include "../object/Object.h" + #include #include @@ -17,7 +19,7 @@ constexpr auto WINDOW_SCENERY_TAB_SELECTION_UNDEFINED = std::numeric_limits