Cleanup gotos to loc_6D8E36

This commit is contained in:
Gymnasiast 2021-07-20 14:43:29 +02:00
parent d0436c7379
commit 3966c6f7a4
No known key found for this signature in database
GPG Key ID: DBFFF47AB2CA3EDD
2 changed files with 88 additions and 81 deletions

View File

@ -3894,6 +3894,91 @@ void Vehicle::UpdateTravelling()
sub_state = 1;
}
void Vehicle::UpdateArrivingPassThroughStation(
const Ride& curRide, const rct_ride_entry_vehicle& vehicleEntry, bool stationBrakesWork)
{
if (sub_state == 0)
{
if (curRide.mode == RideMode::Race && curRide.lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING)
{
return;
}
if (velocity <= 131940)
{
acceleration = 3298;
return;
}
int32_t velocity_diff = velocity;
if (velocity_diff >= 1572864)
velocity_diff /= 8;
else
velocity_diff /= 16;
if (!stationBrakesWork)
{
return;
}
if (curRide.num_circuits != 1)
{
if (num_laps + 1 < curRide.num_circuits)
{
return;
}
}
velocity -= velocity_diff;
acceleration = 0;
}
else
{
if (!(vehicleEntry.flags & VEHICLE_ENTRY_FLAG_POWERED) && velocity >= -131940)
{
acceleration = -3298;
}
if (velocity >= -131940)
{
return;
}
int32_t velocity_diff = velocity;
if (velocity_diff < -1572864)
velocity_diff /= 8;
else
velocity_diff /= 16;
if (!stationBrakesWork)
{
return;
}
if (num_laps + 1 < curRide.num_circuits)
{
return;
}
if (num_laps + 1 != curRide.num_circuits)
{
velocity -= velocity_diff;
acceleration = 0;
return;
}
if (GetRideTypeDescriptor(curRide.type).HasFlag(RIDE_TYPE_FLAG_ALLOW_MULTIPLE_CIRCUITS)
&& curRide.mode != RideMode::Shuttle && curRide.mode != RideMode::PoweredLaunch)
{
SetUpdateFlag(VEHICLE_UPDATE_FLAG_12);
}
else
{
velocity -= velocity_diff;
acceleration = 0;
}
}
}
/**
*
* rct2: 0x006D8C36
@ -3948,88 +4033,8 @@ void Vehicle::UpdateArriving()
rct_ride_entry* rideEntry = GetRideEntry();
rct_ride_entry_vehicle* vehicleEntry = &rideEntry->vehicles[vehicle_type];
if (sub_state == 0)
{
if (curRide->mode == RideMode::Race && curRide->lifecycle_flags & RIDE_LIFECYCLE_PASS_STATION_NO_STOPPING)
{
goto loc_6D8E36;
}
UpdateArrivingPassThroughStation(*curRide, *vehicleEntry, stationBrakesWork);
if (velocity <= 131940)
{
acceleration = 3298;
goto loc_6D8E36;
}
int32_t velocity_diff = velocity;
if (velocity_diff >= 1572864)
velocity_diff /= 8;
else
velocity_diff /= 16;
if (!stationBrakesWork)
{
goto loc_6D8E36;
}
if (curRide->num_circuits != 1)
{
if (num_laps + 1 < curRide->num_circuits)
{
goto loc_6D8E36;
}
}
velocity -= velocity_diff;
acceleration = 0;
}
else
{
if (!(vehicleEntry->flags & VEHICLE_ENTRY_FLAG_POWERED) && velocity >= -131940)
{
acceleration = -3298;
}
if (velocity >= -131940)
{
goto loc_6D8E36;
}
int32_t velocity_diff = velocity;
if (velocity_diff < -1572864)
velocity_diff /= 8;
else
velocity_diff /= 16;
if (!stationBrakesWork)
{
goto loc_6D8E36;
}
if (num_laps + 1 < curRide->num_circuits)
{
goto loc_6D8E36;
}
if (num_laps + 1 != curRide->num_circuits)
{
velocity -= velocity_diff;
acceleration = 0;
goto loc_6D8E36;
}
if (GetRideTypeDescriptor(curRide->type).HasFlag(RIDE_TYPE_FLAG_ALLOW_MULTIPLE_CIRCUITS)
&& curRide->mode != RideMode::Shuttle && curRide->mode != RideMode::PoweredLaunch)
{
SetUpdateFlag(VEHICLE_UPDATE_FLAG_12);
}
else
{
velocity -= velocity_diff;
acceleration = 0;
}
}
loc_6D8E36:
curFlags = UpdateTrackMotion(nullptr);
if (curFlags & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_COLLISION && !stationBrakesWork)
{

View File

@ -308,6 +308,8 @@ private:
void UpdateDepartingBoatHire();
void UpdateTravellingBoatHireSetup();
void UpdateBoatLocation();
void UpdateArrivingPassThroughStation(
const Ride& curRide, const rct_ride_entry_vehicle& vehicleEntry, bool stationBrakesWork);
void UpdateArriving();
void UpdateUnloadingPassengers();
void UpdateWaitingForCableLift();