diff --git a/src/openrct2-ui/windows/Scenery.cpp b/src/openrct2-ui/windows/Scenery.cpp index 3251b1be9f..aa362d26e9 100644 --- a/src/openrct2-ui/windows/Scenery.cpp +++ b/src/openrct2-ui/windows/Scenery.cpp @@ -277,7 +277,7 @@ void window_scenery_init() } // small scenery - for (uint16_t sceneryId = SCENERY_SMALL_SCENERY_ID_MIN; sceneryId < SCENERY_SMALL_SCENERY_ID_MAX; sceneryId++) + for (uint16_t sceneryId = SCENERY_SMALL_SCENERY_ID_MIN; sceneryId <= SCENERY_SMALL_SCENERY_ID_MAX; sceneryId++) { rct_scenery_entry* sceneryEntry = get_small_scenery_entry(sceneryId); if (sceneryEntry == nullptr) @@ -287,7 +287,7 @@ void window_scenery_init() } // large scenery - for (int32_t sceneryId = SCENERY_LARGE_SCENERY_ID_MIN; sceneryId < SCENERY_LARGE_SCENERY_ID_MAX; sceneryId++) + for (int32_t sceneryId = SCENERY_LARGE_SCENERY_ID_MIN; sceneryId <= SCENERY_LARGE_SCENERY_ID_MAX; sceneryId++) { int32_t largeSceneryIndex = sceneryId - SCENERY_LARGE_SCENERY_ID_MIN; @@ -299,7 +299,7 @@ void window_scenery_init() } // walls - for (int32_t sceneryId = SCENERY_WALLS_ID_MIN; sceneryId < SCENERY_WALLS_ID_MAX; sceneryId++) + for (int32_t sceneryId = SCENERY_WALLS_ID_MIN; sceneryId <= SCENERY_WALLS_ID_MAX; sceneryId++) { int32_t wallSceneryIndex = sceneryId - SCENERY_WALLS_ID_MIN; @@ -311,7 +311,7 @@ void window_scenery_init() } // banners - for (int32_t sceneryId = SCENERY_BANNERS_ID_MIN; sceneryId < SCENERY_BANNERS_ID_MAX; sceneryId++) + for (int32_t sceneryId = SCENERY_BANNERS_ID_MIN; sceneryId <= SCENERY_BANNERS_ID_MAX; sceneryId++) { int32_t bannerIndex = sceneryId - SCENERY_BANNERS_ID_MIN; @@ -323,7 +323,7 @@ void window_scenery_init() } // path bits - for (int32_t sceneryId = SCENERY_PATH_SCENERY_ID_MIN; sceneryId < SCENERY_PATH_SCENERY_ID_MAX; sceneryId++) + for (int32_t sceneryId = SCENERY_PATH_SCENERY_ID_MIN; sceneryId <= SCENERY_PATH_SCENERY_ID_MAX; sceneryId++) { int32_t pathBitIndex = sceneryId - SCENERY_PATH_SCENERY_ID_MIN; @@ -832,22 +832,24 @@ static void window_scenery_update(rct_window* w) if (tabSelectedSceneryId != -1) { - if (tabSelectedSceneryId >= 0x400) + if (tabSelectedSceneryId >= SCENERY_BANNERS_ID_MIN) { // banner gCurrentToolId = TOOL_ENTRANCE_DOWN; } - else if (tabSelectedSceneryId >= 0x300) + else if (tabSelectedSceneryId >= SCENERY_LARGE_SCENERY_ID_MIN) { // large scenery gCurrentToolId = static_cast( - get_large_scenery_entry(tabSelectedSceneryId - 0x300)->large_scenery.tool_id); + get_large_scenery_entry(tabSelectedSceneryId - SCENERY_LARGE_SCENERY_ID_MIN)->large_scenery.tool_id); } - else if (tabSelectedSceneryId >= 0x200) + else if (tabSelectedSceneryId >= SCENERY_WALLS_ID_MIN) { // wall - gCurrentToolId = static_cast(get_wall_entry(tabSelectedSceneryId - 0x200)->wall.tool_id); + gCurrentToolId = static_cast( + get_wall_entry(tabSelectedSceneryId - SCENERY_WALLS_ID_MIN)->wall.tool_id); } - else if (tabSelectedSceneryId >= 0x100) + else if (tabSelectedSceneryId >= SCENERY_PATH_SCENERY_ID_MIN) { // path bit - gCurrentToolId = static_cast(get_footpath_item_entry(tabSelectedSceneryId - 0x100)->path_bit.tool_id); + gCurrentToolId = static_cast( + get_footpath_item_entry(tabSelectedSceneryId - SCENERY_PATH_SCENERY_ID_MIN)->path_bit.tool_id); } else { // small scenery @@ -996,7 +998,7 @@ void window_scenery_invalidate(rct_window* w) int16_t tabSelectedSceneryId = gWindowSceneryTabSelections[tabIndex]; if (tabSelectedSceneryId != -1) { - if (tabSelectedSceneryId < 0x100) + if (tabSelectedSceneryId <= SCENERY_SMALL_SCENERY_ID_MAX) { if (!(gWindowSceneryPaintEnabled & 1)) { @@ -1009,7 +1011,7 @@ void window_scenery_invalidate(rct_window* w) window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_FLATBTN; } } - else if (tabSelectedSceneryId >= 0x300) + else if (tabSelectedSceneryId >= SCENERY_LARGE_SCENERY_ID_MIN) { window_scenery_widgets[WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type = WWT_FLATBTN; } @@ -1038,26 +1040,26 @@ void window_scenery_invalidate(rct_window* w) { rct_scenery_entry* sceneryEntry = nullptr; - if (tabSelectedSceneryId >= 0x400) + if (tabSelectedSceneryId >= SCENERY_BANNERS_ID_MIN) { - sceneryEntry = get_banner_entry(tabSelectedSceneryId - 0x400); + sceneryEntry = get_banner_entry(tabSelectedSceneryId - SCENERY_BANNERS_ID_MIN); if (sceneryEntry->banner.flags & BANNER_ENTRY_FLAG_HAS_PRIMARY_COLOUR) { window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLOURBTN; } } - else if (tabSelectedSceneryId >= 0x300) + else if (tabSelectedSceneryId >= SCENERY_LARGE_SCENERY_ID_MIN) { - sceneryEntry = get_large_scenery_entry(tabSelectedSceneryId - 0x300); + sceneryEntry = get_large_scenery_entry(tabSelectedSceneryId - SCENERY_LARGE_SCENERY_ID_MIN); if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_HAS_PRIMARY_COLOUR) window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLOURBTN; if (sceneryEntry->large_scenery.flags & LARGE_SCENERY_FLAG_HAS_SECONDARY_COLOUR) window_scenery_widgets[WIDX_SCENERY_SECONDARY_COLOUR_BUTTON].type = WWT_COLOURBTN; } - else if (tabSelectedSceneryId >= 0x200) + else if (tabSelectedSceneryId >= SCENERY_WALLS_ID_MIN) { - sceneryEntry = get_wall_entry(tabSelectedSceneryId - 0x200); + sceneryEntry = get_wall_entry(tabSelectedSceneryId - SCENERY_WALLS_ID_MIN); if (sceneryEntry->wall.flags & (WALL_SCENERY_HAS_PRIMARY_COLOUR | WALL_SCENERY_HAS_GLASS)) { window_scenery_widgets[WIDX_SCENERY_PRIMARY_COLOUR_BUTTON].type = WWT_COLOURBTN; @@ -1073,7 +1075,7 @@ void window_scenery_invalidate(rct_window* w) } } } - else if (tabSelectedSceneryId < 0x100) + else if (tabSelectedSceneryId <= SCENERY_SMALL_SCENERY_ID_MAX) { sceneryEntry = get_small_scenery_entry(tabSelectedSceneryId); @@ -1148,24 +1150,24 @@ void window_scenery_paint(rct_window* w, rct_drawpixelinfo* dpi) uint32_t price = 0; rct_scenery_entry* sceneryEntry = nullptr; - if (selectedSceneryEntryId >= 0x400) + if (selectedSceneryEntryId >= SCENERY_BANNERS_ID_MIN) { - sceneryEntry = get_banner_entry(selectedSceneryEntryId - 0x400); + sceneryEntry = get_banner_entry(selectedSceneryEntryId - SCENERY_BANNERS_ID_MIN); price = sceneryEntry->banner.price; } - else if (selectedSceneryEntryId >= 0x300) + else if (selectedSceneryEntryId >= SCENERY_LARGE_SCENERY_ID_MIN) { - sceneryEntry = get_large_scenery_entry(selectedSceneryEntryId - 0x300); + sceneryEntry = get_large_scenery_entry(selectedSceneryEntryId - SCENERY_LARGE_SCENERY_ID_MIN); price = sceneryEntry->large_scenery.price * 10; } - else if (selectedSceneryEntryId >= 0x200) + else if (selectedSceneryEntryId >= SCENERY_WALLS_ID_MIN) { - sceneryEntry = get_wall_entry(selectedSceneryEntryId - 0x200); + sceneryEntry = get_wall_entry(selectedSceneryEntryId - SCENERY_WALLS_ID_MIN); price = sceneryEntry->wall.price; } - else if (selectedSceneryEntryId >= 0x100) + else if (selectedSceneryEntryId >= SCENERY_PATH_SCENERY_ID_MIN) { - sceneryEntry = get_footpath_item_entry(selectedSceneryEntryId - 0x100); + sceneryEntry = get_footpath_item_entry(selectedSceneryEntryId - SCENERY_PATH_SCENERY_ID_MIN); price = sceneryEntry->path_bit.price; } else diff --git a/src/openrct2/object/SceneryGroupObject.cpp b/src/openrct2/object/SceneryGroupObject.cpp index 21b50d3705..e22630aa39 100644 --- a/src/openrct2/object/SceneryGroupObject.cpp +++ b/src/openrct2/object/SceneryGroupObject.cpp @@ -91,22 +91,22 @@ void SceneryGroupObject::UpdateEntryIndexes() case OBJECT_TYPE_SMALL_SCENERY: break; case OBJECT_TYPE_PATH_BITS: - sceneryEntry |= 0x100; + sceneryEntry += SCENERY_PATH_SCENERY_ID_MIN; break; case OBJECT_TYPE_WALLS: - sceneryEntry |= 0x200; + sceneryEntry += SCENERY_WALLS_ID_MIN; break; case OBJECT_TYPE_LARGE_SCENERY: - sceneryEntry |= 0x300; + sceneryEntry += SCENERY_LARGE_SCENERY_ID_MIN; break; case OBJECT_TYPE_BANNERS: - sceneryEntry |= 0x400; + sceneryEntry += SCENERY_BANNERS_ID_MIN; break; default: - sceneryEntry = 0xFFFF; + sceneryEntry = UINT16_MAX; break; } - if (sceneryEntry != 0xFFFF) + if (sceneryEntry != UINT16_MAX) { _legacyType.scenery_entries[_legacyType.entry_count] = sceneryEntry; _legacyType.entry_count++; diff --git a/src/openrct2/world/Scenery.h b/src/openrct2/world/Scenery.h index ead02fd7a3..4a89686052 100644 --- a/src/openrct2/world/Scenery.h +++ b/src/openrct2/world/Scenery.h @@ -12,21 +12,23 @@ #include "../common.h" #include "../object/Object.h" +#include "../object/ObjectLimits.h" #include "../world/Location.hpp" #include "TileElement.h" #include -#define SCENERY_SMALL_SCENERY_ID_MIN 0x0 -#define SCENERY_SMALL_SCENERY_ID_MAX 0xFC -#define SCENERY_LARGE_SCENERY_ID_MIN 0x300 -#define SCENERY_LARGE_SCENERY_ID_MAX 0x380 -#define SCENERY_WALLS_ID_MIN 0x200 -#define SCENERY_WALLS_ID_MAX 0x280 -#define SCENERY_BANNERS_ID_MIN 0x400 -#define SCENERY_BANNERS_ID_MAX 0x420 -#define SCENERY_PATH_SCENERY_ID_MIN 0x100 -#define SCENERY_PATH_SCENERY_ID_MAX 0x10F +constexpr const uint16_t SCENERY_SMALL_SCENERY_ID_MIN = 0; +constexpr const uint16_t SCENERY_SMALL_SCENERY_ID_MAX = MAX_SMALL_SCENERY_OBJECTS - 1; +constexpr const uint16_t SCENERY_PATH_SCENERY_ID_MIN = 0x100; +constexpr const uint16_t SCENERY_PATH_SCENERY_ID_MAX = SCENERY_PATH_SCENERY_ID_MIN + MAX_PATH_ADDITION_OBJECTS - 1; +constexpr const uint16_t SCENERY_WALLS_ID_MIN = 0x200; +constexpr const uint16_t SCENERY_WALLS_ID_MAX = SCENERY_WALLS_ID_MIN + MAX_WALL_SCENERY_OBJECTS - 1; +constexpr const uint16_t SCENERY_LARGE_SCENERY_ID_MIN = 0x300; +constexpr const uint16_t SCENERY_LARGE_SCENERY_ID_MAX = SCENERY_LARGE_SCENERY_ID_MIN + MAX_LARGE_SCENERY_OBJECTS - 1; +constexpr const uint16_t SCENERY_BANNERS_ID_MIN = 0x400; +constexpr const uint16_t SCENERY_BANNERS_ID_MAX = SCENERY_BANNERS_ID_MIN + MAX_BANNER_OBJECTS - 1; + #define SCENERY_WITHER_AGE_THRESHOLD_1 0x28 #define SCENERY_WITHER_AGE_THRESHOLD_2 0x37