mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add RideUpdate to RTD (#17752)
This commit is contained in:
parent
a21d9183e6
commit
807e080d41
|
@ -1062,10 +1062,9 @@ void Ride::Update()
|
|||
}
|
||||
|
||||
// Ride specific updates
|
||||
if (type == RIDE_TYPE_CHAIRLIFT)
|
||||
UpdateChairlift();
|
||||
else if (type == RIDE_TYPE_SPIRAL_SLIDE)
|
||||
UpdateSpiralSlide();
|
||||
const auto& rtd = GetRideTypeDescriptor();
|
||||
if (rtd.RideUpdate != nullptr)
|
||||
rtd.RideUpdate(*this);
|
||||
|
||||
ride_breakdown_update(this);
|
||||
|
||||
|
@ -1104,23 +1103,23 @@ void Ride::Update()
|
|||
*
|
||||
* rct2: 0x006AC489
|
||||
*/
|
||||
void Ride::UpdateChairlift()
|
||||
void UpdateChairlift(Ride& ride)
|
||||
{
|
||||
if (!(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
if (!(ride.lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||
return;
|
||||
if ((lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))
|
||||
&& breakdown_reason_pending == 0)
|
||||
if ((ride.lifecycle_flags & (RIDE_LIFECYCLE_BREAKDOWN_PENDING | RIDE_LIFECYCLE_BROKEN_DOWN | RIDE_LIFECYCLE_CRASHED))
|
||||
&& ride.breakdown_reason_pending == 0)
|
||||
return;
|
||||
|
||||
uint16_t old_chairlift_bullwheel_rotation = chairlift_bullwheel_rotation >> 14;
|
||||
chairlift_bullwheel_rotation += speed * 2048;
|
||||
if (old_chairlift_bullwheel_rotation == speed / 8)
|
||||
uint16_t old_chairlift_bullwheel_rotation = ride.chairlift_bullwheel_rotation >> 14;
|
||||
ride.chairlift_bullwheel_rotation += ride.speed * 2048;
|
||||
if (old_chairlift_bullwheel_rotation == ride.speed / 8)
|
||||
return;
|
||||
|
||||
auto bullwheelLoc = ChairliftBullwheelLocation[0].ToCoordsXYZ();
|
||||
auto bullwheelLoc = ride.ChairliftBullwheelLocation[0].ToCoordsXYZ();
|
||||
map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) });
|
||||
|
||||
bullwheelLoc = ChairliftBullwheelLocation[1].ToCoordsXYZ();
|
||||
bullwheelLoc = ride.ChairliftBullwheelLocation[1].ToCoordsXYZ();
|
||||
map_invalidate_tile_zoom1({ bullwheelLoc, bullwheelLoc.z, bullwheelLoc.z + (4 * COORDS_Z_STEP) });
|
||||
}
|
||||
|
||||
|
@ -1196,19 +1195,20 @@ static constexpr const CoordsXY ride_spiral_slide_main_tile_offset[][4] = {
|
|||
*
|
||||
* rct2: 0x006AC545
|
||||
*/
|
||||
void Ride::UpdateSpiralSlide()
|
||||
|
||||
void UpdateSpiralSlide(Ride& ride)
|
||||
{
|
||||
if (gCurrentTicks & 3)
|
||||
return;
|
||||
if (slide_in_use == 0)
|
||||
if (ride.slide_in_use == 0)
|
||||
return;
|
||||
|
||||
spiral_slide_progress++;
|
||||
if (spiral_slide_progress >= 48)
|
||||
ride.spiral_slide_progress++;
|
||||
if (ride.spiral_slide_progress >= 48)
|
||||
{
|
||||
slide_in_use--;
|
||||
ride.slide_in_use--;
|
||||
|
||||
auto* peep = GetEntity<Guest>(slide_peep);
|
||||
auto* peep = GetEntity<Guest>(ride.slide_peep);
|
||||
if (peep != nullptr)
|
||||
{
|
||||
auto destination = peep->GetDestination();
|
||||
|
@ -1221,12 +1221,12 @@ void Ride::UpdateSpiralSlide()
|
|||
// Invalidate something related to station start
|
||||
for (int32_t i = 0; i < OpenRCT2::Limits::MaxStationsPerRide; i++)
|
||||
{
|
||||
if (stations[i].Start.IsNull())
|
||||
if (ride.stations[i].Start.IsNull())
|
||||
continue;
|
||||
|
||||
auto startLoc = stations[i].Start;
|
||||
auto startLoc = ride.stations[i].Start;
|
||||
|
||||
TileElement* tileElement = ride_get_station_start_track_element(this, StationIndex::FromUnderlying(i));
|
||||
TileElement* tileElement = ride_get_station_start_track_element(&ride, StationIndex::FromUnderlying(i));
|
||||
if (tileElement == nullptr)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -279,6 +279,10 @@ struct Ride
|
|||
uint8_t current_issues;
|
||||
uint32_t last_issue_time;
|
||||
|
||||
// TO-DO: those friend functions are temporary, find a way to not access the private fields
|
||||
friend void UpdateSpiralSlide(Ride& ride);
|
||||
friend void UpdateChairlift(Ride& ride);
|
||||
|
||||
private:
|
||||
std::array<RideStation, OpenRCT2::Limits::MaxStationsPerRide> stations;
|
||||
|
||||
|
@ -298,8 +302,6 @@ public:
|
|||
|
||||
private:
|
||||
void Update();
|
||||
void UpdateChairlift();
|
||||
void UpdateSpiralSlide();
|
||||
void UpdateQueueLength(StationIndex stationIndex);
|
||||
ResultWithMessage CreateVehicles(const CoordsXYE& element, bool isApplying);
|
||||
void MoveTrainsToBlockBrakes(TrackElement* firstBlock);
|
||||
|
@ -396,6 +398,8 @@ public:
|
|||
bool HasRecolourableShopItems() const;
|
||||
bool HasStation() const;
|
||||
};
|
||||
void UpdateSpiralSlide(Ride& ride);
|
||||
void UpdateChairlift(Ride& ride);
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
|
|
|
@ -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 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,7 @@ struct RideTypeDescriptor
|
|||
PeepUpdateRideLeaveEntranceFunc UpdateLeaveEntrance = PeepUpdateRideLeaveEntranceDefault;
|
||||
|
||||
RideConstructionWindowContext ConstructionWindowContext = RideConstructionWindowContext::Default;
|
||||
RideUpdateFunction RideUpdate = nullptr;
|
||||
|
||||
RideUpdateMeasurementsSpecialElementsFunc UpdateMeasurementsSpecialElements = RideUpdateMeasurementsSpecialElements_Default;
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ constexpr const RideTypeDescriptor WaterCoasterRTD =
|
|||
SET_FIELD(Classification, RideClassification::Ride),
|
||||
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
|
||||
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
|
||||
SET_FIELD(RideUpdate, nullptr),
|
||||
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_WaterCoaster),
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -57,6 +57,7 @@ constexpr const RideTypeDescriptor CircusRTD =
|
|||
SET_FIELD(Classification,RideClassification::Ride),
|
||||
SET_FIELD(UpdateLeaveEntrance,PeepUpdateRideLeaveEntranceDefault),
|
||||
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
|
||||
SET_FIELD(RideUpdate, nullptr),
|
||||
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_Default),
|
||||
SET_FIELD(MusicTrackOffsetLength, OpenRCT2::RideAudio::RideMusicGetTrackOffsetLength_Circus),
|
||||
};
|
||||
|
|
|
@ -59,6 +59,7 @@ constexpr const RideTypeDescriptor MiniGolfRTD =
|
|||
SET_FIELD(Classification, RideClassification::Ride),
|
||||
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceDefault),
|
||||
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
|
||||
SET_FIELD(RideUpdate, nullptr),
|
||||
SET_FIELD(UpdateMeasurementsSpecialElements, RideUpdateMeasurementsSpecialElements_MiniGolf),
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -59,5 +59,7 @@ constexpr const RideTypeDescriptor SpiralSlideRTD =
|
|||
SET_FIELD(MusicUpdateFunction, DefaultMusicUpdate),
|
||||
SET_FIELD(Classification, RideClassification::Ride),
|
||||
SET_FIELD(UpdateLeaveEntrance, PeepUpdateRideLeaveEntranceSpiralSlide),
|
||||
SET_FIELD(ConstructionWindowContext, RideConstructionWindowContext::Default),
|
||||
SET_FIELD(RideUpdate, UpdateSpiralSlide),
|
||||
};
|
||||
// clang-format on
|
||||
|
|
|
@ -57,5 +57,12 @@ constexpr const RideTypeDescriptor ChairliftRTD =
|
|||
SET_FIELD(ColourKey, RideColourKey::Ride),
|
||||
SET_FIELD(Name, "chairlift"),
|
||||
SET_FIELD(LightFXAddLightsMagicVehicle, LightFxAddLightsMagicVehicle_ChairLift),
|
||||
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(ConstructionWindowContext, RideConstructionWindowContext::Default),
|
||||
SET_FIELD(RideUpdate, UpdateChairlift),
|
||||
};
|
||||
// clang-format on
|
||||
|
|
Loading…
Reference in New Issue