mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-23 15:52:55 +01:00
Merge pull request #11382 from mustaphaelghoul/eecs481
Create 5 Vehicle::CableLiftUpdate... member functions from cable_lift_update_... (#9473)
This commit is contained in:
@@ -20,12 +20,6 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#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(
|
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)
|
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)
|
switch (status)
|
||||||
{
|
{
|
||||||
case VEHICLE_STATUS_MOVING_TO_END_OF_STATION:
|
case VEHICLE_STATUS_MOVING_TO_END_OF_STATION:
|
||||||
cable_lift_update_moving_to_end_of_station(this);
|
CableLiftUpdateMovingToEndOfStation();
|
||||||
break;
|
break;
|
||||||
case VEHICLE_STATUS_WAITING_FOR_PASSENGERS:
|
case VEHICLE_STATUS_WAITING_FOR_PASSENGERS:
|
||||||
// Stays in this state until a train puts it into next state
|
// Stays in this state until a train puts it into next state
|
||||||
break;
|
break;
|
||||||
case VEHICLE_STATUS_WAITING_TO_DEPART:
|
case VEHICLE_STATUS_WAITING_TO_DEPART:
|
||||||
cable_lift_update_waiting_to_depart(this);
|
CableLiftUpdateWaitingToDepart();
|
||||||
break;
|
break;
|
||||||
case VEHICLE_STATUS_DEPARTING:
|
case VEHICLE_STATUS_DEPARTING:
|
||||||
cable_lift_update_departing(this);
|
CableLiftUpdateDeparting();
|
||||||
break;
|
break;
|
||||||
case VEHICLE_STATUS_TRAVELLING:
|
case VEHICLE_STATUS_TRAVELLING:
|
||||||
cable_lift_update_travelling(this);
|
CableLiftUpdateTravelling();
|
||||||
break;
|
break;
|
||||||
case VEHICLE_STATUS_ARRIVING:
|
case VEHICLE_STATUS_ARRIVING:
|
||||||
cable_lift_update_arriving(this);
|
CableLiftUpdateArriving();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -119,71 +113,71 @@ void Vehicle::CableLiftUpdate()
|
|||||||
*
|
*
|
||||||
* rct2: 0x006DF8A4
|
* rct2: 0x006DF8A4
|
||||||
*/
|
*/
|
||||||
static void cable_lift_update_moving_to_end_of_station(Vehicle* vehicle)
|
void Vehicle::CableLiftUpdateMovingToEndOfStation()
|
||||||
{
|
{
|
||||||
if (vehicle->velocity >= -439800)
|
if (velocity >= -439800)
|
||||||
vehicle->acceleration = -2932;
|
acceleration = -2932;
|
||||||
|
|
||||||
if (vehicle->velocity < -439800)
|
if (velocity < -439800)
|
||||||
{
|
{
|
||||||
vehicle->velocity -= vehicle->velocity / 16;
|
velocity -= velocity / 16;
|
||||||
vehicle->acceleration = 0;
|
acceleration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cable_lift_update_track_motion(vehicle) & (1 << 0)))
|
if (!(cable_lift_update_track_motion(this) & VEHICLE_UPDATE_MOTION_TRACK_FLAG_VEHICLE_AT_STATION))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vehicle->velocity = 0;
|
velocity = 0;
|
||||||
vehicle->acceleration = 0;
|
acceleration = 0;
|
||||||
vehicle->SetState(VEHICLE_STATUS_WAITING_FOR_PASSENGERS, vehicle->sub_state);
|
SetState(VEHICLE_STATUS_WAITING_FOR_PASSENGERS, sub_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006DF8F1
|
* rct2: 0x006DF8F1
|
||||||
*/
|
*/
|
||||||
static void cable_lift_update_waiting_to_depart(Vehicle* vehicle)
|
void Vehicle::CableLiftUpdateWaitingToDepart()
|
||||||
{
|
{
|
||||||
if (vehicle->velocity >= -58640)
|
if (velocity >= -58640)
|
||||||
vehicle->acceleration = -14660;
|
acceleration = -14660;
|
||||||
|
|
||||||
if (vehicle->velocity < -58640)
|
if (velocity < -58640)
|
||||||
{
|
{
|
||||||
vehicle->velocity -= vehicle->velocity / 16;
|
velocity -= velocity / 16;
|
||||||
vehicle->acceleration = 0;
|
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
|
// Next check to see if the second part of the cable lift
|
||||||
// is at the front of the passenger vehicle to simulate the
|
// is at the front of the passenger vehicle to simulate the
|
||||||
// cable being attached underneath the train.
|
// cable being attached underneath the train.
|
||||||
Vehicle* passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
|
Vehicle* passengerVehicle = GET_VEHICLE(cable_lift_target);
|
||||||
Vehicle* cableLiftSecondPart = GET_VEHICLE(vehicle->prev_vehicle_on_ride);
|
Vehicle* cableLiftSecondPart = GET_VEHICLE(prev_vehicle_on_ride);
|
||||||
|
|
||||||
int16_t dist_x = abs(passengerVehicle->x - cableLiftSecondPart->x);
|
int16_t distX = abs(passengerVehicle->x - cableLiftSecondPart->x);
|
||||||
int16_t dist_y = abs(passengerVehicle->y - cableLiftSecondPart->y);
|
int16_t distY = abs(passengerVehicle->y - cableLiftSecondPart->y);
|
||||||
|
|
||||||
if (dist_x + dist_y > 2)
|
if (distX + distY > 2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vehicle->velocity = 0;
|
velocity = 0;
|
||||||
vehicle->acceleration = 0;
|
acceleration = 0;
|
||||||
vehicle->SetState(VEHICLE_STATUS_DEPARTING, 0);
|
SetState(VEHICLE_STATUS_DEPARTING, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006DF97A
|
* rct2: 0x006DF97A
|
||||||
*/
|
*/
|
||||||
static void cable_lift_update_departing(Vehicle* vehicle)
|
void Vehicle::CableLiftUpdateDeparting()
|
||||||
{
|
{
|
||||||
vehicle->sub_state++;
|
sub_state++;
|
||||||
if (vehicle->sub_state < 16)
|
if (sub_state < 16)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vehicle* passengerVehicle = GET_VEHICLE(vehicle->cable_lift_target);
|
Vehicle* passengerVehicle = GET_VEHICLE(cable_lift_target);
|
||||||
vehicle->SetState(VEHICLE_STATUS_TRAVELLING, vehicle->sub_state);
|
SetState(VEHICLE_STATUS_TRAVELLING, sub_state);
|
||||||
passengerVehicle->SetState(VEHICLE_STATUS_TRAVELLING_CABLE_LIFT, passengerVehicle->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
|
* 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);
|
velocity = std::min(passengerVehicle->velocity, 439800);
|
||||||
vehicle->acceleration = 0;
|
acceleration = 0;
|
||||||
if (passengerVehicle->update_flags & VEHICLE_UPDATE_FLAG_BROKEN_TRAIN)
|
if (passengerVehicle->update_flags & VEHICLE_UPDATE_FLAG_BROKEN_TRAIN)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!(cable_lift_update_track_motion(vehicle) & (1 << 1)))
|
if (!(cable_lift_update_track_motion(this) & VEHICLE_UPDATE_MOTION_TRACK_FLAG_1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vehicle->velocity = 0;
|
velocity = 0;
|
||||||
vehicle->acceleration = 0;
|
acceleration = 0;
|
||||||
vehicle->SetState(VEHICLE_STATUS_ARRIVING, 0);
|
SetState(VEHICLE_STATUS_ARRIVING, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006DF9F0
|
* rct2: 0x006DF9F0
|
||||||
*/
|
*/
|
||||||
static void cable_lift_update_arriving(Vehicle* vehicle)
|
void Vehicle::CableLiftUpdateArriving()
|
||||||
{
|
{
|
||||||
vehicle->sub_state++;
|
sub_state++;
|
||||||
if (vehicle->sub_state >= 64)
|
if (sub_state >= 64)
|
||||||
vehicle->SetState(VEHICLE_STATUS_MOVING_TO_END_OF_STATION, vehicle->sub_state);
|
SetState(VEHICLE_STATUS_MOVING_TO_END_OF_STATION, sub_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sub_6DF01A_loop(Vehicle* vehicle)
|
static bool sub_6DF01A_loop(Vehicle* vehicle)
|
||||||
|
|||||||
@@ -312,6 +312,11 @@ private:
|
|||||||
uint16_t GetSoundPriority() const;
|
uint16_t GetSoundPriority() const;
|
||||||
rct_vehicle_sound_params CreateSoundParam(uint16_t priority) const;
|
rct_vehicle_sound_params CreateSoundParam(uint16_t priority) const;
|
||||||
void CableLiftUpdate();
|
void CableLiftUpdate();
|
||||||
|
void CableLiftUpdateMovingToEndOfStation();
|
||||||
|
void CableLiftUpdateWaitingToDepart();
|
||||||
|
void CableLiftUpdateDeparting();
|
||||||
|
void CableLiftUpdateTravelling();
|
||||||
|
void CableLiftUpdateArriving();
|
||||||
void UpdateMovingToEndOfStation();
|
void UpdateMovingToEndOfStation();
|
||||||
void UpdateWaitingForPassengers();
|
void UpdateWaitingForPassengers();
|
||||||
void UpdateWaitingToDepart();
|
void UpdateWaitingToDepart();
|
||||||
|
|||||||
Reference in New Issue
Block a user