From a768d3dc9645310a95a6490cdd8815e7e57d6796 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 7 May 2015 19:16:00 +0100 Subject: [PATCH] Fix large scenery removal bug. Issue was caused by comparing the height value to the wrong number. I've rejigged the function to make it easier to follow and added in an error message if an element fails to be found. --- src/world/map.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/world/map.c b/src/world/map.c index 38ddd2f4b5..5ceacf057e 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -758,14 +758,30 @@ void game_command_remove_large_scenery(int* eax, int* ebx, int* ecx, int* edx, i if(*ebx & GAME_COMMAND_FLAG_APPLY){ rct_map_element* map_element = map_get_first_element_at(x3 / 32, y3 / 32); - while(map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE || - (map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction || - map_element->properties.scenerymultiple.type >> 10 != i || - map_element->base_height != base_height){ - map_element++; + uint8 tile_not_found = 1; + do + { + if (map_element_get_type(map_element) != MAP_ELEMENT_TYPE_SCENERY_MULTIPLE) + continue; + + if ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) != map_element_direction) + continue; + + if ((map_element->properties.scenerymultiple.type >> 10) != i) + continue; + + if (map_element->base_height != z3 / 8) + continue; + + map_invalidate_tile_full(x3, y3); + map_element_remove(map_element); + tile_not_found = 0; + break; + } while (!map_element_is_last_for_tile(map_element++)); + + if (tile_not_found){ + log_error("Tile not found when trying to remove element!"); } - map_invalidate_tile_full(x3, y3); - map_element_remove(map_element); } i++;