diff --git a/src/openrct2/scripting/ScTile.hpp b/src/openrct2/scripting/ScTile.hpp index e7e3a72b6f..48682d6a0d 100644 --- a/src/openrct2/scripting/ScTile.hpp +++ b/src/openrct2/scripting/ScTile.hpp @@ -530,8 +530,8 @@ namespace OpenRCT2::Scripting const auto elementIndex = _element - map_get_first_element_at(_coords); // Insert corrupt element at the end of the list for this tile - // Note: Z = 255 guarantee this - TileElement* insertedElement = tile_element_insert({ _coords, 0xFF }, 0); + // Note: Z = MAX_ELEMENT_HEIGHT to guarantee this + TileElement* insertedElement = tile_element_insert({ _coords, MAX_ELEMENT_HEIGHT }, 0); if (insertedElement == nullptr) { // TODO: Show error diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h index 2b8de73e88..c5c0324c6f 100644 --- a/src/openrct2/world/TileElement.h +++ b/src/openrct2/world/TileElement.h @@ -21,6 +21,8 @@ struct rct_scenery_entry; struct rct_footpath_entry; using track_type_t = uint16_t; +constexpr const uint8_t MAX_ELEMENT_HEIGHT = 255; + #pragma pack(push, 1) enum diff --git a/src/openrct2/world/TileInspector.cpp b/src/openrct2/world/TileInspector.cpp index 0e309e0768..7b30204588 100644 --- a/src/openrct2/world/TileInspector.cpp +++ b/src/openrct2/world/TileInspector.cpp @@ -421,7 +421,8 @@ GameActionResult::Ptr tile_inspector_any_base_height_offset( int16_t newBaseHeight = static_cast(tileElement->base_height + heightOffset); int16_t newClearanceHeight = static_cast(tileElement->clearance_height + heightOffset); - if (newBaseHeight < 0 || newBaseHeight > 0xff || newClearanceHeight < 0 || newClearanceHeight > 0xff) + if (newBaseHeight < 0 || newBaseHeight > MAX_ELEMENT_HEIGHT || newClearanceHeight < 0 + || newClearanceHeight > MAX_ELEMENT_HEIGHT) { return std::make_unique(GA_ERROR::UNKNOWN, STR_NONE); }