Add GetGuestWaypointLocation to RTD (#17750)

This commit is contained in:
frutiemax 2022-08-13 15:53:27 -04:00 committed by GitHub
parent d9e23e9dfa
commit f9bb5b2447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 41 additions and 30 deletions

View File

@ -3595,8 +3595,6 @@ void Guest::UpdateRideLeaveEntranceWaypoints(const Ride& ride)
Guard::Assert(!station.Entrance.IsNull());
uint8_t direction_entrance = station.Entrance.direction;
CoordsXY waypoint = ride.GetStation(CurrentRideStation).Start.ToTileCentre();
TileElement* tile_element = ride_get_station_start_track_element(&ride, CurrentRideStation);
uint8_t direction_track = (tile_element == nullptr ? 0 : tile_element->GetDirection());
@ -3612,11 +3610,8 @@ void Guest::UpdateRideLeaveEntranceWaypoints(const Ride& ride)
Var37 = (direction_entrance | GetWaypointedSeatLocation(ride, vehicle_type, direction_track) * 4) * 4;
if (ride.type == RIDE_TYPE_ENTERPRISE)
{
waypoint.x = vehicle->x;
waypoint.y = vehicle->y;
}
const auto& rtd = ride.GetRideTypeDescriptor();
CoordsXY waypoint = rtd.GetGuestWaypointLocation(*vehicle, ride, CurrentRideStation);
const auto waypointIndex = Var37 / 4;
Guard::Assert(vehicle_type->peep_loading_waypoints.size() >= static_cast<size_t>(waypointIndex));
@ -4237,9 +4232,6 @@ void Guest::UpdateRideLeaveVehicle()
auto exitLocation = station.Exit.ToCoordsXYZD();
Guard::Assert(!exitLocation.IsNull());
auto waypointLoc = CoordsXYZ{ station.Start.ToTileCentre(),
exitLocation.z + ride->GetRideTypeDescriptor().Heights.PlatformHeight };
TileElement* trackElement = ride_get_station_start_track_element(ride, CurrentRideStation);
Direction station_direction = (trackElement == nullptr ? 0 : trackElement->GetDirection());
@ -4250,19 +4242,17 @@ void Guest::UpdateRideLeaveVehicle()
return;
}
CoordsXYZ waypointLoc;
const auto& rtd = ride->GetRideTypeDescriptor();
waypointLoc = { rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation),
exitLocation.z + ride->GetRideTypeDescriptor().Heights.PlatformHeight };
rideEntry = vehicle->GetRideEntry();
carEntry = &rideEntry->Cars[vehicle->vehicle_type];
if (carEntry == nullptr)
return;
Var37 = ((exitLocation.direction | GetWaypointedSeatLocation(*ride, carEntry, station_direction) * 4) * 4) | 1;
if (ride->type == RIDE_TYPE_ENTERPRISE)
{
waypointLoc.x = vehicle->x;
waypointLoc.y = vehicle->y;
}
Guard::Assert(carEntry->peep_loading_waypoints.size() >= static_cast<size_t>(Var37 / 4));
CoordsXYZ exitWaypointLoc = waypointLoc;
@ -4371,6 +4361,17 @@ void Guest::UpdateRideInExit()
RideSubState = PeepRideSubState::LeaveExit;
}
#pragma warning(default : 6011)
CoordsXY GetGuestWaypointLocationDefault(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation)
{
return ride.GetStation(CurrentRideStation).Start.ToTileCentre();
}
CoordsXY GetGuestWaypointLocationEnterprise(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation)
{
return { vehicle.x, vehicle.y };
}
/**
*
* rct2: 0x006926AD
@ -4428,13 +4429,8 @@ void Guest::UpdateRideApproachVehicleWaypoints()
return;
}
CoordsXY targetLoc = ride->GetStation(CurrentRideStation).Start.ToTileCentre();
if (ride->type == RIDE_TYPE_ENTERPRISE)
{
targetLoc.x = vehicle->x;
targetLoc.y = vehicle->y;
}
const auto& rtd = ride->GetRideTypeDescriptor();
CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation);
rct_ride_entry* ride_entry = vehicle->GetRideEntry();
if (ride_entry == nullptr)
@ -4499,13 +4495,9 @@ void Guest::UpdateRideApproachExitWaypoints()
{
return;
}
CoordsXY targetLoc = ride->GetStation(CurrentRideStation).Start.ToTileCentre();
if (ride->type == RIDE_TYPE_ENTERPRISE)
{
targetLoc.x = vehicle->x;
targetLoc.y = vehicle->y;
}
const auto& rtd = ride->GetRideTypeDescriptor();
CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation);
rct_ride_entry* rideEntry = vehicle->GetRideEntry();
CarEntry* carEntry = &rideEntry->Cars[vehicle->vehicle_type];

View File

@ -477,3 +477,6 @@ void decrement_guests_heading_for_park();
void PeepUpdateRideLeaveEntranceMaze(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceSpiralSlide(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc);
void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc);
CoordsXY GetGuestWaypointLocationDefault(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
CoordsXY GetGuestWaypointLocationEnterprise(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);

View File

@ -160,6 +160,7 @@ using RideMusicUpdateFunction = void (*)(Ride*);
using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest*, Ride*, CoordsXYZD&);
using StartRideMusicFunction = void (*)(const OpenRCT2::RideAudio::ViewportRideMusicInstance&);
using LightFXAddLightsMagicVehicleFunction = void (*)(const Vehicle* vehicle);
using RideLocationFunction = CoordsXY (*)(const Vehicle& vehicle, const Ride& ride, const StationIndex& CurrentRideStation);
using RideUpdateFunction = void (*)(Ride& ride);
using RideUpdateMeasurementsSpecialElementsFunc = void (*)(Ride* ride, const track_type_t trackType);
using MusicTrackOffsetLengthFunc = std::pair<size_t, size_t> (*)(const Ride& ride);
@ -228,6 +229,8 @@ struct RideTypeDescriptor
PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault;
RideLocationFunction GetGuestWaypointLocation = GetGuestWaypointLocationDefault;
RideConstructionWindowContext ConstructionWindowContext = RideConstructionWindowContext::Default;
RideUpdateFunction RideUpdate = nullptr;

View File

@ -60,6 +60,7 @@ constexpr const RideTypeDescriptor WaterCoasterRTD =
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
SET_FIELD(RideUpdate, nullptr),
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_WaterCoaster),

View File

@ -56,6 +56,7 @@ constexpr const RideTypeDescriptor CircusRTD =
SET_FIELD(MusicUpdateFunction, CircusMusicUpdate),
SET_FIELD(Classification,RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance,PeepUpdateRideLeaveEntranceDefault),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
SET_FIELD(RideUpdate, nullptr),
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_Default),

View File

@ -58,6 +58,7 @@ constexpr const RideTypeDescriptor MazeRTD =
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceMaze),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Maze),
};
// clang-format on

View File

@ -58,6 +58,7 @@ constexpr const RideTypeDescriptor MiniGolfRTD =
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
SET_FIELD(RideUpdate, nullptr),
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_MiniGolf),

View File

@ -59,6 +59,7 @@ constexpr const RideTypeDescriptor SpiralSlideRTD =
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceSpiralSlide),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
SET_FIELD(RideUpdate, UpdateSpiralSlide),
};

View File

@ -50,5 +50,12 @@ constexpr const RideTypeDescriptor EnterpriseRTD =
SET_FIELD(ColourPreview, { 0, 0 }),
SET_FIELD(ColourKey, RideColourKey::Ride),
SET_FIELD(Name, "enterprise"),
SET_FIELD(LightFXAddLightsMagicVehicle, nullptr),
SET_FIELD(StartRideMusic, OpenRCT2::RideAudio::DefaultStartRideMusicChannel),
SET_FIELD(DesignCreateMode, TrackDesignCreateMode::Default),
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationEnterprise),
};
// clang-format on

View File

@ -62,6 +62,7 @@ constexpr const RideTypeDescriptor ChairliftRTD =
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
SET_FIELD(Classification, RideClassification::Ride),
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault),
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
SET_FIELD(RideUpdate, UpdateChairlift),
};