diff --git a/src/ride/ride.c b/src/ride/ride.c index 4fc987a6af..321663338e 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -169,6 +169,8 @@ uint8 _currentSeatRotationAngle; uint8 gRideEntranceExitPlaceType; uint8 gRideEntranceExitPlaceRideIndex; uint8 gRideEntranceExitPlaceStationIndex; +uint8 gRideEntranceExitPlacePreviousRideConstructionState; +uint8 gRideEntranceExitPlaceDirection; // Static function declarations rct_peep *find_closest_mechanic(int x, int y, int forInspection); @@ -1692,7 +1694,7 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int gRideEntranceExitPlaceStationIndex = bl; gInputFlags |= INPUT_FLAG_6; if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { - RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; + gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState; _rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT; } @@ -7059,7 +7061,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc rct_viewport *viewport; rct_ride *ride; - RCT2_GLOBAL(0x00F44194, uint8) = 255; + gRideEntranceExitPlaceDirection = 255; get_map_coordinates_from_pos(screenX, screenY, 0xFFFB, &mapX, &mapY, &interactionType, &mapElement, &viewport); if (interactionType != 0) { if (map_element_get_type(mapElement) == MAP_ELEMENT_TYPE_TRACK) { @@ -7121,8 +7123,8 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc continue; if (mapElement->properties.track.ride_index != gRideEntranceExitPlaceRideIndex) continue; - if (mapElement->properties.track.type == 101) { - RCT2_GLOBAL(0x00F44194, uint8) = direction ^ 2; + if (mapElement->properties.track.type == TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP) { + gRideEntranceExitPlaceDirection = direction ^ 2; *outDirection = direction ^ 2; return; } @@ -7132,7 +7134,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc int ebx = (mapElement->properties.track.type << 4) + (mapElement->properties.track.sequence & 0x0F); int eax = (direction + 2 - mapElement->type) & MAP_ELEMENT_DIRECTION_MASK; if (RCT2_ADDRESS(0x0099CA64, uint8)[ebx] & (1 << eax)) { - RCT2_GLOBAL(0x00F44194, uint8) = direction ^ 2; + gRideEntranceExitPlaceDirection = direction ^ 2; *outDirection = direction ^ 2; return; } @@ -7140,7 +7142,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc } direction = (direction + 1) & 3; } - RCT2_GLOBAL(0x00F44194, uint8) = 0xFF; + gRideEntranceExitPlaceDirection = 0xFF; } else { mapX = (stationStartXY & 0xFF) * 32; mapY = (stationStartXY >> 8) * 32; @@ -7187,7 +7189,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc direction = loc_6CD18E(*outX, *outY, entranceMinX - 32, entranceMinY - 32, entranceMaxX + 32, entranceMaxY + 32); if (direction != -1 && direction != stationDirection && direction != (stationDirection ^ 2)) { - RCT2_GLOBAL(0x00F44194, uint8) = direction; + gRideEntranceExitPlaceDirection = direction; *outDirection = direction; return; } diff --git a/src/ride/ride.h b/src/ride/ride.h index 34c8dd2867..8d8cb5266b 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -927,6 +927,8 @@ extern uint8 _currentSeatRotationAngle; extern uint8 gRideEntranceExitPlaceType; extern uint8 gRideEntranceExitPlaceRideIndex; extern uint8 gRideEntranceExitPlaceStationIndex; +extern uint8 gRideEntranceExitPlacePreviousRideConstructionState; +extern uint8 gRideEntranceExitPlaceDirection; extern bool gGotoStartPlacementMode; extern int gRideRemoveTrackPieceCallbackX; diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index a14486dd49..030b948a4d 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -302,7 +302,7 @@ static void window_maze_construction_update(rct_window *w) break; case RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT: if (!widget_is_active_tool(w, WIDX_MAZE_ENTRANCE) && !widget_is_active_tool(w, WIDX_MAZE_EXIT)) { - _rideConstructionState = RCT2_GLOBAL(0x00F440CC, uint8); + _rideConstructionState = gRideEntranceExitPlacePreviousRideConstructionState; window_maze_construction_update_pressed_widgets(); } break; @@ -355,7 +355,7 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* int direction = 0; ride_get_entrance_or_exit_position_from_screen_position(x, y, &x, &y, &direction); - if (RCT2_GLOBAL(0x00F44194, uint8) == 0xFF) + if (gRideEntranceExitPlaceDirection == 0xFF) return; uint8 rideIndex = gRideEntranceExitPlaceRideIndex; diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index e4aa8dafc1..50e02a9a90 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1904,7 +1904,7 @@ static void window_ride_construction_entrance_click(rct_window *w) gInputFlags |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { - RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; + gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState; _rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT; } sub_6C84CE(); @@ -1928,7 +1928,7 @@ static void window_ride_construction_exit_click(rct_window *w) gInputFlags |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { - RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; + gRideEntranceExitPlacePreviousRideConstructionState = _rideConstructionState; _rideConstructionState = RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT; } sub_6C84CE(); @@ -1968,7 +1968,7 @@ static void window_ride_construction_update(rct_window *w) if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { if (!widget_is_active_tool(w, WIDX_ENTRANCE) && !widget_is_active_tool(w, WIDX_EXIT)) { - _rideConstructionState = RCT2_GLOBAL(0x00F440CC, uint8); + _rideConstructionState = gRideEntranceExitPlacePreviousRideConstructionState; sub_6C84CE(); } } @@ -3690,7 +3690,7 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY) gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_CONSTRUCT; gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW; ride_get_entrance_or_exit_position_from_screen_position(screenX, screenY, &x, &y, &direction); - if (RCT2_GLOBAL(0x00F44194, uint8) == 255) { + if (gRideEntranceExitPlaceDirection == 255) { sub_6C9627(); return; } @@ -3707,7 +3707,7 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY) gMapSelectArrowPosition.z = RCT2_GLOBAL(0x00F44190, uint8) * 8; map_invalidate_selection_rect(); - direction = RCT2_GLOBAL(0x00F44194, uint8) ^ 2; + direction = gRideEntranceExitPlaceDirection ^ 2; unk = gRideEntranceExitPlaceStationIndex; if ( !(_currentTrackSelectionFlags & 4) || @@ -3938,7 +3938,7 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) int mapX, mapY, direction; ride_get_entrance_or_exit_position_from_screen_position(screenX, screenY, &mapX, &mapY, &direction); - if (RCT2_GLOBAL(0x00F44194, uint8) == 255) + if (gRideEntranceExitPlaceDirection == 255) return; gGameCommandErrorTitle = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? @@ -3948,7 +3948,7 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) game_command_callback = game_command_callback_place_ride_entrance_or_exit; game_do_command( RCT2_GLOBAL(0x00F44188, uint16), - (GAME_COMMAND_FLAG_APPLY) | ((RCT2_GLOBAL(0x00F44194, uint8) ^ 2) << 8), + (GAME_COMMAND_FLAG_APPLY) | ((gRideEntranceExitPlaceDirection ^ 2) << 8), RCT2_GLOBAL(0x00F4418A, uint16), gRideEntranceExitPlaceRideIndex | (gRideEntranceExitPlaceType << 8), GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT,