From e04165eef4e0218922d8dd51bbb9ea6ad1f6a4ba Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 23 Apr 2015 20:40:53 +0100 Subject: [PATCH] Refactoring and bug fixing. Noticed a bug that was causing path bits to fail to be changed. Reduced compile warnings by using ints for coordinates. Rearanged colour picker to stop bug that prevents its use when first clicked. --- src/windows/dropdown.c | 21 +++++++++++---------- src/windows/top_toolbar.c | 15 ++++++++++++--- src/world/footpath.c | 2 +- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/windows/dropdown.c b/src/windows/dropdown.c index 2a02739add..0804d787d1 100644 --- a/src/windows/dropdown.c +++ b/src/windows/dropdown.c @@ -411,6 +411,17 @@ void window_dropdown_show_colour_available(rct_window *w, rct_widget *widget, ui if (availableColours & (1 << i)) numItems++; + // Set items + for (i = 0; i < 32; i++) { + if (availableColours & (1 << i)) { + if (selectedColour == i) + RCT2_GLOBAL(0x009DEBA2, sint16) = i; + + gDropdownItemsFormat[i] = 0xFFFE; + gDropdownItemsArgs[i] = ((uint64)i << 32) | (0x20000000 | (i << 19) | 5059); + } + } + // Show dropdown window_dropdown_show_image( w->x + widget->left, @@ -424,14 +435,4 @@ void window_dropdown_show_colour_available(rct_window *w, rct_widget *widget, ui gAppropriateImageDropdownItemsPerRow[numItems] ); - // Set items - for (i = 0; i < 32; i++) { - if (availableColours & (1 << i)) { - if (selectedColour == i) - RCT2_GLOBAL(0x009DEBA2, sint16) = i; - - gDropdownItemsFormat[i] = 0xFFFE; - gDropdownItemsArgs[i] = ((uint64)i << 32) | (0x20000000 | (i << 19) | 5059); - } - } } diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index 08c37f00a7..f35a9d1f15 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -943,7 +943,10 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin int interaction_type = 0; rct_map_element* map_element; - get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &map_element, NULL); + int map_x, map_y; + get_map_coordinates_from_pos(x, y, flags, &map_x, &map_y, &interaction_type, &map_element, NULL); + *grid_x = (sint16)map_x; + *grid_y = (sint16)map_y; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { @@ -1020,7 +1023,10 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin int interaction_type = 0; rct_map_element* map_element; - get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &map_element, NULL); + int map_x, map_y; + get_map_coordinates_from_pos(x, y, flags, &map_x, &map_y, &interaction_type, &map_element, NULL); + *grid_x = (sint16)map_x; + *grid_y = (sint16)map_y; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { @@ -1166,7 +1172,10 @@ void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid_x, sin int interaction_type = 0; rct_map_element* map_element; - get_map_coordinates_from_pos(x, y, flags, grid_x, grid_y, &interaction_type, &map_element, NULL); + int map_x, map_y; + get_map_coordinates_from_pos(x, y, flags, &map_x, &map_y, &interaction_type, &map_element, NULL); + *grid_x = (sint16)map_x; + *grid_y = (sint16)map_y; if (interaction_type == VIEWPORT_INTERACTION_ITEM_NONE) { diff --git a/src/world/footpath.c b/src/world/footpath.c index 756f9e63ad..330cd02563 100644 --- a/src/world/footpath.c +++ b/src/world/footpath.c @@ -231,7 +231,7 @@ static money32 footpath_element_update(int x, int y, rct_map_element *mapElement if (flags & (1 << 4)) return MONEY32_UNDEFINED; - if (!(flags & (1 << 6))) { + if (flags & (1 << 6)) { if (mapElement->properties.path.additions & 0x0F) { RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, rct_string_id) = STR_NONE; return MONEY32_UNDEFINED;