From c2cfa95d1a5d5bffaff5f130c929db809818994a Mon Sep 17 00:00:00 2001 From: frutiemax Date: Wed, 31 Aug 2022 21:56:13 -0400 Subject: [PATCH] Add UpdateRideApproachVehicleWaypoints to RTD (#17124) --- src/openrct2/entity/Guest.cpp | 54 ++++++++++--------- src/openrct2/entity/Guest.h | 5 ++ src/openrct2/ride/RideData.h | 3 ++ .../ride/thrill/meta/MotionSimulator.h | 13 +++++ 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 600e7608e7..4fe85c21f7 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -4391,31 +4391,10 @@ void Guest::UpdateRideApproachVehicleWaypoints() int16_t xy_distance; uint8_t waypoint = Var37 & 3; + const auto& rtd = ride->GetRideTypeDescriptor(); if (auto loc = UpdateAction(xy_distance); loc.has_value()) { - int16_t actionZ; - // Motion simulators have steps this moves the peeps up the steps - if (ride->type == RIDE_TYPE_MOTION_SIMULATOR) - { - actionZ = ride->GetStation(CurrentRideStation).GetBaseZ() + 2; - - if (waypoint == 2) - { - xy_distance -= 12; - if (xy_distance < 0) - xy_distance = 0; - - if (xy_distance <= 15) - { - actionZ += 15 - xy_distance; - } - } - } - else - { - actionZ = z; - } - MoveTo({ loc.value(), actionZ }); + rtd.UpdateRideApproachVehicleWaypoints(*this, loc.value(), xy_distance); return; } @@ -4435,7 +4414,6 @@ void Guest::UpdateRideApproachVehicleWaypoints() return; } - const auto& rtd = ride->GetRideTypeDescriptor(); CoordsXY targetLoc = rtd.GetGuestWaypointLocation(*vehicle, *ride, CurrentRideStation); rct_ride_entry* ride_entry = vehicle->GetRideEntry(); @@ -4452,6 +4430,33 @@ void Guest::UpdateRideApproachVehicleWaypoints() SetDestination(targetLoc); } +void UpdateRideApproachVehicleWaypointsMotionSimulator(Guest& guest, const CoordsXY& loc, int16_t& xy_distance) +{ + int16_t actionZ; + auto ride = get_ride(guest.CurrentRide); + // Motion simulators have steps this moves the peeps up the steps + actionZ = ride->GetStation(guest.CurrentRideStation).GetBaseZ() + 2; + + uint8_t waypoint = guest.Var37 & 3; + if (waypoint == 2) + { + xy_distance -= 12; + if (xy_distance < 0) + xy_distance = 0; + + if (xy_distance <= 15) + { + actionZ += 15 - xy_distance; + } + } + guest.MoveTo({ loc, actionZ }); +} + +void UpdateRideApproachVehicleWaypointsDefault(Guest& guest, const CoordsXY& loc, int16_t& xy_distance) +{ + guest.MoveTo({ loc, guest.z }); +} + /** * * rct2: 0x0069357D @@ -4467,6 +4472,7 @@ void Guest::UpdateRideApproachExitWaypoints() if (auto loc = UpdateAction(xy_distance); loc.has_value()) { int16_t actionZ; + if (ride->type == RIDE_TYPE_MOTION_SIMULATOR) { actionZ = ride->GetStation(CurrentRideStation).GetBaseZ() + 2; diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index a2c856fe3e..13e00850de 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -400,7 +400,9 @@ private: void UpdateRideLeaveVehicle(); void UpdateRideApproachExit(); void UpdateRideInExit(); + void UpdateRideApproachVehicleWaypoints(); + void UpdateRideApproachExitWaypoints(); void UpdateRideApproachSpiralSlide(); void UpdateRideOnSpiralSlide(); @@ -425,6 +427,9 @@ private: void GoToRideEntrance(Ride* ride); }; +void UpdateRideApproachVehicleWaypointsMotionSimulator(Guest&, const CoordsXY&, int16_t&); +void UpdateRideApproachVehicleWaypointsDefault(Guest&, const CoordsXY&, int16_t&); + static_assert(sizeof(Guest) <= 512); enum diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index 42cf4ad0a2..7b2d90cfed 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -157,6 +157,7 @@ struct UpkeepCostsDescriptor }; using RideTrackGroup = OpenRCT2::BitSet; +using UpdateRideApproachVehicleWaypointsFunction = void (*)(Guest&, const CoordsXY&, int16_t&); using RideMusicUpdateFunction = void (*)(Ride*); using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest*, Ride*, CoordsXYZD&); using StartRideMusicFunction = void (*)(const OpenRCT2::RideAudio::ViewportRideMusicInstance&); @@ -244,6 +245,8 @@ struct RideTypeDescriptor MusicTrackOffsetLengthFunc MusicTrackOffsetLength = OpenRCT2::RideAudio::RideMusicGetTrackOffsetLength_Default; + UpdateRideApproachVehicleWaypointsFunction UpdateRideApproachVehicleWaypoints = UpdateRideApproachVehicleWaypointsDefault; + bool HasFlag(uint64_t flag) const; void GetAvailableTrackPieces(RideTrackGroup& res) const; bool SupportsTrackPiece(const uint64_t trackPiece) const; diff --git a/src/openrct2/ride/thrill/meta/MotionSimulator.h b/src/openrct2/ride/thrill/meta/MotionSimulator.h index 54a55f6846..71d59b93f4 100644 --- a/src/openrct2/ride/thrill/meta/MotionSimulator.h +++ b/src/openrct2/ride/thrill/meta/MotionSimulator.h @@ -50,5 +50,18 @@ constexpr const RideTypeDescriptor MotionSimulatorRTD = SET_FIELD(ColourPreview, { 0, 0 }), SET_FIELD(ColourKey, RideColourKey::Ride), SET_FIELD(Name, "motion_simulator"), + 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(SpecialElementRatingAdjustment, SpecialTrackElementRatingsAjustment_Default), + SET_FIELD(GetGuestWaypointLocation, GetGuestWaypointLocationDefault), + SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default), + SET_FIELD(RideUpdate, nullptr), + SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_Default), + SET_FIELD(MusicTrackOffsetLength, OpenRCT2::RideAudio::RideMusicGetTrackOffsetLength_Default), + SET_FIELD(UpdateRideApproachVehicleWaypoints, UpdateRideApproachVehicleWaypointsMotionSimulator), }; // clang-format on