From 9396da9b713eaf276f4ac610fbaf6e1ecaf5b7a7 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Tue, 29 May 2018 14:06:09 +0200 Subject: [PATCH] Fix #7571 Track design ghost generates money The problem was that when placing a ride ghost, some clearance checks are performed to see if nothing stands in the way, and if it does, it tries to raise the ride to a height where it's possible to place. When this happens, it removes all ghost track pieces that have already been placed, and tries at the next height. With clearance checks disabled, this check was still performed, while it should ignore clearance altogether. --- distribution/changelog.txt | 1 + src/openrct2/world/Map.cpp | 13 ++++++++++--- src/openrct2/world/Map.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 4b84bdc31f..b3b98b4837 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -33,6 +33,7 @@ - Fix: [#7480] Graphs skip values of 0. - Fix: [#7528] In park entrance pricing tab, switching tabs happens on mouse-down instead of mouse-up - Fix: [#7544] Starting a headless server with no arguments causes the game to freeze. +- Fix: [#7571] Hovering a ride design over scenery will give tons of money. - Improved: [#2989] Multiplayer window now changes title when tab changes. - Improved: [#5339] Change eyedropper icon to actual eyedropper and change cursor to crosshair. - Improved: [#5832] Resize tile inspector automatically when selecting a tile element. diff --git a/src/openrct2/world/Map.cpp b/src/openrct2/world/Map.cpp index 9c4b1340d4..f6035f88ce 100644 --- a/src/openrct2/world/Map.cpp +++ b/src/openrct2/world/Map.cpp @@ -3328,7 +3328,7 @@ void map_obstruction_set_error_text(rct_tile_element *tileElement) * ebp = clearFunc * bl = bl */ -sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, CLEAR_FUNC clearFunc, uint8 bl, uint8 flags, money32 *price, uint8 crossingMode) +bool map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, CLEAR_FUNC clearFunc, uint8 bl, uint8 flags, money32 *price, uint8 crossingMode) { sint32 al, ah, bh, cl, ch, water_height; al = ah = bh = cl = ch = water_height = 0; @@ -3336,10 +3336,17 @@ sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 z gMapGroundFlags = ELEMENT_IS_ABOVE_GROUND; bool canBuildCrossing = false; - if (x >= gMapSizeUnits || y >= gMapSizeUnits || x < 32 || y < 32) { + if (x >= gMapSizeUnits || y >= gMapSizeUnits || x < 32 || y < 32) + { gGameCommandErrorText = STR_OFF_EDGE_OF_MAP; return false; } + + if (gCheatsDisableClearanceChecks) + { + return true; + } + rct_tile_element* tileElement = map_get_first_element_at(x / 32, y / 32); do { if (tileElement->GetType() != TILE_ELEMENT_TYPE_SURFACE) { @@ -3351,7 +3358,7 @@ sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 z continue; } water_height = surface_get_water_height(tileElement) * 2; - if (water_height && water_height > zLow && tileElement->base_height < zHigh && !gCheatsDisableClearanceChecks) { + if (water_height && water_height > zLow && tileElement->base_height < zHigh) { gMapGroundFlags |= ELEMENT_IS_UNDERWATER; if (water_height < zHigh) { goto loc_68BAE6; diff --git a/src/openrct2/world/Map.h b/src/openrct2/world/Map.h index ad4617d2d3..085f44a2de 100644 --- a/src/openrct2/world/Map.h +++ b/src/openrct2/world/Map.h @@ -173,7 +173,7 @@ using CLEAR_FUNC = sint32(*)(rct_tile_element** tile_element, sint32 x, sint32 y sint32 map_place_non_scenery_clear_func(rct_tile_element** tile_element, sint32 x, sint32 y, uint8 flags, money32* price); sint32 map_place_scenery_clear_func(rct_tile_element** tile_element, sint32 x, sint32 y, uint8 flags, money32* price); -sint32 map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, CLEAR_FUNC clearFunc, uint8 bl, uint8 flags, money32 *price, uint8 crossingMode); +bool map_can_construct_with_clear_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, CLEAR_FUNC clearFunc, uint8 bl, uint8 flags, money32 *price, uint8 crossingMode); sint32 map_can_construct_at(sint32 x, sint32 y, sint32 zLow, sint32 zHigh, uint8 bl); void rotate_map_coordinates(sint16 *x, sint16 *y, sint32 rotation); LocationXY16 coordinate_3d_to_2d(const LocationXYZ16* coordinate_3d, sint32 rotation);