1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-20 13:33:02 +01:00

Introduce constant MAX_ELEMENT_HEIGHT

This commit is contained in:
Hielke Morsink
2020-05-05 11:35:42 +02:00
parent f88951eb33
commit b39c673456
3 changed files with 6 additions and 3 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -421,7 +421,8 @@ GameActionResult::Ptr tile_inspector_any_base_height_offset(
int16_t newBaseHeight = static_cast<int16_t>(tileElement->base_height + heightOffset);
int16_t newClearanceHeight = static_cast<int16_t>(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<GameActionResult>(GA_ERROR::UNKNOWN, STR_NONE);
}