Pass Ride* instead of ride_id_t

This commit is contained in:
Ted John committed 2019-02-13 20:16:42 +00:00
1 parent fdf9f36fab
commit ba445cb6ef
10 files changed
+185 -182

No files matched your search

+10 -6
View File
@@ -2871,20 +2871,20 @@ static void window_ride_vehicle_mousedown(rct_window* w, rct_widgetindex widgetI
break;
case WIDX_VEHICLE_TRAINS_INCREASE:
if (ride->num_vehicles < 32)
ride_set_num_vehicles(w->number, ride->num_vehicles + 1);
ride_set_num_vehicles(ride, ride->num_vehicles + 1);
break;
case WIDX_VEHICLE_TRAINS_DECREASE:
if (ride->num_vehicles > 1)
ride_set_num_vehicles(w->number, ride->num_vehicles - 1);
ride_set_num_vehicles(ride, ride->num_vehicles - 1);
break;
case WIDX_VEHICLE_CARS_PER_TRAIN_INCREASE:
if (ride->num_cars_per_train < 255)
ride_set_num_cars_per_vehicle(w->number, ride->num_cars_per_train + 1);
ride_set_num_cars_per_vehicle(ride, ride->num_cars_per_train + 1);
break;
case WIDX_VEHICLE_CARS_PER_TRAIN_DECREASE:
rct_ride_entry* rideEntry = get_ride_entry_by_ride(ride);
if (ride->num_cars_per_train > rideEntry->zero_cars + 1)
ride_set_num_cars_per_vehicle(w->number, ride->num_cars_per_train - 1);
ride_set_num_cars_per_vehicle(ride, ride->num_cars_per_train - 1);
break;
}
}
@@ -2903,8 +2903,12 @@ static void window_ride_vehicle_dropdown(rct_window* w, rct_widgetindex widgetIn
case WIDX_VEHICLE_TYPE_DROPDOWN:
if (dropdownIndex >= 0 && static_cast<std::size_t>(dropdownIndex) < VehicleDropdownData.size())
{
int32_t newRideType = VehicleDropdownData[dropdownIndex].subtype_id;
ride_set_ride_entry(w->number, newRideType);
auto ride = get_ride(w->number);
if (ride != nullptr)
{
auto newRideType = VehicleDropdownData[dropdownIndex].subtype_id;
ride_set_ride_entry(ride, newRideType);
}
}
break;
}
+9 -5
View File
@@ -620,7 +620,7 @@ static void window_ride_construction_close(rct_window* w)
}
}
ride_set_to_default_inspection_interval(ride->id);
ride_set_to_default_inspection_interval(ride);
auto intent = Intent(WC_RIDE);
intent.putExtra(INTENT_EXTRA_RIDE_ID, ride->id);
context_open_intent(&intent);
@@ -1710,6 +1710,7 @@ static void window_ride_construction_construct(rct_window* w)
// ***************
// NOTE: the rest of this function (minus the network condition) is copied to
// game_command_callback_ride_construct_placed_front/back Please update both ends if there are any changes here
auto ride = get_ride(rideIndex);
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_BACK)
{
trackDirection = direction_reverse(_currentTrackPieceDirection);
@@ -1722,7 +1723,7 @@ static void window_ride_construction_construct(rct_window* w)
y += CoordsDirectionDelta[trackDirection].y;
}
if (track_block_get_previous_from_zero(x, y, z, _currentRideIndex, trackDirection, &trackBeginEnd))
if (track_block_get_previous_from_zero(x, y, z, ride, trackDirection, &trackBeginEnd))
{
_currentTrackBeginX = trackBeginEnd.begin_x;
_currentTrackBeginY = trackBeginEnd.begin_y;
@@ -1752,7 +1753,7 @@ static void window_ride_construction_construct(rct_window* w)
}
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, _currentRideIndex, trackDirection, &next_track, &z, &trackDirection, false))
if (track_block_get_next_from_zero(x, y, z, ride, trackDirection, &next_track, &z, &trackDirection, false))
{
_currentTrackBeginX = next_track.x;
_currentTrackBeginY = next_track.y;
@@ -3691,8 +3692,11 @@ void ride_construction_toolupdate_entrance_exit(int32_t screenX, int32_t screenY
|| y != gRideEntranceExitGhostPosition.y || direction != gRideEntranceExitGhostPosition.direction
|| stationNum != gRideEntranceExitGhostStationIndex)
{
_currentTrackPrice = ride_entrance_exit_place_ghost(
_currentRideIndex, x, y, direction, gRideEntranceExitPlaceType, stationNum);
auto ride = get_ride(_currentRideIndex);
if (ride != nullptr)
{
_currentTrackPrice = ride_entrance_exit_place_ghost(ride, x, y, direction, gRideEntranceExitPlaceType, stationNum);
}
window_ride_construction_update_active_elements();
}
}
+1 -1
View File
@@ -348,7 +348,7 @@ public:
{
Ride* ride = get_ride(_rideIndex);
tile_element_remove(tileElement);
sub_6CB945(_rideIndex);
sub_6CB945(ride);
ride->maze_tiles--;
}
+3 -3
View File
@@ -123,10 +123,10 @@ private:
ride_clear_for_construction(ride);
ride_remove_peeps(ride);
ride_stop_peeps_queuing(_rideIndex);
ride_stop_peeps_queuing(ride);
sub_6CB945(_rideIndex);
ride_clear_leftover_entrances(_rideIndex);
sub_6CB945(ride);
ride_clear_leftover_entrances(ride);
news_item_disable_news(NEWS_ITEM_RIDE, _rideIndex);
for (auto& banner : gBanners)
+132 -138
View File
@@ -537,11 +537,9 @@ bool ride_try_get_origin_element(const Ride* ride, CoordsXYE* output)
* on the first element of a track block
*/
bool track_block_get_next_from_zero(
int16_t x, int16_t y, int16_t z_start, ride_id_t rideIndex, uint8_t direction_start, CoordsXYE* output, int32_t* z,
int16_t x, int16_t y, int16_t z_start, Ride* ride, uint8_t direction_start, CoordsXYE* output, int32_t* z,
int32_t* direction, bool isGhost)
{
Ride* ride = get_ride(rideIndex);
if (!(direction_start & (1 << 2)))
{
x += CoordsDirectionDelta[direction_start].x;
@@ -561,7 +559,7 @@ bool track_block_get_next_from_zero(
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
if (tileElement->AsTrack()->GetRideIndex() != ride->id)
continue;
if (tileElement->AsTrack()->GetSequenceIndex() != 0)
@@ -658,7 +656,7 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
uint8_t directionStart = ((trackCoordinate->rotation_end + rotation) & TILE_ELEMENT_DIRECTION_MASK)
| (trackCoordinate->rotation_end & (1 << 2));
return track_block_get_next_from_zero(x, y, OriginZ, rideIndex, directionStart, output, z, direction, false);
return track_block_get_next_from_zero(x, y, OriginZ, ride, directionStart, output, z, direction, false);
}
/**
@@ -670,10 +668,8 @@ bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32
* rct2: 0x006C63D6
*/
bool track_block_get_previous_from_zero(
int16_t x, int16_t y, int16_t z, ride_id_t rideIndex, uint8_t direction, track_begin_end* outTrackBeginEnd)
int16_t x, int16_t y, int16_t z, Ride* ride, uint8_t direction, track_begin_end* outTrackBeginEnd)
{
Ride* ride = get_ride(rideIndex);
uint8_t directionStart = direction;
direction = direction_reverse(direction);
@@ -698,7 +694,7 @@ bool track_block_get_previous_from_zero(
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
if (tileElement->AsTrack()->GetRideIndex() != ride->id)
continue;
const rct_preview_track* nextTrackBlock = get_track_def_from_ride(ride, tileElement->AsTrack()->GetTrackType());
@@ -811,7 +807,7 @@ bool track_block_get_previous(int32_t x, int32_t y, TileElement* tileElement, tr
rotation = ((trackCoordinate->rotation_begin + rotation) & TILE_ELEMENT_DIRECTION_MASK)
| (trackCoordinate->rotation_begin & (1 << 2));
return track_block_get_previous_from_zero(x, y, z, rideIndex, rotation, outTrackBeginEnd);
return track_block_get_previous_from_zero(x, y, z, ride, rotation, outTrackBeginEnd);
}
/**
@@ -1476,7 +1472,7 @@ void ride_remove_provisional_track_piece()
y -= CoordsDirectionDelta[direction].y;
}
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, rideIndex, direction, &next_track, &z, &direction, true))
if (track_block_get_next_from_zero(x, y, z, ride, direction, &next_track, &z, &direction, true))
{
int32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5
| GAME_COMMAND_FLAG_GHOST;
@@ -1597,7 +1593,7 @@ void ride_construction_set_default_next_piece()
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
direction = _currentTrackPieceDirection;
if (!track_block_get_previous_from_zero(x, y, z, rideIndex, direction, &trackBeginEnd))
if (!track_block_get_previous_from_zero(x, y, z, ride, direction, &trackBeginEnd))
{
ride_construction_reset_current_piece();
return;
@@ -1670,7 +1666,7 @@ void ride_construction_set_default_next_piece()
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
direction = direction_reverse(_currentTrackPieceDirection);
if (!track_block_get_next_from_zero(x, y, z, rideIndex, direction, &xyElement, &z, &direction, false))
if (!track_block_get_next_from_zero(x, y, z, ride, direction, &xyElement, &z, &direction, false))
{
ride_construction_reset_current_piece();
return;
@@ -6019,7 +6015,7 @@ int32_t ride_get_refund_price(const Ride* ride)
*
* rct2: 0x00696707
*/
void ride_stop_peeps_queuing(ride_id_t rideIndex)
void ride_stop_peeps_queuing(Ride* ride)
{
uint16_t spriteIndex;
rct_peep* peep;
@@ -6028,7 +6024,7 @@ void ride_stop_peeps_queuing(ride_id_t rideIndex)
{
if (peep->state != PEEP_STATE_QUEUING)
continue;
if (peep->current_ride != rideIndex)
if (peep->current_ride != ride->id)
continue;
peep->RemoveFromQueue();
@@ -6274,77 +6270,81 @@ void game_command_callback_ride_construct_placed_back(
[[maybe_unused]] int32_t eax, [[maybe_unused]] int32_t ebx, [[maybe_unused]] int32_t ecx, [[maybe_unused]] int32_t edx,
[[maybe_unused]] int32_t esi, [[maybe_unused]] int32_t edi, [[maybe_unused]] int32_t ebp)
{
int32_t trackDirection, x, y, z;
track_begin_end trackBeginEnd;
trackDirection = direction_reverse(_currentTrackPieceDirection);
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
if (!(trackDirection & 4))
auto ride = get_ride(_currentRideIndex);
if (ride != nullptr)
{
x += CoordsDirectionDelta[trackDirection].x;
y += CoordsDirectionDelta[trackDirection].y;
}
auto trackDirection = direction_reverse(_currentTrackPieceDirection);
auto x = _currentTrackBeginX;
auto y = _currentTrackBeginY;
auto z = _currentTrackBeginZ;
if (!(trackDirection & 4))
{
x += CoordsDirectionDelta[trackDirection].x;
y += CoordsDirectionDelta[trackDirection].y;
}
if (track_block_get_previous_from_zero(x, y, z, _currentRideIndex, trackDirection, &trackBeginEnd))
{
_currentTrackBeginX = trackBeginEnd.begin_x;
_currentTrackBeginY = trackBeginEnd.begin_y;
_currentTrackBeginZ = trackBeginEnd.begin_z;
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_previous_section();
}
else
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_0;
}
track_begin_end trackBeginEnd;
if (track_block_get_previous_from_zero(x, y, z, ride, trackDirection, &trackBeginEnd))
{
_currentTrackBeginX = trackBeginEnd.begin_x;
_currentTrackBeginY = trackBeginEnd.begin_y;
_currentTrackBeginZ = trackBeginEnd.begin_z;
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_previous_section();
}
else
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_0;
}
window_ride_construction_do_station_check();
window_ride_construction_update_active_elements();
window_ride_construction_do_station_check();
window_ride_construction_update_active_elements();
}
}
void game_command_callback_ride_construct_placed_front(
[[maybe_unused]] int32_t eax, [[maybe_unused]] int32_t ebx, [[maybe_unused]] int32_t ecx, [[maybe_unused]] int32_t edx,
[[maybe_unused]] int32_t esi, [[maybe_unused]] int32_t edi, [[maybe_unused]] int32_t ebp)
{
int32_t trackDirection, x, y, z;
trackDirection = _currentTrackPieceDirection;
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
if (!(trackDirection & 4))
auto ride = get_ride(_currentRideIndex);
if (ride != nullptr)
{
x -= CoordsDirectionDelta[trackDirection].x;
y -= CoordsDirectionDelta[trackDirection].y;
}
int32_t trackDirection = _currentTrackPieceDirection;
int32_t x = _currentTrackBeginX;
int32_t y = _currentTrackBeginY;
int32_t z = _currentTrackBeginZ;
if (!(trackDirection & 4))
{
x -= CoordsDirectionDelta[trackDirection].x;
y -= CoordsDirectionDelta[trackDirection].y;
}
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, _currentRideIndex, trackDirection, &next_track, &z, &trackDirection, false))
{
_currentTrackBeginX = next_track.x;
_currentTrackBeginY = next_track.y;
_currentTrackBeginZ = z;
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_next_section();
}
else
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_0;
}
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, ride, trackDirection, &next_track, &z, &trackDirection, false))
{
_currentTrackBeginX = next_track.x;
_currentTrackBeginY = next_track.y;
_currentTrackBeginZ = z;
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_next_section();
}
else
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_0;
}
window_ride_construction_do_station_check();
window_ride_construction_do_entrance_exit_check();
window_ride_construction_update_active_elements();
window_ride_construction_do_station_check();
window_ride_construction_do_entrance_exit_check();
window_ride_construction_update_active_elements();
}
}
/**
@@ -6979,57 +6979,55 @@ void ride_get_entrance_or_exit_position_from_screen_position(
bool ride_select_backwards_from_front()
{
track_begin_end trackBeginEnd;
ride_construction_invalidate_current_track();
if (track_block_get_previous_from_zero(
_currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ, _currentRideIndex, _currentTrackPieceDirection,
&trackBeginEnd))
auto ride = get_ride(_currentRideIndex);
if (ride != nullptr)
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
_currentTrackBeginX = trackBeginEnd.begin_x;
_currentTrackBeginY = trackBeginEnd.begin_y;
_currentTrackBeginZ = trackBeginEnd.begin_z;
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
else
{
return false;
ride_construction_invalidate_current_track();
track_begin_end trackBeginEnd;
if (track_block_get_previous_from_zero(
_currentTrackBeginX, _currentTrackBeginY, _currentTrackBeginZ, ride, _currentTrackPieceDirection,
&trackBeginEnd))
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
_currentTrackBeginX = trackBeginEnd.begin_x;
_currentTrackBeginY = trackBeginEnd.begin_y;
_currentTrackBeginZ = trackBeginEnd.begin_z;
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
}
return false;
}
bool ride_select_forwards_from_back()
{
int32_t x, y, z, direction;
ride_construction_invalidate_current_track();
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
direction = direction_reverse(_currentTrackPieceDirection);
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, _currentRideIndex, direction, &next_track, &z, &direction, false))
auto ride = get_ride(_currentRideIndex);
if (ride != nullptr)
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
_currentTrackBeginX = next_track.x;
_currentTrackBeginY = next_track.y;
_currentTrackBeginZ = z;
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
else
{
return false;
ride_construction_invalidate_current_track();
int32_t x = _currentTrackBeginX;
int32_t y = _currentTrackBeginY;
int32_t z = _currentTrackBeginZ;
int32_t direction = direction_reverse(_currentTrackPieceDirection);
CoordsXYE next_track;
if (track_block_get_next_from_zero(x, y, z, ride, direction, &next_track, &z, &direction, false))
{
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
_currentTrackBeginX = next_track.x;
_currentTrackBeginY = next_track.y;
_currentTrackBeginZ = z;
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
}
return false;
}
money32 ride_remove_track_piece(int32_t x, int32_t y, int32_t z, int32_t direction, int32_t type, uint8_t flags)
@@ -7482,28 +7480,28 @@ void ride_update_max_vehicles(Ride* ride)
}
}
void ride_set_ride_entry(ride_id_t rideIndex, int32_t rideEntry)
void ride_set_ride_entry(Ride* ride, int32_t rideEntry)
{
gGameCommandErrorTitle = STR_RIDE_SET_VEHICLE_TYPE_FAIL;
game_do_command(
0, GAME_COMMAND_FLAG_APPLY | (RIDE_SET_VEHICLES_COMMAND_TYPE_RIDE_ENTRY << 8), 0, (rideEntry << 8) | rideIndex,
0, GAME_COMMAND_FLAG_APPLY | (RIDE_SET_VEHICLES_COMMAND_TYPE_RIDE_ENTRY << 8), 0, (rideEntry << 8) | ride->id,
GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0);
}
void ride_set_num_vehicles(ride_id_t rideIndex, int32_t numVehicles)
void ride_set_num_vehicles(Ride* ride, int32_t numVehicles)
{
gGameCommandErrorTitle = STR_RIDE_SET_VEHICLE_SET_NUM_TRAINS_FAIL;
game_do_command(
0, GAME_COMMAND_FLAG_APPLY | (RIDE_SET_VEHICLES_COMMAND_TYPE_NUM_TRAINS << 8), 0, (numVehicles << 8) | rideIndex,
0, GAME_COMMAND_FLAG_APPLY | (RIDE_SET_VEHICLES_COMMAND_TYPE_NUM_TRAINS << 8), 0, (numVehicles << 8) | ride->id,
GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0);
}
void ride_set_num_cars_per_vehicle(ride_id_t rideIndex, int32_t numCarsPerVehicle)
void ride_set_num_cars_per_vehicle(Ride* ride, int32_t numCarsPerVehicle)
{
gGameCommandErrorTitle = STR_RIDE_SET_VEHICLE_SET_NUM_CARS_PER_TRAIN_FAIL;
game_do_command(
0, GAME_COMMAND_FLAG_APPLY | (RIDE_SET_VEHICLES_COMMAND_TYPE_NUM_CARS_PER_TRAIN << 8), 0,
(numCarsPerVehicle << 8) | rideIndex, GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0);
(numCarsPerVehicle << 8) | ride->id, GAME_COMMAND_SET_RIDE_VEHICLES, 0, 0);
}
static bool ride_is_vehicle_type_valid(Ride* ride, uint8_t inputRideEntryIndex)
@@ -7703,9 +7701,8 @@ void game_command_set_ride_vehicles(
*
* rct2: 0x006CB945
*/
void sub_6CB945(ride_id_t rideIndex)
void sub_6CB945(Ride* ride)
{
Ride* ride = get_ride(rideIndex);
if (ride->type != RIDE_TYPE_MAZE)
{
for (uint8_t stationId = 0; stationId < MAX_STATIONS; ++stationId)
@@ -7739,7 +7736,7 @@ void sub_6CB945(ride_id_t rideIndex)
continue;
if (tileElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
if (tileElement->AsTrack()->GetRideIndex() != rideIndex)
if (tileElement->AsTrack()->GetRideIndex() != ride->id)
continue;
if (tileElement->AsTrack()->GetSequenceIndex() != 0)
continue;
@@ -7850,7 +7847,7 @@ void sub_6CB945(ride_id_t rideIndex)
{
if (tileElement->GetType() != TILE_ELEMENT_TYPE_ENTRANCE)
continue;
if (tileElement->AsEntrance()->GetRideIndex() != rideIndex)
if (tileElement->AsEntrance()->GetRideIndex() != ride->id)
continue;
if (tileElement->AsEntrance()->GetEntranceType() > ENTRANCE_TYPE_RIDE_EXIT)
continue;
@@ -7865,7 +7862,7 @@ void sub_6CB945(ride_id_t rideIndex)
{
if (trackElement->GetType() != TILE_ELEMENT_TYPE_TRACK)
continue;
if (trackElement->AsTrack()->GetRideIndex() != rideIndex)
if (trackElement->AsTrack()->GetRideIndex() != ride->id)
continue;
if (trackElement->base_height != tileElement->base_height)
continue;
@@ -7928,9 +7925,8 @@ void sub_6CB945(ride_id_t rideIndex)
}
}
void ride_set_to_default_inspection_interval(ride_id_t rideIndex)
void ride_set_to_default_inspection_interval(Ride* ride)
{
Ride* ride = get_ride(rideIndex);
uint8_t defaultInspectionInterval = gConfigGeneral.default_inspection_interval;
if (ride->inspection_interval != defaultInspectionInterval)
{
@@ -7938,7 +7934,7 @@ void ride_set_to_default_inspection_interval(ride_id_t rideIndex)
{
gGameCommandErrorTitle = STR_CANT_CHANGE_OPERATING_MODE;
game_do_command(
0, (defaultInspectionInterval << 8) | 1, 0, (5 << 8) | rideIndex, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
0, (defaultInspectionInterval << 8) | 1, 0, (5 << 8) | ride->id, GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
}
}
}
@@ -7947,9 +7943,8 @@ void ride_set_to_default_inspection_interval(ride_id_t rideIndex)
*
* rct2: 0x006B752C
*/
void ride_crash(ride_id_t rideIndex, uint8_t vehicleIndex)
void ride_crash(Ride* ride, uint8_t vehicleIndex)
{
Ride* ride = get_ride(rideIndex);
rct_vehicle* vehicle = GET_VEHICLE(ride->vehicles[vehicleIndex]);
if (!(gScreenFlags & SCREEN_FLAGS_TITLE_DEMO))
@@ -7970,7 +7965,7 @@ void ride_crash(ride_id_t rideIndex, uint8_t vehicleIndex)
set_format_arg(2, uint32_t, ride->name_arguments);
if (gConfigNotifications.ride_crashed)
{
news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_HAS_CRASHED, rideIndex);
news_item_add_to_queue(NEWS_ITEM_RIDE, STR_RIDE_HAS_CRASHED, ride->id);
}
}
@@ -8063,9 +8058,8 @@ rct_vehicle* ride_get_broken_vehicle(Ride* ride)
*
* rct2: 0x006D235B
*/
void ride_delete(ride_id_t rideIndex)
void ride_delete(Ride* ride)
{
Ride* ride = get_ride(rideIndex);
user_string_free(ride->name);
ride->type = RIDE_TYPE_NULL;
}
@@ -8644,7 +8638,7 @@ void determine_ride_entrance_and_exit_locations()
}
}
void ride_clear_leftover_entrances(ride_id_t rideIndex)
void ride_clear_leftover_entrances(Ride* ride)
{
tile_element_iterator it;
@@ -8653,7 +8647,7 @@ void ride_clear_leftover_entrances(ride_id_t rideIndex)
{
if (it.element->GetType() == TILE_ELEMENT_TYPE_ENTRANCE
&& it.element->AsEntrance()->GetEntranceType() != ENTRANCE_TYPE_PARK_ENTRANCE
&& it.element->AsEntrance()->GetRideIndex() == rideIndex)
&& it.element->AsEntrance()->GetRideIndex() == ride->id)
{
tile_element_remove(it.element);
tile_element_iterator_restart_for_tile(&it);
+12 -12
View File
@@ -1119,19 +1119,19 @@ void ride_construction_set_default_next_piece();
bool track_block_get_next(CoordsXYE* input, CoordsXYE* output, int32_t* z, int32_t* direction);
bool track_block_get_next_from_zero(
int16_t x, int16_t y, int16_t z_start, ride_id_t rideIndex, uint8_t direction_start, CoordsXYE* output, int32_t* z,
int16_t x, int16_t y, int16_t z_start, Ride* ride, uint8_t direction_start, CoordsXYE* output, int32_t* z,
int32_t* direction, bool isGhost);
bool track_block_get_previous(int32_t x, int32_t y, TileElement* tileElement, track_begin_end* outTrackBeginEnd);
bool track_block_get_previous_from_zero(
int16_t x, int16_t y, int16_t z, ride_id_t rideIndex, uint8_t direction, track_begin_end* outTrackBeginEnd);
int16_t x, int16_t y, int16_t z, Ride* ride, uint8_t direction, track_begin_end* outTrackBeginEnd);
void ride_get_start_of_track(CoordsXYE* output);
void window_ride_construction_update_active_elements();
void ride_construction_remove_ghosts();
money32 ride_entrance_exit_place_ghost(
ride_id_t rideIndex, int32_t x, int32_t y, int32_t direction, int32_t placeType, int32_t stationNum);
Ride* ride, int32_t x, int32_t y, int32_t direction, int32_t placeType, int32_t stationNum);
void ride_get_entrance_or_exit_position_from_screen_position(
int32_t x, int32_t y, int32_t* outX, int32_t* outY, int32_t* outDirection);
@@ -1149,9 +1149,9 @@ void ride_update_max_vehicles(Ride* ride);
void ride_update_vehicle_colours(Ride* ride);
uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry);
void ride_set_ride_entry(ride_id_t rideIndex, int32_t rideEntry);
void ride_set_num_vehicles(ride_id_t rideIndex, int32_t numVehicles);
void ride_set_num_cars_per_vehicle(ride_id_t rideIndex, int32_t numCarsPerVehicle);
void ride_set_ride_entry(Ride* ride, int32_t rideEntry);
void ride_set_num_vehicles(Ride* ride, int32_t numVehicles);
void ride_set_num_cars_per_vehicle(Ride* ride, int32_t numCarsPerVehicle);
void game_command_set_ride_vehicles(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
@@ -1160,10 +1160,10 @@ void game_command_place_ride_entrance_or_exit(
void game_command_remove_ride_entrance_or_exit(
int32_t* eax, int32_t* ebx, int32_t* ecx, int32_t* edx, int32_t* esi, int32_t* edi, int32_t* ebp);
void ride_set_to_default_inspection_interval(ride_id_t rideIndex);
void ride_set_to_default_inspection_interval(Ride* ride);
void sub_6CB945(ride_id_t rideIndex);
void ride_crash(ride_id_t rideIndex, uint8_t vehicleIndex);
void sub_6CB945(Ride* ride);
void ride_crash(Ride* ride, uint8_t vehicleIndex);
void sub_6C94D8();
@@ -1182,7 +1182,7 @@ void window_ride_construction_do_entrance_exit_check();
void game_command_callback_place_ride_entrance_or_exit(
int32_t eax, int32_t ebx, int32_t ecx, int32_t edx, int32_t esi, int32_t edi, int32_t ebp);
void ride_delete(ride_id_t rideIndex);
void ride_delete(Ride* ride);
void ride_renew(Ride* ride);
money16 ride_get_price(Ride* ride);
@@ -1203,11 +1203,11 @@ int32_t ride_get_entry_index(int32_t rideType, int32_t rideSubType);
StationObject* ride_get_station_object(const Ride* ride);
void ride_action_modify(Ride* ride, int32_t modifyType, int32_t flags);
void ride_stop_peeps_queuing(ride_id_t rideIndex);
void ride_stop_peeps_queuing(Ride* ride);
LocationXY16 ride_get_rotated_coords(int16_t x, int16_t y, int16_t z);
void determine_ride_entrance_and_exit_locations();
void ride_clear_leftover_entrances(ride_id_t rideIndex);
void ride_clear_leftover_entrances(Ride* ride);
#endif
+2 -2
View File
@@ -1509,7 +1509,7 @@ static money32 track_place(
{
track_add_station_element(x, y, baseZ, direction, rideIndex, GAME_COMMAND_FLAG_APPLY);
}
sub_6CB945(rideIndex);
sub_6CB945(ride);
ride_update_max_vehicles(ride);
}
@@ -1794,7 +1794,7 @@ static money32 track_remove(
footpath_remove_edges_at(x, y, tileElement);
}
tile_element_remove(tileElement);
sub_6CB945(rideIndex);
sub_6CB945(ride);
if (!(flags & GAME_COMMAND_FLAG_GHOST))
{
ride_update_max_vehicles(ride);
+9 -8
View File
@@ -1643,8 +1643,8 @@ static bool track_design_place_ride(rct_track_td6* td6, int16_t x, int16_t y, in
if (_trackDesignPlaceOperation == PTD_OPERATION_CLEAR_OUTLINES)
{
sub_6CB945(_currentRideIndex);
ride_delete(_currentRideIndex);
sub_6CB945(ride);
ride_delete(ride);
}
return true;
}
@@ -1730,8 +1730,9 @@ int32_t place_virtual_track(
* ebx = ride_id
* cost = edi
*/
static bool track_design_place_preview(rct_track_td6* td6, money32* cost, uint8_t* rideId, uint8_t* flags)
static bool track_design_place_preview(rct_track_td6* td6, money32* cost, Ride** outRide, uint8_t* flags)
{
*outRide = nullptr;
*flags = 0;
uint8_t entry_type, entry_index;
@@ -1818,7 +1819,7 @@ static bool track_design_place_preview(rct_track_td6* td6, money32* cost, uint8_
_currentTrackPieceDirection = backup_rotation;
byte_9D8150 = false;
*cost = resultCost;
*rideId = rideIndex;
*outRide = ride;
return true;
}
else
@@ -1972,7 +1973,7 @@ static money32 place_track_design(int16_t x, int16_t y, int16_t z, uint8_t flags
}
game_do_command(0, flags | (num_circuits << 8), 0, ride->id | (9 << 8), GAME_COMMAND_SET_RIDE_SETTING, 0, 0);
ride_set_to_default_inspection_interval(ride->id);
ride_set_to_default_inspection_interval(ride);
ride->lifecycle_flags |= RIDE_LIFECYCLE_NOT_CUSTOM_DESIGN;
ride->colour_scheme_type = td6->version_and_colour_scheme & 3;
@@ -2189,9 +2190,9 @@ void track_design_draw_preview(rct_track_td6* td6, uint8_t* pixels)
}
money32 cost;
ride_id_t rideIndex;
Ride* ride;
uint8_t flags;
if (!track_design_place_preview(td6, &cost, &rideIndex, &flags))
if (!track_design_place_preview(td6, &cost, &ride, &flags))
{
std::fill_n(pixels, TRACK_PREVIEW_IMAGE_SIZE * 4, 0x00);
track_design_preview_restore_map(mapBackup);
@@ -2277,7 +2278,7 @@ void track_design_draw_preview(rct_track_td6* td6, uint8_t* pixels)
dpi.bits += TRACK_PREVIEW_IMAGE_SIZE;
}
ride_delete(rideIndex);
ride_delete(ride);
track_design_preview_restore_map(mapBackup);
}
+5 -5
View File
@@ -2564,8 +2564,8 @@ static void vehicle_update_waiting_to_depart(rct_vehicle* vehicle)
int32_t direction;
if (track_block_get_next_from_zero(
vehicle->track_x, vehicle->track_y, vehicle->track_z, vehicle->ride, (uint8_t)(vehicle->track_direction & 0x3),
&track, &z, &direction, false))
vehicle->track_x, vehicle->track_y, vehicle->track_z, ride, (uint8_t)(vehicle->track_direction & 0x3), &track,
&z, &direction, false))
{
if (track.element->AsTrack()->HasCableLift())
{
@@ -3532,7 +3532,7 @@ static void vehicle_update_collision_setup(rct_vehicle* vehicle)
return;
}
ride_crash(vehicle->ride, trainIndex);
ride_crash(ride, trainIndex);
if (ride->status != RIDE_STATUS_CLOSED)
{
@@ -5270,7 +5270,7 @@ static void vehicle_crash_on_land(rct_vehicle* vehicle)
return;
}
ride_crash(vehicle->ride, trainIndex);
ride_crash(ride, trainIndex);
if (ride->status != RIDE_STATUS_CLOSED)
{
@@ -5327,7 +5327,7 @@ static void vehicle_crash_on_water(rct_vehicle* vehicle)
return;
}
ride_crash(vehicle->ride, trainIndex);
ride_crash(ride, trainIndex);
if (ride->status != RIDE_STATUS_CLOSED)
{
+2 -2
View File
@@ -501,10 +501,10 @@ void ride_entrance_exit_remove_ghost()
* rct2: 0x006CA28C
*/
money32 ride_entrance_exit_place_ghost(
ride_id_t rideIndex, int32_t x, int32_t y, int32_t direction, int32_t placeType, int32_t stationNum)
Ride* ride, int32_t x, int32_t y, int32_t direction, int32_t placeType, int32_t stationNum)
{
ride_construction_remove_ghosts();
money32 result = RideEntranceExitPlaceGhost(rideIndex, x, y, direction, placeType, stationNum);
money32 result = RideEntranceExitPlaceGhost(ride->id, x, y, direction, placeType, stationNum);
if (result != MONEY32_UNDEFINED)
{