1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-30 10:15:36 +01:00

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.
This commit is contained in:
jensj12
2017-07-13 17:31:37 +02:00
parent 2736058912
commit 1b69fe485f
2 changed files with 23 additions and 4 deletions

View File

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

View File

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