From c1ed727067d67f7459f8823af13c314093cb9f07 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 16 Nov 2015 20:19:58 +0000 Subject: [PATCH] Fix #2305. Fences now build correctly with shift. Issue was caused by failing to reinitialise a variable and reusing a variable name for two different purposes. It has been fixed by nameing the variable and also initialising it. --- src/world/map.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/world/map.c b/src/world/map.c index 1c14179b58..1a317288f1 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -2952,9 +2952,10 @@ void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, if (!(bp & 0xC0)){ uint8 new_edge = (edge + 2) & 3; - bp += 2; + uint8 new_base_height = map_element->base_height; + new_base_height += 2; if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < bp){ + if (position.z / 8 < new_base_height){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; *ebx = MONEY32_UNDEFINED; return; @@ -2966,13 +2967,13 @@ void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, if (map_element->properties.surface.slope & (1 << new_edge)){ new_edge = (new_edge + 2) & 3; if (map_element->properties.surface.slope & (1 << new_edge)){ - bp += 2; - if (position.z / 8 < bp){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; *ebx = MONEY32_UNDEFINED; return; } - bp -= 2; + new_base_height -= 2; } } } @@ -2980,7 +2981,7 @@ void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, new_edge = (edge + 3) & 3; if (map_element->properties.surface.slope & (1 << new_edge)){ - if (position.z / 8 < bp){ + if (position.z / 8 < new_base_height){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; *ebx = MONEY32_UNDEFINED; return; @@ -2992,8 +2993,8 @@ void game_command_place_fence(int* eax, int* ebx, int* ecx, int* edx, int* esi, if (map_element->properties.surface.slope & (1 << new_edge)){ new_edge = (new_edge + 2) & 3; if (map_element->properties.surface.slope & (1 << new_edge)){ - bp += 2; - if (position.z / 8 < bp){ + new_base_height += 2; + if (position.z / 8 < new_base_height){ RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND; *ebx = MONEY32_UNDEFINED; return;