From db18fa8f145b5dedc777f15706403428e43832bf Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Mon, 21 Dec 2015 22:28:34 +0000 Subject: [PATCH] finally fix #1619: Can't place any path RCT2_ADDRESS_TOOL_WIDGETINDEX was being read as an int32 sometimes --- src/input.c | 10 +++++----- src/interface/viewport.c | 2 +- src/interface/widget.c | 2 +- src/interface/window.c | 2 +- src/ride/ride.c | 4 ++-- src/windows/map.c | 6 +++--- src/windows/map_tooltip.c | 2 +- src/windows/maze_construction.c | 4 ++-- src/windows/ride.c | 4 ++-- src/windows/ride_construction.c | 4 ++-- src/windows/scenery.c | 2 +- src/windows/top_toolbar.c | 8 ++++---- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/input.c b/src/input.c index ad246853f4..666fcbb6aa 100644 --- a/src/input.c +++ b/src/input.c @@ -368,7 +368,7 @@ static void game_handle_input_mouse(int x, int y, int state) if (w == NULL) break; - window_event_tool_drag_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint32), x, y); + window_event_tool_drag_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), x, y); } else if (state == 2){ @@ -1016,7 +1016,7 @@ static void input_widget_left(int x, int y, rct_window *w, int widgetIndex) RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) ); if (w != NULL) { - window_event_tool_down_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint32), x, y); + window_event_tool_down_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), x, y); RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= INPUT_FLAG_4; } } @@ -1157,14 +1157,14 @@ void process_mouse_tool(int x, int y) if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) { rct_window* w = window_find_by_number( - RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8), - RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, uint16) + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) ); if (!w) tool_cancel(); else - window_event_tool_update_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint32), x, y); + window_event_tool_update_call(w, RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16), x, y); } } diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 0c77c432c6..91e9e21707 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -101,7 +101,7 @@ void viewport_init_all() RCT2_GLOBAL(RCT2_ADDRESS_ACTIVE_VIEWPORT_PTR_ARRAY, rct_viewport*) = NULL; // ? - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, sint32) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) = 0; RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, sint8) = INPUT_STATE_RESET; RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass) = -1; RCT2_GLOBAL(RCT2_ADDRESS_PICKEDUP_PEEP_SPRITE, sint32) = -1; diff --git a/src/interface/widget.c b/src/interface/widget.c index b205882802..988b7a7211 100644 --- a/src/interface/widget.c +++ b/src/interface/widget.c @@ -1014,7 +1014,7 @@ int widget_is_active_tool(rct_window *w, int widgetIndex) return 0; if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) != w->number) return 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, sint32) != widgetIndex) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != widgetIndex) return 0; return 1; diff --git a/src/interface/window.c b/src/interface/window.c index 36dec65ef2..33071eae03 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1778,7 +1778,7 @@ void tool_cancel() // Reset map selection RCT2_GLOBAL(RCT2_ADDRESS_MAP_SELECTION_FLAGS, uint16) = 0; - if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, sint16) >= 0) { + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) >= 0) { // Invalidate tool widget widget_invalidate_by_number( RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), diff --git a/src/ride/ride.c b/src/ride/ride.c index d7113dc736..302b4c8094 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -1603,7 +1603,7 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int sub_6C9627(); if ( _rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT || - !(RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) & INPUT_FLAG_TOOL_ACTIVE) || + !(RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) || RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_RIDE_CONSTRUCTION ) { // Replace entrance / exit @@ -1611,7 +1611,7 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int RCT2_GLOBAL(0x00F44191, uint8) = entranceType; RCT2_GLOBAL(0x00F44192, uint8) = rideIndex; RCT2_GLOBAL(0x00F44193, uint8) = bl; - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) |= INPUT_FLAG_6; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= INPUT_FLAG_6; if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; _rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT; diff --git a/src/windows/map.c b/src/windows/map.c index 43d7a5a2f1..6483e78668 100644 --- a/src/windows/map.c +++ b/src/windows/map.c @@ -741,8 +741,8 @@ static void window_map_invalidate(rct_window *w) // scenario editor: build park entrance selected, show rotate button if ( (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && - RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == WC_MAP && - RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint8) == WIDX_BUILD_PARK_ENTRANCE + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == WC_MAP && + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == WIDX_BUILD_PARK_ENTRANCE ) { w->widgets[WIDX_ROTATE_90].type = WWT_FLATBTN; } @@ -756,7 +756,7 @@ static void window_map_invalidate(rct_window *w) RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == WC_MAP ) { // if not in set land rights mode: show the default scenario editor buttons - if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint8) != WIDX_SET_LAND_RIGHTS) { + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != WIDX_SET_LAND_RIGHTS) { window_map_show_default_scenario_editor_buttons(w); } else { // if in set land rights mode: show land tool buttons + modes w->widgets[WIDX_LAND_TOOL].type = WWT_IMGBTN; diff --git a/src/windows/map_tooltip.c b/src/windows/map_tooltip.c index a9a5041a47..180a3f9709 100644 --- a/src/windows/map_tooltip.c +++ b/src/windows/map_tooltip.c @@ -81,7 +81,7 @@ void window_map_tooltip_update_visibility() cursorX = RCT2_GLOBAL(0x0142406C, sint32); cursorY = RCT2_GLOBAL(0x01424070, sint32); - inputFlags = RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8); + inputFlags = RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32); // Check for cursor movement _cursorHoldDuration++; diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index 30029e9b83..7ca6166205 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -311,7 +311,7 @@ static void window_maze_construction_update(rct_window *w) case RIDE_CONSTRUCTION_STATE_BACK: case RIDE_CONSTRUCTION_STATE_SELECTED: if ( - (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) & INPUT_FLAG_TOOL_ACTIVE) && + (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == WC_RIDE_CONSTRUCTION ) { tool_cancel(); @@ -386,7 +386,7 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* else{ RCT2_GLOBAL(0x00F44191, uint8) = is_exit ^ 1; window_invalidate_by_class(WC_RIDE_CONSTRUCTION); - RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint8) = is_exit ? WIDX_MAZE_ENTRANCE : WIDX_MAZE_EXIT; + RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) = is_exit ? WIDX_MAZE_ENTRANCE : WIDX_MAZE_EXIT; } } diff --git a/src/windows/ride.c b/src/windows/ride.c index 49cdf122b0..259765df3f 100644 --- a/src/windows/ride.c +++ b/src/windows/ride.c @@ -1266,7 +1266,7 @@ rct_window *window_ride_open_station(int rideIndex, int stationIndex) } if ( - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) & INPUT_FLAG_TOOL_ACTIVE && + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == w->classification && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) == w->number ) { @@ -1345,7 +1345,7 @@ rct_window *window_ride_open_vehicle(rct_vehicle *vehicle) window_invalidate(w); if ( - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) & INPUT_FLAG_TOOL_ACTIVE && + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == w->classification && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber) == w->number ) { diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index cba9f243e3..19ce6f9bd1 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1862,7 +1862,7 @@ static void window_ride_construction_entrance_click(rct_window *w) RCT2_GLOBAL(0x00F44191, uint8) = 0; RCT2_GLOBAL(0x00F44192, uint8) = w->number & 0xFF; RCT2_GLOBAL(0x00F44193, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) |= INPUT_FLAG_6; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; @@ -1886,7 +1886,7 @@ static void window_ride_construction_exit_click(rct_window *w) RCT2_GLOBAL(0x00F44191, uint8) = 1; RCT2_GLOBAL(0x00F44192, uint8) = w->number & 0xFF; RCT2_GLOBAL(0x00F44193, uint8) = 0; - RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8) |= INPUT_FLAG_6; + RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; diff --git a/src/windows/scenery.c b/src/windows/scenery.c index 241649d511..6fcf842440 100644 --- a/src/windows/scenery.c +++ b/src/windows/scenery.c @@ -488,7 +488,7 @@ void window_scenery_open() */ bool window_scenery_is_scenery_tool_active() { int toolWindowClassification = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass); - int toolWidgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, rct_windownumber); + int toolWidgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16); if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) if (toolWindowClassification == WC_TOP_TOOLBAR && toolWidgetIndex == 9) // 9 is WIDX_SCENERY diff --git a/src/windows/top_toolbar.c b/src/windows/top_toolbar.c index d182b5ef43..390f4501d4 100644 --- a/src/windows/top_toolbar.c +++ b/src/windows/top_toolbar.c @@ -3117,7 +3117,7 @@ void toggle_footpath_window() */ void toggle_land_window(rct_window *topToolbar, int widgetIndex) { - if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 7) { + if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 7) { tool_cancel(); } else { show_gridlines(); @@ -3134,7 +3134,7 @@ void toggle_land_window(rct_window *topToolbar, int widgetIndex) */ void toggle_clear_scenery_window(rct_window *topToolbar, int widgetIndex) { - if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 16) { + if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 16) { tool_cancel(); } else { show_gridlines(); @@ -3151,7 +3151,7 @@ void toggle_clear_scenery_window(rct_window *topToolbar, int widgetIndex) */ void toggle_water_window(rct_window *topToolbar, int widgetIndex) { - if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 8) { + if ((RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE) && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) == 1 && RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) == 8) { tool_cancel(); } else { show_gridlines(); @@ -3172,7 +3172,7 @@ bool land_tool_is_active() return false; if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass) != WC_TOP_TOOLBAR) return false; - if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, sint16) != WIDX_LAND) + if (RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WIDGETINDEX, uint16) != WIDX_LAND) return false; return true; }