mirror of https://github.com/OpenRCT2/OpenRCT2.git
parent
e7625835c8
commit
bc5aac402a
|
@ -6813,9 +6813,9 @@ static void vehicle_update_block_brakes_open_previous_section(Vehicle* vehicle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vehicle_get_swing_amount(Vehicle* vehicle)
|
int32_t Vehicle::GetSwingAmount() const
|
||||||
{
|
{
|
||||||
int32_t trackType = vehicle->track_type >> 2;
|
int32_t trackType = track_type >> 2;
|
||||||
switch (trackType)
|
switch (trackType)
|
||||||
{
|
{
|
||||||
case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES:
|
case TRACK_ELEM_LEFT_QUARTER_TURN_5_TILES:
|
||||||
|
@ -6853,7 +6853,7 @@ static int32_t vehicle_get_swing_amount(Vehicle* vehicle)
|
||||||
case TRACK_ELEM_S_BEND_LEFT:
|
case TRACK_ELEM_S_BEND_LEFT:
|
||||||
case TRACK_ELEM_S_BEND_LEFT_COVERED:
|
case TRACK_ELEM_S_BEND_LEFT_COVERED:
|
||||||
// loc_6D67EF
|
// loc_6D67EF
|
||||||
if (vehicle->track_progress < 48)
|
if (track_progress < 48)
|
||||||
{
|
{
|
||||||
return 14;
|
return 14;
|
||||||
}
|
}
|
||||||
|
@ -6865,7 +6865,7 @@ static int32_t vehicle_get_swing_amount(Vehicle* vehicle)
|
||||||
case TRACK_ELEM_S_BEND_RIGHT:
|
case TRACK_ELEM_S_BEND_RIGHT:
|
||||||
case TRACK_ELEM_S_BEND_RIGHT_COVERED:
|
case TRACK_ELEM_S_BEND_RIGHT_COVERED:
|
||||||
// loc_6D67CC
|
// loc_6D67CC
|
||||||
if (vehicle->track_progress < 48)
|
if (track_progress < 48)
|
||||||
{
|
{
|
||||||
return -14;
|
return -14;
|
||||||
}
|
}
|
||||||
|
@ -6937,21 +6937,21 @@ static int32_t vehicle_get_swing_amount(Vehicle* vehicle)
|
||||||
*
|
*
|
||||||
* rct2: 0x006D6776
|
* rct2: 0x006D6776
|
||||||
*/
|
*/
|
||||||
static void vehicle_update_swinging_car(Vehicle* vehicle)
|
void Vehicle::UpdateSwingingCar()
|
||||||
{
|
{
|
||||||
int32_t dword_F64E08 = abs(_vehicleVelocityF64E08);
|
int32_t dword_F64E08 = abs(_vehicleVelocityF64E08);
|
||||||
vehicle->var_4E += (-vehicle->swinging_car_var_0) >> 6;
|
var_4E += (-swinging_car_var_0) >> 6;
|
||||||
int32_t swingAmount = vehicle_get_swing_amount(vehicle);
|
int32_t swingAmount = GetSwingAmount();
|
||||||
if (swingAmount < 0)
|
if (swingAmount < 0)
|
||||||
{
|
{
|
||||||
vehicle->var_4E -= dword_F64E08 >> (-swingAmount);
|
var_4E -= dword_F64E08 >> (-swingAmount);
|
||||||
}
|
}
|
||||||
else if (swingAmount > 0)
|
else if (swingAmount > 0)
|
||||||
{
|
{
|
||||||
vehicle->var_4E += dword_F64E08 >> swingAmount;
|
var_4E += dword_F64E08 >> swingAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vehicleEntry = vehicle->Entry();
|
auto vehicleEntry = Entry();
|
||||||
if (vehicleEntry == nullptr)
|
if (vehicleEntry == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -6972,7 +6972,7 @@ static void vehicle_update_swinging_car(Vehicle* vehicle)
|
||||||
dx = 5370;
|
dx = 5370;
|
||||||
cx = -5370;
|
cx = -5370;
|
||||||
|
|
||||||
int32_t trackType = vehicle->track_type >> 2;
|
int32_t trackType = track_type >> 2;
|
||||||
switch (trackType)
|
switch (trackType)
|
||||||
{
|
{
|
||||||
case TRACK_ELEM_BANKED_LEFT_QUARTER_TURN_5_TILES:
|
case TRACK_ELEM_BANKED_LEFT_QUARTER_TURN_5_TILES:
|
||||||
|
@ -7001,28 +7001,28 @@ static void vehicle_update_swinging_car(Vehicle* vehicle)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vehicle->update_flags & VEHICLE_UPDATE_FLAG_ON_LIFT_HILL)
|
if (update_flags & VEHICLE_UPDATE_FLAG_ON_LIFT_HILL)
|
||||||
{
|
{
|
||||||
dx = 0;
|
dx = 0;
|
||||||
cx = 0;
|
cx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vehicle->swinging_car_var_0 += vehicle->var_4E;
|
swinging_car_var_0 += var_4E;
|
||||||
vehicle->var_4E -= vehicle->var_4E >> 5;
|
var_4E -= var_4E >> 5;
|
||||||
int16_t ax = vehicle->swinging_car_var_0;
|
int16_t ax = swinging_car_var_0;
|
||||||
if (ax > dx)
|
if (ax > dx)
|
||||||
{
|
{
|
||||||
ax = dx;
|
ax = dx;
|
||||||
vehicle->var_4E = 0;
|
var_4E = 0;
|
||||||
}
|
}
|
||||||
if (ax < cx)
|
if (ax < cx)
|
||||||
{
|
{
|
||||||
ax = cx;
|
ax = cx;
|
||||||
vehicle->var_4E = 0;
|
var_4E = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
vehicle->swinging_car_var_0 = ax;
|
swinging_car_var_0 = ax;
|
||||||
uint8_t swingSprite = 11;
|
uint8_t swingSprite = 11;
|
||||||
if (ax >= -10012)
|
if (ax >= -10012)
|
||||||
{
|
{
|
||||||
|
@ -7072,10 +7072,10 @@ static void vehicle_update_swinging_car(Vehicle* vehicle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (swingSprite != vehicle->swing_sprite)
|
if (swingSprite != swing_sprite)
|
||||||
{
|
{
|
||||||
vehicle->swing_sprite = swingSprite;
|
swing_sprite = swingSprite;
|
||||||
vehicle->Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7127,21 +7127,21 @@ static const uint8_t TrackTypeToSpinFunction[256] = {
|
||||||
*
|
*
|
||||||
* rct2: 0x006D661F
|
* rct2: 0x006D661F
|
||||||
*/
|
*/
|
||||||
static void vehicle_update_spinning_car(Vehicle* vehicle)
|
void Vehicle::UpdateSpinningCar()
|
||||||
{
|
{
|
||||||
if (vehicle->update_flags & VEHICLE_UPDATE_FLAG_ROTATION_OFF_WILD_MOUSE)
|
if (update_flags & VEHICLE_UPDATE_FLAG_ROTATION_OFF_WILD_MOUSE)
|
||||||
{
|
{
|
||||||
vehicle->spin_speed = 0;
|
spin_speed = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vehicleEntry = vehicle->Entry();
|
auto vehicleEntry = Entry();
|
||||||
if (vehicleEntry == nullptr)
|
if (vehicleEntry == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int32_t spinningInertia = vehicleEntry->spinning_inertia;
|
int32_t spinningInertia = vehicleEntry->spinning_inertia;
|
||||||
int32_t trackType = vehicle->track_type >> 2;
|
int32_t trackType = track_type >> 2;
|
||||||
int32_t dword_F64E08 = _vehicleVelocityF64E08;
|
int32_t dword_F64E08 = _vehicleVelocityF64E08;
|
||||||
int32_t spinSpeed;
|
int32_t spinSpeed;
|
||||||
// An L spin adds to the spin speed, R does the opposite
|
// An L spin adds to the spin speed, R does the opposite
|
||||||
|
@ -7154,86 +7154,86 @@ static void vehicle_update_spinning_car(Vehicle* vehicle)
|
||||||
spinningInertia += 6;
|
spinningInertia += 6;
|
||||||
spinSpeed = dword_F64E08 >> spinningInertia;
|
spinSpeed = dword_F64E08 >> spinningInertia;
|
||||||
// Alternate the spin direction (roughly). Perhaps in future save a value to the track
|
// Alternate the spin direction (roughly). Perhaps in future save a value to the track
|
||||||
if (vehicle->sprite_index & 1)
|
if (sprite_index & 1)
|
||||||
{
|
{
|
||||||
vehicle->spin_speed -= spinSpeed;
|
spin_speed -= spinSpeed;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vehicle->spin_speed += spinSpeed;
|
spin_speed += spinSpeed;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R5_SPIN:
|
case R5_SPIN:
|
||||||
// It looks like in the original there was going to be special code for whirlpool
|
// It looks like in the original there was going to be special code for whirlpool
|
||||||
// this has been removed and just uses R5_SPIN
|
// this has been removed and just uses R5_SPIN
|
||||||
spinningInertia += 5;
|
spinningInertia += 5;
|
||||||
vehicle->spin_speed -= dword_F64E08 >> spinningInertia;
|
spin_speed -= dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case L5_SPIN:
|
case L5_SPIN:
|
||||||
spinningInertia += 5;
|
spinningInertia += 5;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case R7_SPIN:
|
case R7_SPIN:
|
||||||
spinningInertia += 7;
|
spinningInertia += 7;
|
||||||
vehicle->spin_speed -= dword_F64E08 >> spinningInertia;
|
spin_speed -= dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case L7_SPIN:
|
case L7_SPIN:
|
||||||
spinningInertia += 7;
|
spinningInertia += 7;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case RL_SPIN:
|
case RL_SPIN:
|
||||||
// Right Left Curve Track Piece
|
// Right Left Curve Track Piece
|
||||||
if (vehicle->track_progress < 48)
|
if (track_progress < 48)
|
||||||
{
|
{
|
||||||
// R8_SPIN
|
// R8_SPIN
|
||||||
spinningInertia += 8;
|
spinningInertia += 8;
|
||||||
vehicle->spin_speed -= dword_F64E08 >> spinningInertia;
|
spin_speed -= dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case L9_SPIN:
|
case L9_SPIN:
|
||||||
spinningInertia += 9;
|
spinningInertia += 9;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case L8_SPIN:
|
case L8_SPIN:
|
||||||
spinningInertia += 8;
|
spinningInertia += 8;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case SP_SPIN:
|
case SP_SPIN:
|
||||||
// On rapids spin after fully on them
|
// On rapids spin after fully on them
|
||||||
if (vehicle->track_progress > 22)
|
if (track_progress > 22)
|
||||||
{
|
{
|
||||||
// L5_SPIN
|
// L5_SPIN
|
||||||
spinningInertia += 5;
|
spinningInertia += 5;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LR_SPIN:
|
case LR_SPIN:
|
||||||
// Left Right Curve Track Piece
|
// Left Right Curve Track Piece
|
||||||
if (vehicle->track_progress < 48)
|
if (track_progress < 48)
|
||||||
{
|
{
|
||||||
// L8_SPIN
|
// L8_SPIN
|
||||||
spinningInertia += 8;
|
spinningInertia += 8;
|
||||||
vehicle->spin_speed += dword_F64E08 >> spinningInertia;
|
spin_speed += dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
[[fallthrough]];
|
[[fallthrough]];
|
||||||
case R9_SPIN:
|
case R9_SPIN:
|
||||||
spinningInertia += 9;
|
spinningInertia += 9;
|
||||||
vehicle->spin_speed -= dword_F64E08 >> spinningInertia;
|
spin_speed -= dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
case R8_SPIN:
|
case R8_SPIN:
|
||||||
spinningInertia += 8;
|
spinningInertia += 8;
|
||||||
vehicle->spin_speed -= dword_F64E08 >> spinningInertia;
|
spin_speed -= dword_F64E08 >> spinningInertia;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinSpeed = std::clamp(vehicle->spin_speed, VEHICLE_MIN_SPIN_SPEED, VEHICLE_MAX_SPIN_SPEED);
|
spinSpeed = std::clamp(spin_speed, VEHICLE_MIN_SPIN_SPEED, VEHICLE_MAX_SPIN_SPEED);
|
||||||
vehicle->spin_speed = spinSpeed;
|
spin_speed = spinSpeed;
|
||||||
vehicle->spin_sprite += spinSpeed >> 8;
|
spin_sprite += spinSpeed >> 8;
|
||||||
// Note this actually increases the spin speed if going right!
|
// Note this actually increases the spin speed if going right!
|
||||||
vehicle->spin_speed -= spinSpeed >> vehicleEntry->spinning_friction;
|
spin_speed -= spinSpeed >> vehicleEntry->spinning_friction;
|
||||||
vehicle->Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9609,12 +9609,12 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
|
||||||
// Swinging cars
|
// Swinging cars
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SWINGING)
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SWINGING)
|
||||||
{
|
{
|
||||||
vehicle_update_swinging_car(car);
|
car->UpdateSwingingCar();
|
||||||
}
|
}
|
||||||
// Spinning cars
|
// Spinning cars
|
||||||
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
if (vehicleEntry->flags & VEHICLE_ENTRY_FLAG_SPINNING)
|
||||||
{
|
{
|
||||||
vehicle_update_spinning_car(car);
|
car->UpdateSpinningCar();
|
||||||
}
|
}
|
||||||
// Rider sprites?? animation??
|
// Rider sprites?? animation??
|
||||||
if ((vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION)
|
if ((vehicleEntry->flags & VEHICLE_ENTRY_FLAG_VEHICLE_ANIMATION)
|
||||||
|
|
|
@ -388,6 +388,9 @@ private:
|
||||||
void ApplyStopBlockBrake();
|
void ApplyStopBlockBrake();
|
||||||
void CheckAndApplyBlockSectionStopSite();
|
void CheckAndApplyBlockSectionStopSite();
|
||||||
void UpdateVelocity();
|
void UpdateVelocity();
|
||||||
|
void UpdateSpinningCar();
|
||||||
|
void UpdateSwingingCar();
|
||||||
|
int32_t GetSwingAmount() const;
|
||||||
bool OpenRestraints();
|
bool OpenRestraints();
|
||||||
bool CloseRestraints();
|
bool CloseRestraints();
|
||||||
void CrashOnWater();
|
void CrashOnWater();
|
||||||
|
|
Loading…
Reference in New Issue