diff --git a/src/ride/ride.c b/src/ride/ride.c index edf1a565a5..4fc987a6af 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -166,6 +166,10 @@ uint16 _previousTrackPieceZ; uint8 _currentSeatRotationAngle; +uint8 gRideEntranceExitPlaceType; +uint8 gRideEntranceExitPlaceRideIndex; +uint8 gRideEntranceExitPlaceStationIndex; + // Static function declarations rct_peep *find_closest_mechanic(int x, int y, int forInspection); static void ride_breakdown_status_update(int rideIndex); @@ -1683,9 +1687,9 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int ) { // Replace entrance / exit tool_set(constructionWindow, entranceType == 0 ? 29 : 30, 12); - RCT2_GLOBAL(0x00F44191, uint8) = entranceType; - RCT2_GLOBAL(0x00F44192, uint8) = rideIndex; - RCT2_GLOBAL(0x00F44193, uint8) = bl; + gRideEntranceExitPlaceType = entranceType; + gRideEntranceExitPlaceRideIndex = rideIndex; + gRideEntranceExitPlaceStationIndex = bl; gInputFlags |= INPUT_FLAG_6; if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { RCT2_GLOBAL(0x00F440CC, uint8) = _rideConstructionState; @@ -1698,7 +1702,7 @@ static int ride_modify_entrance_or_exit(rct_map_element *mapElement, int x, int // Remove entrance / exit game_do_command(x, (GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_APPLY), y, rideIndex, GAME_COMMAND_REMOVE_RIDE_ENTRANCE_OR_EXIT, bl, 0); gCurrentToolWidget.widget_index = entranceType == ENTRANCE_TYPE_RIDE_ENTRANCE ? 29 : 30; - RCT2_GLOBAL(0x00F44191, uint8) = entranceType; + gRideEntranceExitPlaceType = entranceType; } window_invalidate_by_class(WC_RIDE_CONSTRUCTION); @@ -7059,20 +7063,20 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc 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) { - if (mapElement->properties.track.ride_index == RCT2_GLOBAL(0x00F44192, uint8)) { + if (mapElement->properties.track.ride_index == gRideEntranceExitPlaceRideIndex) { if (RCT2_ADDRESS(0x0099BA64, uint8)[mapElement->properties.track.type << 4] & 0x10) { if (mapElement->properties.track.type == 101) { - RCT2_GLOBAL(0x00F44193, uint8) = 0; + gRideEntranceExitPlaceStationIndex = 0; } else { - RCT2_GLOBAL(0x00F44193, uint8) = (mapElement->properties.track.sequence & 0x70) >> 4; + gRideEntranceExitPlaceStationIndex = (mapElement->properties.track.sequence & 0x70) >> 4; } } } } } - ride = get_ride(RCT2_GLOBAL(0x00F44192, uint8)); - stationHeight = ride->station_heights[RCT2_GLOBAL(0x00F44193, uint8)]; + ride = get_ride(gRideEntranceExitPlaceRideIndex); + stationHeight = ride->station_heights[gRideEntranceExitPlaceStationIndex]; screen_get_map_xy_with_z(screenX, screenY, stationHeight * 8, &mapX, &mapY); if (mapX == (short)0x8000) { @@ -7090,7 +7094,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc if (ride->type == RIDE_TYPE_NULL) return; - uint16 stationStartXY = ride->station_starts[RCT2_GLOBAL(0x00F44193, uint8)]; + uint16 stationStartXY = ride->station_starts[gRideEntranceExitPlaceStationIndex]; if (stationStartXY == 0xFFFF) return; @@ -7115,14 +7119,14 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc continue; if (mapElement->base_height != stationHeight) continue; - if (mapElement->properties.track.ride_index != RCT2_GLOBAL(0x00F44192, uint8)) + if (mapElement->properties.track.ride_index != gRideEntranceExitPlaceRideIndex) continue; if (mapElement->properties.track.type == 101) { RCT2_GLOBAL(0x00F44194, uint8) = direction ^ 2; *outDirection = direction ^ 2; return; } - if (map_get_station(mapElement) != RCT2_GLOBAL(0x00F44193, uint8)) + if (map_get_station(mapElement) != gRideEntranceExitPlaceStationIndex) continue; int ebx = (mapElement->properties.track.type << 4) + (mapElement->properties.track.sequence & 0x0F); @@ -7143,7 +7147,7 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc entranceMinX = mapX; entranceMinY = mapY; - mapElement = ride_get_station_start_track_element(ride, RCT2_GLOBAL(0x00F44193, uint8)); + mapElement = ride_get_station_start_track_element(ride, gRideEntranceExitPlaceStationIndex); direction = mapElement->type & MAP_ELEMENT_DIRECTION_MASK; stationDirection = direction; @@ -7156,9 +7160,9 @@ void ride_get_entrance_or_exit_position_from_screen_position(int screenX, int sc do { if (map_element_get_type(mapElement) != MAP_ELEMENT_TYPE_TRACK) continue; - if (mapElement->properties.track.ride_index != RCT2_GLOBAL(0x00F44192, uint8)) + if (mapElement->properties.track.ride_index != gRideEntranceExitPlaceRideIndex) continue; - if (map_get_station(mapElement) != RCT2_GLOBAL(0x00F44193, uint8)) + if (map_get_station(mapElement) != gRideEntranceExitPlaceStationIndex) continue; switch (mapElement->properties.track.type) { diff --git a/src/ride/ride.h b/src/ride/ride.h index cd0b07a7fb..34c8dd2867 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -924,6 +924,10 @@ extern uint16 _previousTrackPieceZ; extern uint8 _currentSeatRotationAngle; +extern uint8 gRideEntranceExitPlaceType; +extern uint8 gRideEntranceExitPlaceRideIndex; +extern uint8 gRideEntranceExitPlaceStationIndex; + extern bool gGotoStartPlacementMode; extern int gRideRemoveTrackPieceCallbackX; extern int gRideRemoveTrackPieceCallbackY; diff --git a/src/windows/maze_construction.c b/src/windows/maze_construction.c index b01c7e1860..a14486dd49 100644 --- a/src/windows/maze_construction.c +++ b/src/windows/maze_construction.c @@ -187,9 +187,9 @@ static void window_maze_construction_entrance_mouseup(rct_window *w, int widgetI if (tool_set(w, widgetIndex, 12)) return; - RCT2_GLOBAL(0x00F44191, uint8) = widgetIndex == WIDX_MAZE_ENTRANCE ? 0 : 1; - RCT2_GLOBAL(0x00F44192, uint8) = (uint8)w->number; - RCT2_GLOBAL(0x00F44193, uint8) = 0; + gRideEntranceExitPlaceType = widgetIndex == WIDX_MAZE_ENTRANCE ? ENTRANCE_TYPE_RIDE_ENTRANCE : ENTRANCE_TYPE_RIDE_EXIT; + gRideEntranceExitPlaceRideIndex = (uint8)w->number; + gRideEntranceExitPlaceStationIndex = 0; gInputFlags |= INPUT_FLAG_6; sub_6C9627(); @@ -358,17 +358,17 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* if (RCT2_GLOBAL(0x00F44194, uint8) == 0xFF) return; - uint8 rideIndex = RCT2_GLOBAL(0x00F44192, uint8); - uint8 is_exit = RCT2_GLOBAL(0x00F44191, uint8); - gGameCommandErrorTitle = is_exit ? 1144 : 1145; + uint8 rideIndex = gRideEntranceExitPlaceRideIndex; + uint8 entranceExitType = gRideEntranceExitPlaceType; + gGameCommandErrorTitle = entranceExitType ? 1144 : 1145; money32 cost = game_do_command( x, GAME_COMMAND_FLAG_APPLY | ((direction ^ 2) << 8), y, - rideIndex | (is_exit << 8), + rideIndex | (entranceExitType << 8), GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, - RCT2_GLOBAL(0x00F44193, uint8), + gRideEntranceExitPlaceStationIndex, 0); if (cost == MONEY32_UNDEFINED) @@ -387,9 +387,9 @@ static void window_maze_construction_entrance_tooldown(int x, int y, rct_window* window_close(w); } else{ - RCT2_GLOBAL(0x00F44191, uint8) = is_exit ^ 1; + gRideEntranceExitPlaceType = entranceExitType ^ 1; window_invalidate_by_class(WC_RIDE_CONSTRUCTION); - gCurrentToolWidget.widget_index = is_exit ? WIDX_MAZE_ENTRANCE : WIDX_MAZE_EXIT; + gCurrentToolWidget.widget_index = entranceExitType ? WIDX_MAZE_ENTRANCE : WIDX_MAZE_EXIT; } } diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index b6b0263d4e..e4aa8dafc1 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1898,9 +1898,9 @@ static void window_ride_construction_entrance_click(rct_window *w) sub_6CC3FB(_currentRideIndex); } } else { - RCT2_GLOBAL(0x00F44191, uint8) = 0; - RCT2_GLOBAL(0x00F44192, uint8) = w->number & 0xFF; - RCT2_GLOBAL(0x00F44193, uint8) = 0; + gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_ENTRANCE; + gRideEntranceExitPlaceRideIndex = w->number & 0xFF; + gRideEntranceExitPlaceStationIndex = 0; gInputFlags |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { @@ -1922,9 +1922,9 @@ static void window_ride_construction_exit_click(rct_window *w) sub_6CC3FB(_currentRideIndex); } } else { - RCT2_GLOBAL(0x00F44191, uint8) = 1; - RCT2_GLOBAL(0x00F44192, uint8) = w->number & 0xFF; - RCT2_GLOBAL(0x00F44193, uint8) = 0; + gRideEntranceExitPlaceType = ENTRANCE_TYPE_RIDE_EXIT; + gRideEntranceExitPlaceRideIndex = w->number & 0xFF; + gRideEntranceExitPlaceStationIndex = 0; gInputFlags |= INPUT_FLAG_6; sub_6C9627(); if (_rideConstructionState != RIDE_CONSTRUCTION_STATE_ENTRANCE_EXIT) { @@ -3708,7 +3708,7 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY) map_invalidate_selection_rect(); direction = RCT2_GLOBAL(0x00F44194, uint8) ^ 2; - unk = RCT2_GLOBAL(0x00F44193, uint8); + unk = gRideEntranceExitPlaceStationIndex; if ( !(_currentTrackSelectionFlags & 4) || x != RCT2_GLOBAL(0x00F440BF, uint16) || @@ -3717,7 +3717,7 @@ void ride_construction_toolupdate_entrance_exit(int screenX, int screenY) unk != RCT2_GLOBAL(0x00F440C4, uint8) ) { _currentTrackPrice = ride_get_entrance_or_exit_price( - _currentRideIndex, x, y, direction, RCT2_GLOBAL(0x00F44191, uint8), unk + _currentRideIndex, x, y, direction, gRideEntranceExitPlaceType, unk ); sub_6C84CE(); } @@ -3941,7 +3941,7 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) if (RCT2_GLOBAL(0x00F44194, uint8) == 255) return; - gGameCommandErrorTitle = (RCT2_GLOBAL(0x00F44191, uint8) == 0) ? + gGameCommandErrorTitle = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? STR_CANT_BUILD_MOVE_ENTRANCE_FOR_THIS_RIDE_ATTRACTION : STR_CANT_BUILD_MOVE_EXIT_FOR_THIS_RIDE_ATTRACTION; @@ -3950,9 +3950,9 @@ static void ride_construction_tooldown_entrance_exit(int screenX, int screenY) RCT2_GLOBAL(0x00F44188, uint16), (GAME_COMMAND_FLAG_APPLY) | ((RCT2_GLOBAL(0x00F44194, uint8) ^ 2) << 8), RCT2_GLOBAL(0x00F4418A, uint16), - RCT2_GLOBAL(0x00F44192, uint8) | (RCT2_GLOBAL(0x00F44191, uint8) << 8), + gRideEntranceExitPlaceRideIndex | (gRideEntranceExitPlaceType << 8), GAME_COMMAND_PLACE_RIDE_ENTRANCE_OR_EXIT, - RCT2_GLOBAL(0x00F44193, uint8), + gRideEntranceExitPlaceStationIndex, 0 ); } @@ -3966,16 +3966,16 @@ void game_command_callback_place_ride_entrance_or_exit(int eax, int ebx, int ecx gCommandPosition.z ); - rct_ride *ride = get_ride(RCT2_GLOBAL(0x00F44192, uint8)); + rct_ride *ride = get_ride(gRideEntranceExitPlaceRideIndex); if (ride_are_all_possible_entrances_and_exits_built(ride)) { tool_cancel(); if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_NO_TRACK)) { window_close_by_class(WC_RIDE_CONSTRUCTION); } } else { - RCT2_GLOBAL(0x00F44191, uint8) ^= 1; + gRideEntranceExitPlaceType ^= 1; window_invalidate_by_class(77); - gCurrentToolWidget.widget_index = (RCT2_GLOBAL(0x00F44191, uint8) == 0) ? + gCurrentToolWidget.widget_index = (gRideEntranceExitPlaceType == ENTRANCE_TYPE_RIDE_ENTRANCE) ? WIDX_ENTRANCE : WIDX_EXIT; } }