From 8627a5875fe9e08b19b8fdb744b39b77960e2796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20L=C3=B6ppenberg?= <61902845+loeppenberg@users.noreply.github.com> Date: Sat, 6 May 2023 14:23:17 +0200 Subject: [PATCH] Fix #20007: Wrong Error message when raising land or water: "Too low!" (#20123) --- src/openrct2/actions/LandRaiseAction.cpp | 12 ++++++++++-- src/openrct2/actions/WaterRaiseAction.cpp | 9 ++++++++- src/openrct2/network/NetworkBase.cpp | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/openrct2/actions/LandRaiseAction.cpp b/src/openrct2/actions/LandRaiseAction.cpp index 5f78121871..2fdd40e293 100644 --- a/src/openrct2/actions/LandRaiseAction.cpp +++ b/src/openrct2/actions/LandRaiseAction.cpp @@ -110,8 +110,16 @@ GameActions::Result LandRaiseAction::QueryExecute(bool isExecuting) const uint8_t currentSlope = surfaceElement->GetSlope(); uint8_t newSlope = tile_element_raise_styles[tableRow][currentSlope]; if (newSlope & SURFACE_STYLE_FLAG_RAISE_OR_LOWER_BASE_HEIGHT) - height += 2; - + { + if (height + 2 > UINT8_MAX) + { + height = UINT8_MAX; + } + else + { + height += 2; + } + } newSlope &= TILE_ELEMENT_SURFACE_SLOPE_MASK; auto landSetHeightAction = LandSetHeightAction({ x, y }, height, newSlope); diff --git a/src/openrct2/actions/WaterRaiseAction.cpp b/src/openrct2/actions/WaterRaiseAction.cpp index a94e716664..2da3654222 100644 --- a/src/openrct2/actions/WaterRaiseAction.cpp +++ b/src/openrct2/actions/WaterRaiseAction.cpp @@ -94,7 +94,14 @@ GameActions::Result WaterRaiseAction::QueryExecute(bool isExecuting) const { if (height > maxHeight) continue; - height += 2; + if (height + 2 > UINT8_MAX) + { + height = UINT8_MAX; + } + else + { + height += 2; + } } else { diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index 670e3f58f5..d9c82ad5ff 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -43,7 +43,7 @@ // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "18" +#define NETWORK_STREAM_VERSION "19" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION