From 2e5f46fcf1b12100730ff1672a2f3e8f7d49fbcd Mon Sep 17 00:00:00 2001 From: Joseph Atkins-Turkish Date: Sun, 22 Sep 2019 05:13:52 -0700 Subject: [PATCH] Fix raise/lowering water at edge of map (#9979) --- distribution/changelog.txt | 1 + src/openrct2/actions/WaterLowerAction.hpp | 9 +++++---- src/openrct2/actions/WaterRaiseAction.hpp | 9 +++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index c0caee936a..29b5351968 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -15,6 +15,7 @@ - Fix: [#9625] Show correct cost in scenery selection. - Fix: [#9669] The tile inspector shortcut key does not work with debugging tools disabled. - Fix: [#9675] Guest entry point limit can be bypassed in scenario editor. +- Fix: [#9683] Cannot raise water level if part of the tool's area of effect is off of the map. - Fix: [#9717] Scroll bars do not render correctly when using OpenGL renderer. - Fix: [#9729] Peeps do not take into account height difference when deciding to pathfind to a ride entrance (original bug). - Fix: [#9902] Doors/Portcullis do not check to make sure doors are open causing double opens. diff --git a/src/openrct2/actions/WaterLowerAction.hpp b/src/openrct2/actions/WaterLowerAction.hpp index 807a1f10cd..3218bbcbb9 100644 --- a/src/openrct2/actions/WaterLowerAction.hpp +++ b/src/openrct2/actions/WaterLowerAction.hpp @@ -72,7 +72,7 @@ private: res->Position.z = z; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - uint8_t minHeight = GetLowestHeight(); + uint8_t minHeight = GetLowestHeight(validRange); bool hasChanged = false; for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) { @@ -119,12 +119,13 @@ private: } private: - uint8_t GetLowestHeight() const + uint8_t GetLowestHeight(MapRange validRange) const { + // The lowest height to lower the water to is the highest water level in the selection uint8_t minHeight{ 0 }; - for (int32_t y = _range.GetTop(); y <= _range.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) { - for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) { auto* surfaceElement = map_get_surface_element_at({ x, y }); if (surfaceElement == nullptr) diff --git a/src/openrct2/actions/WaterRaiseAction.hpp b/src/openrct2/actions/WaterRaiseAction.hpp index 3acc5445e7..666214a233 100644 --- a/src/openrct2/actions/WaterRaiseAction.hpp +++ b/src/openrct2/actions/WaterRaiseAction.hpp @@ -73,7 +73,7 @@ private: res->Position.z = z; res->ExpenditureType = RCT_EXPENDITURE_TYPE_LANDSCAPING; - uint8_t maxHeight = GetHighestHeight(); + uint8_t maxHeight = GetHighestHeight(validRange); bool hasChanged = false; for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) { @@ -126,12 +126,13 @@ private: } private: - uint8_t GetHighestHeight() const + uint8_t GetHighestHeight(MapRange validRange) const { + // The highest height to raise the water to is the lowest water level in the selection uint8_t maxHeight{ 255 }; - for (int32_t y = _range.GetTop(); y <= _range.GetBottom(); y += 32) + for (int32_t y = validRange.GetTop(); y <= validRange.GetBottom(); y += 32) { - for (int32_t x = _range.GetLeft(); x <= _range.GetRight(); x += 32) + for (int32_t x = validRange.GetLeft(); x <= validRange.GetRight(); x += 32) { auto* surfaceElement = map_get_surface_element_at({ x, y }); if (surfaceElement == nullptr)