mirror of https://github.com/OpenRCT2/OpenRCT2.git
Create Ride::ChangeStatusCreateVehicles() to reduce codedup
Co-authored-by: spacek531 <spacek531@users.noreply.github.com>
This commit is contained in:
parent
e91d22b203
commit
3329da538b
|
@ -3943,28 +3943,7 @@ ResultWithMessage Ride::Test(RideStatus newStatus, bool isApplying)
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isApplying)
|
return ChangeStatusCreateVehicles(isApplying, trackElement);
|
||||||
ride_set_start_finish_points(id, trackElement);
|
|
||||||
|
|
||||||
const auto& rtd = GetRideTypeDescriptor();
|
|
||||||
if (!rtd.HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES) && !(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
|
||||||
{
|
|
||||||
const auto createVehicleResult = CreateVehicles(trackElement, isApplying);
|
|
||||||
if (!createVehicleResult.Successful)
|
|
||||||
{
|
|
||||||
return { false, createVehicleResult.Message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtd.HasFlag(RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL) && (lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED)
|
|
||||||
&& !(lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
|
||||||
{
|
|
||||||
const auto createCableLiftResult = ride_create_cable_lift(id, isApplying);
|
|
||||||
if (!createCableLiftResult.Successful)
|
|
||||||
return { false, createCableLiftResult.Message };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { true };
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -4034,27 +4013,7 @@ ResultWithMessage Ride::Open(bool isApplying)
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isApplying)
|
return ChangeStatusCreateVehicles(isApplying, trackElement);
|
||||||
ride_set_start_finish_points(id, trackElement);
|
|
||||||
|
|
||||||
if (!GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES) && !(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
|
||||||
{
|
|
||||||
const auto createVehicleResult = CreateVehicles(trackElement, isApplying);
|
|
||||||
if (!createVehicleResult.Successful)
|
|
||||||
{
|
|
||||||
return { false, createVehicleResult.Message };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((GetRideTypeDescriptor().HasFlag(RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL))
|
|
||||||
&& (lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED) && !(lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
|
||||||
{
|
|
||||||
const auto createCableLiftResult = ride_create_cable_lift(id, isApplying);
|
|
||||||
if (!createCableLiftResult.Successful)
|
|
||||||
return { false, createCableLiftResult.Message };
|
|
||||||
}
|
|
||||||
|
|
||||||
return { true };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -5894,3 +5853,29 @@ ResultWithMessage Ride::ChangeStatusCheckTrackValidity(const CoordsXYE& trackEle
|
||||||
|
|
||||||
return { true };
|
return { true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResultWithMessage Ride::ChangeStatusCreateVehicles(bool isApplying, const CoordsXYE& trackElement)
|
||||||
|
{
|
||||||
|
if (isApplying)
|
||||||
|
ride_set_start_finish_points(id, trackElement);
|
||||||
|
|
||||||
|
const auto& rtd = GetRideTypeDescriptor();
|
||||||
|
if (!rtd.HasFlag(RIDE_TYPE_FLAG_NO_VEHICLES) && !(lifecycle_flags & RIDE_LIFECYCLE_ON_TRACK))
|
||||||
|
{
|
||||||
|
const auto createVehicleResult = CreateVehicles(trackElement, isApplying);
|
||||||
|
if (!createVehicleResult.Successful)
|
||||||
|
{
|
||||||
|
return { false, createVehicleResult.Message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtd.HasFlag(RIDE_TYPE_FLAG_ALLOW_CABLE_LIFT_HILL) && (lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT_HILL_COMPONENT_USED)
|
||||||
|
&& !(lifecycle_flags & RIDE_LIFECYCLE_CABLE_LIFT))
|
||||||
|
{
|
||||||
|
const auto createCableLiftResult = ride_create_cable_lift(id, isApplying);
|
||||||
|
if (!createCableLiftResult.Successful)
|
||||||
|
return { false, createCableLiftResult.Message };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { true };
|
||||||
|
}
|
||||||
|
|
|
@ -310,6 +310,7 @@ private:
|
||||||
void ConstructMissingEntranceOrExit() const;
|
void ConstructMissingEntranceOrExit() const;
|
||||||
|
|
||||||
ResultWithMessage ChangeStatusCheckTrackValidity(const CoordsXYE& trackElement);
|
ResultWithMessage ChangeStatusCheckTrackValidity(const CoordsXYE& trackElement);
|
||||||
|
ResultWithMessage ChangeStatusCreateVehicles(bool isApplying, const CoordsXYE& trackElement);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool CanBreakDown() const;
|
bool CanBreakDown() const;
|
||||||
|
|
Loading…
Reference in New Issue