mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 17:54:50 +01:00
Move ride_open and ride_test into Ride
This commit is contained in:
@@ -101,7 +101,7 @@ public:
|
||||
}
|
||||
else if (_status == RIDE_STATUS_TESTING || _status == RIDE_STATUS_SIMULATING)
|
||||
{
|
||||
if (!ride_test(ride, _status, false))
|
||||
if (!ride->Test(_status, false))
|
||||
{
|
||||
res->Error = GameActions::Status::Unknown;
|
||||
res->ErrorMessage = gGameCommandErrorText;
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
}
|
||||
else if (_status == RIDE_STATUS_OPEN)
|
||||
{
|
||||
if (!ride_open(ride, _status == RIDE_STATUS_OPEN, false))
|
||||
if (!ride->Open(_status == RIDE_STATUS_OPEN, false))
|
||||
{
|
||||
res->Error = GameActions::Status::Unknown;
|
||||
res->ErrorMessage = gGameCommandErrorText;
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
ride_clear_for_construction(ride);
|
||||
ride_remove_peeps(ride);
|
||||
|
||||
if (!ride_test(ride, _status, true))
|
||||
if (!ride->Test(_status, true))
|
||||
{
|
||||
res->Error = GameActions::Status::Unknown;
|
||||
res->ErrorMessage = gGameCommandErrorText;
|
||||
@@ -213,14 +213,14 @@ public:
|
||||
|
||||
if (_status == RIDE_STATUS_TESTING)
|
||||
{
|
||||
if (!ride_test(ride, _status, true))
|
||||
if (!ride->Test(_status, true))
|
||||
{
|
||||
res->Error = GameActions::Status::Unknown;
|
||||
res->ErrorMessage = gGameCommandErrorText;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
else if (!ride_open(ride, _status == RIDE_STATUS_OPEN, true))
|
||||
else if (!ride->Open(_status == RIDE_STATUS_OPEN, true))
|
||||
{
|
||||
res->Error = GameActions::Status::Unknown;
|
||||
res->ErrorMessage = gGameCommandErrorText;
|
||||
|
||||
@@ -5116,56 +5116,56 @@ TrackElement* Ride::GetOriginElement(StationIndex stationIndex) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
bool Ride::Test(int32_t newStatus, bool isApplying)
|
||||
{
|
||||
CoordsXYE trackElement, problematicTrackElement = {};
|
||||
|
||||
if (ride->type == RIDE_TYPE_NULL)
|
||||
if (type == RIDE_TYPE_NULL)
|
||||
{
|
||||
log_warning("Invalid ride type for ride %u", ride->id);
|
||||
log_warning("Invalid ride type for ride %u", id);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status != RIDE_STATUS_SIMULATING)
|
||||
if (newStatus != RIDE_STATUS_SIMULATING)
|
||||
{
|
||||
window_close_by_number(WC_RIDE_CONSTRUCTION, ride->id);
|
||||
window_close_by_number(WC_RIDE_CONSTRUCTION, id);
|
||||
}
|
||||
|
||||
StationIndex stationIndex = ride_mode_check_station_present(ride);
|
||||
StationIndex stationIndex = ride_mode_check_station_present(this);
|
||||
if (stationIndex == STATION_INDEX_NULL)
|
||||
return false;
|
||||
|
||||
if (!ride_mode_check_valid_station_numbers(ride))
|
||||
if (!ride_mode_check_valid_station_numbers(this))
|
||||
return false;
|
||||
|
||||
if (status != RIDE_STATUS_SIMULATING && !ride_check_for_entrance_exit(ride->id))
|
||||
if (newStatus != RIDE_STATUS_SIMULATING && !ride_check_for_entrance_exit(id))
|
||||
{
|
||||
loc_6B51C0(ride);
|
||||
loc_6B51C0(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (status == RIDE_STATUS_OPEN && isApplying)
|
||||
if (newStatus == RIDE_STATUS_OPEN && isApplying)
|
||||
{
|
||||
sub_6B5952(ride);
|
||||
ride->lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
|
||||
sub_6B5952(this);
|
||||
lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
|
||||
}
|
||||
|
||||
// z = ride->stations[i].GetBaseZ();
|
||||
auto startLoc = ride->stations[stationIndex].Start;
|
||||
auto startLoc = stations[stationIndex].Start;
|
||||
trackElement.x = startLoc.x;
|
||||
trackElement.y = startLoc.y;
|
||||
trackElement.element = reinterpret_cast<TileElement*>(ride->GetOriginElement(stationIndex));
|
||||
trackElement.element = reinterpret_cast<TileElement*>(GetOriginElement(stationIndex));
|
||||
if (trackElement.element == nullptr)
|
||||
{
|
||||
// Maze is strange, station start is 0... investigation required
|
||||
if (ride->type != RIDE_TYPE_MAZE)
|
||||
if (type != RIDE_TYPE_MAZE)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ride->mode == RideMode::ContinuousCircuit || ride->IsBlockSectioned())
|
||||
if (mode == RideMode::ContinuousCircuit || IsBlockSectioned())
|
||||
{
|
||||
if (ride_find_track_gap(ride, &trackElement, &problematicTrackElement)
|
||||
&& (status != RIDE_STATUS_SIMULATING || ride->IsBlockSectioned()))
|
||||
if (ride_find_track_gap(this, &trackElement, &problematicTrackElement)
|
||||
&& (newStatus != RIDE_STATUS_SIMULATING || IsBlockSectioned()))
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_IS_NOT_A_COMPLETE_CIRCUIT;
|
||||
ride_scroll_to_track_error(&problematicTrackElement);
|
||||
@@ -5173,7 +5173,7 @@ bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->IsBlockSectioned())
|
||||
if (IsBlockSectioned())
|
||||
{
|
||||
if (!ride_check_block_brakes(&trackElement, &problematicTrackElement))
|
||||
{
|
||||
@@ -5182,9 +5182,9 @@ bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
|
||||
if (subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
|
||||
{
|
||||
rct_ride_entry* rideType = get_ride_entry(ride->subtype);
|
||||
rct_ride_entry* rideType = get_ride_entry(subtype);
|
||||
if (rideType->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
|
||||
@@ -5205,9 +5205,9 @@ bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->mode == RideMode::StationToStation)
|
||||
if (mode == RideMode::StationToStation)
|
||||
{
|
||||
if (!ride_find_track_gap(ride, &trackElement, &problematicTrackElement))
|
||||
if (!ride_find_track_gap(this, &trackElement, &problematicTrackElement))
|
||||
{
|
||||
gGameCommandErrorText = STR_RIDE_MUST_START_AND_END_WITH_STATIONS;
|
||||
return false;
|
||||
@@ -5229,21 +5229,20 @@ bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
}
|
||||
|
||||
if (isApplying)
|
||||
ride_set_start_finish_points(ride->id, &trackElement);
|
||||
ride_set_start_finish_points(id, &trackElement);
|
||||
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_VEHICLES) && !(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
if (!ride_type_has_flag(type, RIDE_TYPE_FLAG_NO_VEHICLES) && !(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
{
|
||||
if (!ride_create_vehicles(ride, trackElement, isApplying))
|
||||
if (!ride_create_vehicles(this, trackElement, isApplying))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((RideTypeDescriptors[ride->type].Flags & RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL)
|
||||
&& (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED)
|
||||
&& !(ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
||||
if ((RideTypeDescriptors[type].Flags & RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL)
|
||||
&& (lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) && !(lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
||||
{
|
||||
if (!ride_create_cable_lift(ride->id, isApplying))
|
||||
if (!ride_create_cable_lift(id, isApplying))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -5253,7 +5252,7 @@ bool ride_test(Ride* ride, int32_t status, bool isApplying)
|
||||
*
|
||||
* rct2: 0x006B4EEA
|
||||
*/
|
||||
bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
bool Ride::Open(int32_t goingToBeOpen, bool isApplying)
|
||||
{
|
||||
CoordsXYE trackElement, problematicTrackElement = {};
|
||||
|
||||
@@ -5261,44 +5260,44 @@ bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
// to set the track to its final state and clean up ghosts.
|
||||
// We can't just call close as it would cause a stack overflow during shop creation
|
||||
// with auto open on.
|
||||
if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && ride->id == gCurrentToolWidget.window_number
|
||||
if (WC_RIDE_CONSTRUCTION == gCurrentToolWidget.window_classification && id == gCurrentToolWidget.window_number
|
||||
&& (input_test_flag(INPUT_FLAG_TOOL_ACTIVE)))
|
||||
window_close_by_number(WC_RIDE_CONSTRUCTION, ride->id);
|
||||
window_close_by_number(WC_RIDE_CONSTRUCTION, id);
|
||||
|
||||
StationIndex stationIndex = ride_mode_check_station_present(ride);
|
||||
StationIndex stationIndex = ride_mode_check_station_present(this);
|
||||
if (stationIndex == STATION_INDEX_NULL)
|
||||
return false;
|
||||
|
||||
if (!ride_mode_check_valid_station_numbers(ride))
|
||||
if (!ride_mode_check_valid_station_numbers(this))
|
||||
return false;
|
||||
|
||||
if (!ride_check_for_entrance_exit(ride->id))
|
||||
if (!ride_check_for_entrance_exit(id))
|
||||
{
|
||||
loc_6B51C0(ride);
|
||||
loc_6B51C0(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (goingToBeOpen && isApplying)
|
||||
{
|
||||
sub_6B5952(ride);
|
||||
ride->lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
|
||||
sub_6B5952(this);
|
||||
lifecycle_flags |= RIDE_LIFECYCLE_EVER_BEEN_OPENED;
|
||||
}
|
||||
|
||||
// z = ride->stations[i].GetBaseZ();
|
||||
auto startLoc = ride->stations[stationIndex].Start;
|
||||
auto startLoc = stations[stationIndex].Start;
|
||||
trackElement.x = startLoc.x;
|
||||
trackElement.y = startLoc.y;
|
||||
trackElement.element = reinterpret_cast<TileElement*>(ride->GetOriginElement(stationIndex));
|
||||
trackElement.element = reinterpret_cast<TileElement*>(GetOriginElement(stationIndex));
|
||||
if (trackElement.element == nullptr)
|
||||
{
|
||||
// Maze is strange, station start is 0... investigation required
|
||||
if (ride->type != RIDE_TYPE_MAZE)
|
||||
if (type != RIDE_TYPE_MAZE)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ride->mode == RideMode::Race || ride->mode == RideMode::ContinuousCircuit || ride->IsBlockSectioned())
|
||||
if (mode == RideMode::Race || mode == RideMode::ContinuousCircuit || IsBlockSectioned())
|
||||
{
|
||||
if (ride_find_track_gap(ride, &trackElement, &problematicTrackElement))
|
||||
if (ride_find_track_gap(this, &trackElement, &problematicTrackElement))
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_IS_NOT_A_COMPLETE_CIRCUIT;
|
||||
ride_scroll_to_track_error(&problematicTrackElement);
|
||||
@@ -5306,7 +5305,7 @@ bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->IsBlockSectioned())
|
||||
if (IsBlockSectioned())
|
||||
{
|
||||
if (!ride_check_block_brakes(&trackElement, &problematicTrackElement))
|
||||
{
|
||||
@@ -5315,9 +5314,9 @@ bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
|
||||
if (subtype != RIDE_ENTRY_INDEX_NULL && !gCheatsEnableAllDrawableTrackPieces)
|
||||
{
|
||||
rct_ride_entry* rideEntry = get_ride_entry(ride->subtype);
|
||||
rct_ride_entry* rideEntry = get_ride_entry(subtype);
|
||||
if (rideEntry->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS)
|
||||
{
|
||||
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
|
||||
@@ -5338,9 +5337,9 @@ bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
}
|
||||
}
|
||||
|
||||
if (ride->mode == RideMode::StationToStation)
|
||||
if (mode == RideMode::StationToStation)
|
||||
{
|
||||
if (!ride_find_track_gap(ride, &trackElement, &problematicTrackElement))
|
||||
if (!ride_find_track_gap(this, &trackElement, &problematicTrackElement))
|
||||
{
|
||||
gGameCommandErrorText = STR_RIDE_MUST_START_AND_END_WITH_STATIONS;
|
||||
return false;
|
||||
@@ -5362,21 +5361,20 @@ bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying)
|
||||
}
|
||||
|
||||
if (isApplying)
|
||||
ride_set_start_finish_points(ride->id, &trackElement);
|
||||
ride_set_start_finish_points(id, &trackElement);
|
||||
|
||||
if (!ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_NO_VEHICLES) && !(ride->lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
if (!ride_type_has_flag(type, RIDE_TYPE_FLAG_NO_VEHICLES) && !(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
{
|
||||
if (!ride_create_vehicles(ride, trackElement, isApplying))
|
||||
if (!ride_create_vehicles(this, trackElement, isApplying))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((RideTypeDescriptors[ride->type].Flags & RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL)
|
||||
&& (ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED)
|
||||
&& !(ride->lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
||||
if ((RideTypeDescriptors[type].Flags & RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL)
|
||||
&& (lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) && !(lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
||||
{
|
||||
if (!ride_create_cable_lift(ride->id, isApplying))
|
||||
if (!ride_create_cable_lift(id, isApplying))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -407,6 +407,9 @@ public:
|
||||
|
||||
void StopGuestsQueuing();
|
||||
|
||||
bool Open(int32_t goingToBeOpen, bool isApplying);
|
||||
bool Test(int32_t newStatus, bool isApplying);
|
||||
|
||||
RideMode GetDefaultMode() const;
|
||||
|
||||
void SetColourPreset(uint8_t index);
|
||||
@@ -1113,8 +1116,6 @@ void ride_set_vehicle_colours_to_random_preset(Ride* ride, uint8_t preset_index)
|
||||
void ride_measurements_update();
|
||||
void ride_breakdown_add_news_item(Ride* ride);
|
||||
Peep* ride_find_closest_mechanic(Ride* ride, int32_t forInspection);
|
||||
bool ride_open(Ride* ride, int32_t goingToBeOpen, bool isApplying);
|
||||
bool ride_test(Ride* ride, int32_t status, bool isApplying);
|
||||
int32_t ride_initialise_construction_window(Ride* ride);
|
||||
void ride_construction_invalidate_current_track();
|
||||
std::optional<CoordsXYZ> sub_6C683D(
|
||||
|
||||
Reference in New Issue
Block a user