1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Part of #9473: Create 5 Vehicle::CableLiftUpdate... from cable_lift_update_...

This commit is contained in:
Mustapha Elghoul
2020-04-20 22:12:42 -04:00
parent 4d679b7e3e
commit e627b1680c
2 changed files with 49 additions and 50 deletions

View File

@@ -20,12 +20,6 @@
#include <algorithm>
static void cable_lift_update_moving_to_end_of_station(Vehicle* vehicle);
static void cable_lift_update_waiting_to_depart(Vehicle* vehicle);
static void cable_lift_update_departing(Vehicle* vehicle);
static void cable_lift_update_travelling(Vehicle* vehicle);
static void cable_lift_update_arriving(Vehicle* vehicle);
Vehicle* cable_lift_segment_create(
Ride& ride, int32_t x, int32_t y, int32_t z, int32_t direction, uint16_t var_44, int32_t remaining_distance, bool head)
{
@@ -93,22 +87,22 @@ void Vehicle::CableLiftUpdate()
switch (status)
{
case VEHICLE_STATUS_MOVING_TO_END_OF_STATION:
cable_lift_update_moving_to_end_of_station(this);
CableLiftUpdateMovingToEndOfStation();
break;
case VEHICLE_STATUS_WAITING_FOR_PASSENGERS:
// Stays in this state until a train puts it into next state
break;
case VEHICLE_STATUS_WAITING_TO_DEPART:
cable_lift_update_waiting_to_depart(this);
CableLiftUpdateWaitingToDepart();
break;
case VEHICLE_STATUS_DEPARTING:
cable_lift_update_departing(this);
CableLiftUpdateDeparting();
break;
case VEHICLE_STATUS_TRAVELLING:
cable_lift_update_travelling(this);
CableLiftUpdateTravelling();
break;
case VEHICLE_STATUS_ARRIVING:
cable_lift_update_arriving(this);
CableLiftUpdateArriving();
break;
default:
break;
@@ -119,47 +113,47 @@ void Vehicle::CableLiftUpdate()
*
* rct2: 0x006DF8A4
*/
static void cable_lift_update_moving_to_end_of_station(Vehicle* vehicle)
void Vehicle::CableLiftUpdateMovingToEndOfStation()
{
if (vehicle->velocity >= -439800)
vehicle->acceleration = -2932;
if (velocity >= -439800)
acceleration = -2932;
if (vehicle->velocity < -439800)
if (velocity < -439800)
{
vehicle->velocity -= vehicle->velocity / 16;
vehicle->acceleration = 0;
velocity -= velocity / 16;
acceleration = 0;
}
if (!(cable_lift_update_track_motion(vehicle) & (1 << 0)))
if (!(cable_lift_update_track_motion(this) & (1 << 0)))
return;
vehicle->velocity = 0;
vehicle->acceleration = 0;
vehicle->SetState(VEHICLE_STATUS_WAITING_FOR_PASSENGERS, vehicle->sub_state);
velocity = 0;
acceleration = 0;
SetState(VEHICLE_STATUS_WAITING_FOR_PASSENGERS, sub_state);
}
/**
*
* rct2: 0x006DF8F1
*/
static void cable_lift_update_waiting_to_depart(Vehicle* vehicle)
void Vehicle::CableLiftUpdateWaitingToDepart()
{
if (vehicle->velocity >= -58640)
vehicle->acceleration = -14660;
if (velocity >= -58640)
acceleration = -14660;
if (vehicle->velocity < -58640)
if (velocity < -58640)
{
vehicle->velocity -= vehicle->velocity / 16;
vehicle->acceleration = 0;
velocity -= velocity / 16;
acceleration = 0;
}
cable_lift_update_track_motion(vehicle);
cable_lift_update_track_motion(this);
// Next check to see if the second part of the cable lift
// is at the front of the passenger vehicle to simulate the
// cable being attached underneath the train.
Vehicle* passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
Vehicle* cableLiftSecondPart = GET_VEHICLE(vehicle->prev_vehicle_on_ride);
Vehicle* passengerVehicle = GET_VEHICLE(cable_lift_target);
Vehicle* cableLiftSecondPart = GET_VEHICLE(prev_vehicle_on_ride);
int16_t dist_x = abs(passengerVehicle->x - cableLiftSecondPart->x);
int16_t dist_y = abs(passengerVehicle->y - cableLiftSecondPart->y);
@@ -167,23 +161,23 @@ static void cable_lift_update_waiting_to_depart(Vehicle* vehicle)
if (dist_x + dist_y > 2)
return;
vehicle->velocity = 0;
vehicle->acceleration = 0;
vehicle->SetState(VEHICLE_STATUS_DEPARTING, 0);
velocity = 0;
acceleration = 0;
SetState(VEHICLE_STATUS_DEPARTING, 0);
}
/**
*
* rct2: 0x006DF97A
*/
static void cable_lift_update_departing(Vehicle* vehicle)
void Vehicle::CableLiftUpdateDeparting()
{
vehicle->sub_state++;
if (vehicle->sub_state < 16)
sub_state++;
if (sub_state < 16)
return;
Vehicle* passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
vehicle->SetState(VEHICLE_STATUS_TRAVELLING, vehicle->sub_state);
Vehicle* passengerVehicle = GET_VEHICLE(cable_lift_target);
SetState(VEHICLE_STATUS_TRAVELLING, sub_state);
passengerVehicle->SetState(VEHICLE_STATUS_TRAVELLING_CABLE_LIFT, passengerVehicle->sub_state);
}
@@ -191,32 +185,32 @@ static void cable_lift_update_departing(Vehicle* vehicle)
*
* rct2: 0x006DF99C
*/
static void cable_lift_update_travelling(Vehicle* vehicle)
void Vehicle::CableLiftUpdateTravelling()
{
Vehicle* passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
Vehicle* passengerVehicle = GET_VEHICLE(cable_lift_target);
vehicle->velocity = std::min(passengerVehicle->velocity, 439800);
vehicle->acceleration = 0;
velocity = std::min(passengerVehicle->velocity, 439800);
acceleration = 0;
if (passengerVehicle->update_flags & VEHICLE_UPDATE_FLAG_BROKEN_TRAIN)
return;
if (!(cable_lift_update_track_motion(vehicle) & (1 << 1)))
if (!(cable_lift_update_track_motion(this) & (1 << 1)))
return;
vehicle->velocity = 0;
vehicle->acceleration = 0;
vehicle->SetState(VEHICLE_STATUS_ARRIVING, 0);
velocity = 0;
acceleration = 0;
SetState(VEHICLE_STATUS_ARRIVING, 0);
}
/**
*
* rct2: 0x006DF9F0
*/
static void cable_lift_update_arriving(Vehicle* vehicle)
void Vehicle::CableLiftUpdateArriving()
{
vehicle->sub_state++;
if (vehicle->sub_state >= 64)
vehicle->SetState(VEHICLE_STATUS_MOVING_TO_END_OF_STATION, vehicle->sub_state);
sub_state++;
if (sub_state >= 64)
SetState(VEHICLE_STATUS_MOVING_TO_END_OF_STATION, sub_state);
}
static bool sub_6DF01A_loop(Vehicle* vehicle)

View File

@@ -350,6 +350,11 @@ private:
bool CurrentTowerElementIsTop();
bool UpdateTrackMotionForwards(rct_ride_entry_vehicle* vehicleEntry, Ride* curRide, rct_ride_entry* rideEntry);
bool UpdateTrackMotionBackwards(rct_ride_entry_vehicle* vehicleEntry, Ride* curRide, rct_ride_entry* rideEntry);
void CableLiftUpdateMovingToEndOfStation();
void CableLiftUpdateWaitingToDepart();
void CableLiftUpdateDeparting();
void CableLiftUpdateTravelling();
void CableLiftUpdateArriving();
};
struct train_ref