From f9bb5b244758485d17b72f290abc3c4f00e327de Mon Sep 17 00:00:00 2001 From: frutiemax Date: Sat, 13 Aug 2022 15:53:27 -0400 Subject: [PATCH] Add GetGuestWaypointLocation to RTD (#17750) --- src/openrct2/entity/Guest.cpp | 52 ++++++++----------- src/openrct2/entity/Guest.h | 3 ++ src/openrct2/ride/RideData.h | 3 ++ src/openrct2/ride/coaster/meta/WaterCoaster.h | 1 + src/openrct2/ride/gentle/meta/Circus.h | 1 + src/openrct2/ride/gentle/meta/Maze.h | 1 + src/openrct2/ride/gentle/meta/MiniGolf.h | 1 + src/openrct2/ride/gentle/meta/SpiralSlide.h | 1 + src/openrct2/ride/thrill/meta/Enterprise.h | 7 +++ src/openrct2/ride/transport/meta/Chairlift.h | 1 + 10 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 50afb47551..0517cf851b 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -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(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(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]; diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index f70569b29e..a2c856fe3e 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -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); diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index b3ab7cd368..e91b64761f 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -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 (*)(const Ride& ride); @@ -228,6 +229,8 @@ struct RideTypeDescriptor PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault; + RideLocationFunction GetGuestWaypointLocation = GetGuestWaypointLocationDefault; + RideConstructionWindowContext ConstructionWindowContext = RideConstructionWindowContext::Default; RideUpdateFunction RideUpdate = nullptr; diff --git a/src/openrct2/ride/coaster/meta/WaterCoaster.h b/src/openrct2/ride/coaster/meta/WaterCoaster.h index c5d14ec2a0..0cc5e3828d 100644 --- a/src/openrct2/ride/coaster/meta/WaterCoaster.h +++ b/src/openrct2/ride/coaster/meta/WaterCoaster.h @@ -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), diff --git a/src/openrct2/ride/gentle/meta/Circus.h b/src/openrct2/ride/gentle/meta/Circus.h index 496d55f55d..3ba5fe496d 100644 --- a/src/openrct2/ride/gentle/meta/Circus.h +++ b/src/openrct2/ride/gentle/meta/Circus.h @@ -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), diff --git a/src/openrct2/ride/gentle/meta/Maze.h b/src/openrct2/ride/gentle/meta/Maze.h index 5da339ce33..c8b4258002 100644 --- a/src/openrct2/ride/gentle/meta/Maze.h +++ b/src/openrct2/ride/gentle/meta/Maze.h @@ -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 diff --git a/src/openrct2/ride/gentle/meta/MiniGolf.h b/src/openrct2/ride/gentle/meta/MiniGolf.h index 69ac375822..426ef6a1c2 100644 --- a/src/openrct2/ride/gentle/meta/MiniGolf.h +++ b/src/openrct2/ride/gentle/meta/MiniGolf.h @@ -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), diff --git a/src/openrct2/ride/gentle/meta/SpiralSlide.h b/src/openrct2/ride/gentle/meta/SpiralSlide.h index ad613f3f73..b45438f26d 100644 --- a/src/openrct2/ride/gentle/meta/SpiralSlide.h +++ b/src/openrct2/ride/gentle/meta/SpiralSlide.h @@ -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), }; diff --git a/src/openrct2/ride/thrill/meta/Enterprise.h b/src/openrct2/ride/thrill/meta/Enterprise.h index 10d6dc8e51..589a5b6f04 100644 --- a/src/openrct2/ride/thrill/meta/Enterprise.h +++ b/src/openrct2/ride/thrill/meta/Enterprise.h @@ -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 diff --git a/src/openrct2/ride/transport/meta/Chairlift.h b/src/openrct2/ride/transport/meta/Chairlift.h index d2a94b9c68..8c3fd709a3 100644 --- a/src/openrct2/ride/transport/meta/Chairlift.h +++ b/src/openrct2/ride/transport/meta/Chairlift.h @@ -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), };