From 1b69fe485f455d160abd0d4c9c69d14ec98e21c6 Mon Sep 17 00:00:00 2001 From: jensj12 Date: Thu, 13 Jul 2017 17:31:37 +0200 Subject: [PATCH] Show error if too high/low Behaviour now matches that of the non-mountain land tool. Provide define for min/max land height and fix a bug where the mountain tool would incorrect raise/lower land. --- src/openrct2/world/map.c | 24 ++++++++++++++++++++---- src/openrct2/world/map.h | 3 +++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/openrct2/world/map.c b/src/openrct2/world/map.c index 0e85e0621d..bfc7e927ee 100644 --- a/src/openrct2/world/map.c +++ b/src/openrct2/world/map.c @@ -1512,21 +1512,21 @@ static money32 map_set_land_height(sint32 flags, sint32 x, sint32 y, sint32 heig return MONEY32_UNDEFINED; } - if (height < 2) { + if (height < MINIMUM_LAND_HEIGHT) { gGameCommandErrorText = STR_TOO_LOW; return MONEY32_UNDEFINED; } // Divide by 2 and subtract 7 to get the in-game units. - if (height > 142) { + if (height > MAXIMUM_LAND_HEIGHT) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; - } else if (height > 140 && (style & 0x1F) != 0) { + } else if (height > MAXIMUM_LAND_HEIGHT - 2 && (style & 0x1F) != 0) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } - if (height == 140 && (style & 0x10)) { + if (height == MAXIMUM_LAND_HEIGHT - 2 && (style & 0x10)) { gGameCommandErrorText = STR_TOO_HIGH; return MONEY32_UNDEFINED; } @@ -2220,10 +2220,18 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 if (commandType == GAME_COMMAND_RAISE_LAND) { minHeight += 2; maxHeight += 2; + if (minHeight > MAXIMUM_LAND_HEIGHT) { + gGameCommandErrorText = STR_TOO_HIGH; + return MONEY32_UNDEFINED; + } } else { maxHeight -= 2; minHeight -= 2; + if (maxHeight < MINIMUM_LAND_HEIGHT) { + gGameCommandErrorText = STR_TOO_LOW; + return MONEY32_UNDEFINED; + } } } else @@ -2237,6 +2245,10 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 newBaseZ += 2; newSlope &= ~0x20; } + if (map_get_corner_height(newBaseZ, newSlope, command & 0xFF) > MAXIMUM_LAND_HEIGHT) { + gGameCommandErrorText = STR_TOO_HIGH; + return MONEY32_UNDEFINED; + } } else { newSlope = map_element_lower_styles[command & 0xFF][newSlope]; @@ -2244,6 +2256,10 @@ static money32 smooth_land(sint32 flags, sint32 centreX, sint32 centreY, sint32 newBaseZ -= 2; newSlope &= ~0x20; } + if (newBaseZ < MINIMUM_LAND_HEIGHT) { + gGameCommandErrorText = STR_TOO_LOW; + return MONEY32_UNDEFINED; + } } } diff --git a/src/openrct2/world/map.h b/src/openrct2/world/map.h index bac15d97ba..487938da0c 100644 --- a/src/openrct2/world/map.h +++ b/src/openrct2/world/map.h @@ -273,6 +273,9 @@ enum #define MAP_ELEM_TRACK_SEQUENCE_SEQUENCE_MASK 0x0F #define MAP_ELEM_TRACK_SEQUENCE_TAKING_PHOTO_MASK 0xF0 +#define MINIMUM_LAND_HEIGHT 2 +#define MAXIMUM_LAND_HEIGHT 142 + #define MINIMUM_MAP_SIZE_TECHNICAL 15 #define MAXIMUM_MAP_SIZE_TECHNICAL 256 #define MINIMUM_MAP_SIZE_PRACTICAL (MINIMUM_MAP_SIZE_TECHNICAL-2)