diff --git a/src/openrct2/entity/Guest.cpp b/src/openrct2/entity/Guest.cpp index 0dad6cd517..8abfcf5efe 100644 --- a/src/openrct2/entity/Guest.cpp +++ b/src/openrct2/entity/Guest.cpp @@ -3503,7 +3503,7 @@ static constexpr const CoordsXY _MazeEntranceStart[] = { { 24, 8 }, }; -static void peep_update_ride_leave_entrance_maze(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc) +void PeepUpdateRideLeaveEntranceMaze(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc) { peep->MazeLastEdge = entrance_loc.direction + 1; @@ -3532,7 +3532,7 @@ static void peep_update_ride_leave_entrance_maze(Guest* peep, Ride* ride, Coords peep->RideSubState = PeepRideSubState::MazePathfinding; } -static void peep_update_ride_leave_entrance_spiral_slide(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc) +void PeepUpdateRideLeaveEntranceSpiralSlide(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc) { entrance_loc = { ride->GetStation(peep->CurrentRideStation).GetStart(), entrance_loc.direction }; @@ -3552,6 +3552,24 @@ static void peep_update_ride_leave_entrance_spiral_slide(Guest* peep, Ride* ride peep->RideSubState = PeepRideSubState::ApproachSpiralSlide; } +void PeepUpdateRideLeaveEntranceDefault(Guest* peep, Ride* ride, CoordsXYZD& entrance_loc) +{ + // If the ride type was changed guests will become stuck. + // Inform the player about this if its a new issue or hasn't been addressed within 120 seconds. + if ((ride->current_issues & RIDE_ISSUE_GUESTS_STUCK) == 0 || gCurrentTicks - ride->last_issue_time > 3000) + { + ride->current_issues |= RIDE_ISSUE_GUESTS_STUCK; + ride->last_issue_time = gCurrentTicks; + + auto ft = Formatter(); + ride->FormatNameTo(ft); + if (gConfigNotifications.ride_warnings) + { + News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, peep->CurrentRide.ToUnderlying(), ft); + } + } +} + uint8_t Guest::GetWaypointedSeatLocation(const Ride& ride, CarEntry* vehicle_type, uint8_t track_direction) const { // The seatlocation can be split into segments around the ride base @@ -3671,32 +3689,8 @@ void Guest::UpdateRideAdvanceThroughEntrance() auto entranceLocation = station.Entrance.ToCoordsXYZD(); Guard::Assert(!entranceLocation.IsNull()); - if (ride->type == RIDE_TYPE_MAZE) - { - peep_update_ride_leave_entrance_maze(this, ride, entranceLocation); - return; - } - if (ride->type == RIDE_TYPE_SPIRAL_SLIDE) - { - peep_update_ride_leave_entrance_spiral_slide(this, ride, entranceLocation); - return; - } - - // If the ride type was changed guests will become stuck. - // Inform the player about this if its a new issue or hasn't been addressed within 120 seconds. - if ((ride->current_issues & RIDE_ISSUE_GUESTS_STUCK) == 0 || gCurrentTicks - ride->last_issue_time > 3000) - { - ride->current_issues |= RIDE_ISSUE_GUESTS_STUCK; - ride->last_issue_time = gCurrentTicks; - - auto ft = Formatter(); - ride->FormatNameTo(ft); - if (gConfigNotifications.ride_warnings) - { - News::AddItemToQueue(News::ItemType::Ride, STR_GUESTS_GETTING_STUCK_ON_RIDE, CurrentRide.ToUnderlying(), ft); - } - } - + const auto& rtd = GetRideTypeDescriptor(ride->type); + rtd.UpdateLeaveEntrance(this, ride, entranceLocation); return; } diff --git a/src/openrct2/entity/Guest.h b/src/openrct2/entity/Guest.h index f95f05eb1b..6c1ec140f7 100644 --- a/src/openrct2/entity/Guest.h +++ b/src/openrct2/entity/Guest.h @@ -475,3 +475,7 @@ void increment_guests_in_park(); void increment_guests_heading_for_park(); void decrement_guests_in_park(); 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); diff --git a/src/openrct2/ride/RideData.h b/src/openrct2/ride/RideData.h index f4cf2335bc..ce6e8ed677 100644 --- a/src/openrct2/ride/RideData.h +++ b/src/openrct2/ride/RideData.h @@ -22,6 +22,7 @@ #include "../audio/audio.h" #include "../common.h" #include "../core/BitSet.hpp" +#include "../entity/Guest.h" #include "../localisation/StringIds.h" #include "../sprites.h" #include "../util/Util.h" @@ -151,6 +152,7 @@ struct UpkeepCostsDescriptor using RideTrackGroup = OpenRCT2::BitSet; using RideMusicUpdateFunction = void (*)(Ride*); +using PeepUpdateRideLeaveEntranceFunc = void (*)(Guest*, Ride*, CoordsXYZD&); struct RideTypeDescriptor { uint8_t AlternateType; @@ -204,6 +206,8 @@ struct RideTypeDescriptor RideMusicUpdateFunction MusicUpdateFunction = DefaultMusicUpdate; RideClassification Classification = RideClassification::Ride; + PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault; + bool HasFlag(uint64_t flag) const; void GetAvailableTrackPieces(RideTrackGroup& res) const; bool SupportsTrackPiece(const uint64_t trackPiece) const; @@ -395,6 +399,10 @@ constexpr const RideTypeDescriptor DummyRTD = SET_FIELD(ColourPreview, { static_cast(SPR_NONE), static_cast(SPR_NONE) }), SET_FIELD(ColourKey, RideColourKey::Ride), SET_FIELD(Name, "invalid"), + SET_FIELD(DesignCreateMode, TrackDesignCreateMode::Default), + SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate), + SET_FIELD(Classification, RideClassification::Ride), + SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault), }; // clang-format on diff --git a/src/openrct2/ride/gentle/meta/Maze.h b/src/openrct2/ride/gentle/meta/Maze.h index 59da8f7cc9..f56fb2edf8 100644 --- a/src/openrct2/ride/gentle/meta/Maze.h +++ b/src/openrct2/ride/gentle/meta/Maze.h @@ -52,5 +52,8 @@ constexpr const RideTypeDescriptor MazeRTD = SET_FIELD(ColourKey, RideColourKey::Ride), SET_FIELD(Name, "maze"), SET_FIELD(DesignCreateMode, TrackDesignCreateMode::Maze), + SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate), + SET_FIELD(Classification, RideClassification::Ride), + SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceMaze), }; // clang-format on diff --git a/src/openrct2/ride/gentle/meta/SpiralSlide.h b/src/openrct2/ride/gentle/meta/SpiralSlide.h index 7c40ded862..bdf8839ff8 100644 --- a/src/openrct2/ride/gentle/meta/SpiralSlide.h +++ b/src/openrct2/ride/gentle/meta/SpiralSlide.h @@ -53,5 +53,9 @@ constexpr const RideTypeDescriptor SpiralSlideRTD = SET_FIELD(ColourPreview, { SPR_RIDE_DESIGN_PREVIEW_SPIRAL_SLIDE_TRACK, 0 }), SET_FIELD(ColourKey, RideColourKey::Ride), SET_FIELD(Name, "spiral_slide"), + SET_FIELD(DesignCreateMode, TrackDesignCreateMode::Default), + SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate), + SET_FIELD(Classification, RideClassification::Ride), + SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceSpiralSlide), }; // clang-format on