From d1a6b650497515d1841c172d64bc27d627fc58a5 Mon Sep 17 00:00:00 2001 From: Alexander Overvoorde Date: Tue, 27 Oct 2015 23:11:30 +0100 Subject: [PATCH] Fix supports error appearing when building outside of owned land This was caused by ride_construction_toolupdate_construct() pointlessly trying to fix the "building outside owned land" error by increasing the Z. --- src/ride/track.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/ride/track.c b/src/ride/track.c index 6ec6b8920a..2523a7f34d 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -3985,6 +3985,43 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in money32 cost = 0; const rct_preview_track *trackBlock = get_track_def_from_ride(ride, type); + + // First check if any of the track pieces are outside the park + for (; trackBlock->index != 0xFF; trackBlock++) { + int x, y, z, offsetX, offsetY; + + switch (direction) { + case 0: + offsetX = trackBlock->x; + offsetY = trackBlock->y; + break; + case 1: + offsetX = trackBlock->y; + offsetY = -trackBlock->x; + break; + case 2: + offsetX = -trackBlock->x; + offsetY = -trackBlock->y; + break; + case 3: + offsetX = -trackBlock->y; + offsetY = trackBlock->x; + break; + } + + x = originX + offsetX; + y = originY + offsetY; + z = originZ + trackBlock->z; + + if (!map_is_location_owned(x, y, z) && !gCheatsSandboxMode) { + RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_LAND_NOT_OWNED_BY_PARK; + return MONEY32_UNDEFINED; + } + } + + // If that is not the case, then perform the remaining checks + trackBlock = get_track_def_from_ride(ride, type); + for (; trackBlock->index != 0xFF; trackBlock++, RCT2_GLOBAL(0x00F44054, uint8*)++) { int x, y, z, offsetX, offsetY; int bl = trackBlock->var_08; @@ -4093,10 +4130,6 @@ static money32 track_place(int rideIndex, int type, int originX, int originY, in } } - if (!map_is_location_owned(x, y, z) && !gCheatsSandboxMode) { - return MONEY32_UNDEFINED; - } - bh = RCT2_GLOBAL(RCT2_ADDRESS_ELEMENT_LOCATION_COMPARED_TO_GROUND_AND_WATER, uint8) & 3; if (RCT2_GLOBAL(RCT2_ADDRESS_ABOVE_GROUND_FLAGS, uint8) != 0 && (RCT2_GLOBAL(RCT2_ADDRESS_ABOVE_GROUND_FLAGS, uint8) & bh) == 0) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CANT_BUILD_PARTLY_ABOVE_AND_PARTLY_BELOW_GROUND;