1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-18 04:23:20 +01:00

rename vehicle position variables (#15370)

This commit is contained in:
spacek531
2022-02-24 23:21:45 -08:00
committed by GitHub
parent 2ef5265ead
commit 466c8b4b89
5 changed files with 113 additions and 108 deletions

View File

@@ -266,21 +266,21 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
track_progress = trackProgress;
const auto moveInfo = GetMoveInfo();
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
auto nextVehiclePosition = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
uint8_t bx = 0;
unk.z += GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset;
if (unk.x != unk_F64E20.x)
bx |= (1 << 0);
if (unk.y != unk_F64E20.y)
bx |= (1 << 1);
if (unk.z != unk_F64E20.z)
bx |= (1 << 2);
uint8_t remainingDistanceFlags = 0;
nextVehiclePosition.z += GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset;
if (nextVehiclePosition.x != _vehicleCurPosition.x)
remainingDistanceFlags |= (1 << 0);
if (nextVehiclePosition.y != _vehicleCurPosition.y)
remainingDistanceFlags |= (1 << 1);
if (nextVehiclePosition.z != _vehicleCurPosition.z)
remainingDistanceFlags |= (1 << 2);
remaining_distance -= dword_9A2930[bx];
unk_F64E20.x = unk.x;
unk_F64E20.y = unk.y;
unk_F64E20.z = unk.z;
remaining_distance -= SubpositionTranslationDistances[remainingDistanceFlags];
_vehicleCurPosition.x = nextVehiclePosition.x;
_vehicleCurPosition.y = nextVehiclePosition.y;
_vehicleCurPosition.z = nextVehiclePosition.z;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
@@ -288,7 +288,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
if (remaining_distance >= 13962)
{
acceleration += dword_9A2970[Pitch];
acceleration += AccelerationFromPitch[Pitch];
}
}
return true;
@@ -334,19 +334,19 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
const auto moveInfo = GetMoveInfo();
auto unk = CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z } + TrackLocation;
uint8_t bx = 0;
uint8_t remainingDistanceFlags = 0;
unk.z += GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset;
if (unk.x != unk_F64E20.x)
bx |= (1 << 0);
if (unk.y != unk_F64E20.y)
bx |= (1 << 1);
if (unk.z != unk_F64E20.z)
bx |= (1 << 2);
if (unk.x != _vehicleCurPosition.x)
remainingDistanceFlags |= (1 << 0);
if (unk.y != _vehicleCurPosition.y)
remainingDistanceFlags |= (1 << 1);
if (unk.z != _vehicleCurPosition.z)
remainingDistanceFlags |= (1 << 2);
remaining_distance += dword_9A2930[bx];
unk_F64E20.x = unk.x;
unk_F64E20.y = unk.y;
unk_F64E20.z = unk.z;
remaining_distance += SubpositionTranslationDistances[remainingDistanceFlags];
_vehicleCurPosition.x = unk.x;
_vehicleCurPosition.y = unk.y;
_vehicleCurPosition.z = unk.z;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
@@ -354,7 +354,7 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
if (remaining_distance < 0)
{
acceleration += dword_9A2970[Pitch];
acceleration += AccelerationFromPitch[Pitch];
}
}
return true;
@@ -385,13 +385,13 @@ int32_t Vehicle::CableLiftUpdateTrackMotion()
for (Vehicle* vehicle = frontVehicle; vehicle != nullptr;)
{
vehicle->acceleration = dword_9A2970[vehicle->Pitch];
vehicle->acceleration = AccelerationFromPitch[vehicle->Pitch];
_vehicleUnkF64E10 = 1;
vehicle->remaining_distance += _vehicleVelocityF64E0C;
if (vehicle->remaining_distance < 0 || vehicle->remaining_distance >= 13962)
{
unk_F64E20 = vehicle->GetLocation();
_vehicleCurPosition = vehicle->GetLocation();
vehicle->Invalidate();
while (true)
@@ -406,7 +406,7 @@ int32_t Vehicle::CableLiftUpdateTrackMotion()
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
_vehicleVelocityF64E0C -= vehicle->remaining_distance - 13962;
vehicle->remaining_distance = 13962;
vehicle->acceleration += dword_9A2970[vehicle->Pitch];
vehicle->acceleration += AccelerationFromPitch[vehicle->Pitch];
_vehicleUnkF64E10++;
continue;
}
@@ -419,10 +419,10 @@ int32_t Vehicle::CableLiftUpdateTrackMotion()
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_5;
_vehicleVelocityF64E0C -= vehicle->remaining_distance + 1;
vehicle->remaining_distance = -1;
vehicle->acceleration += dword_9A2970[vehicle->Pitch];
vehicle->acceleration += AccelerationFromPitch[vehicle->Pitch];
_vehicleUnkF64E10++;
}
vehicle->MoveTo(unk_F64E20);
vehicle->MoveTo(_vehicleCurPosition);
}
vehicle->acceleration /= _vehicleUnkF64E10;
if (_vehicleVelocityF64E08 >= 0)

View File

@@ -72,7 +72,7 @@ int32_t _vehicleVelocityF64E0C;
int32_t _vehicleUnkF64E10;
uint8_t _vehicleF64E2C;
Vehicle* _vehicleFrontVehicle;
CoordsXYZ unk_F64E20;
CoordsXYZ _vehicleCurPosition;
static constexpr const OpenRCT2::Audio::SoundId _screamSet0[] = {
OpenRCT2::Audio::SoundId::Scream8,
@@ -4229,8 +4229,8 @@ void Vehicle::TryReconnectBoatToTrack(const CoordsXY& currentBoatLocation, const
track_progress = 0;
SetState(Vehicle::Status::Travelling, sub_state);
unk_F64E20.x = currentBoatLocation.x;
unk_F64E20.y = currentBoatLocation.y;
_vehicleCurPosition.x = currentBoatLocation.x;
_vehicleCurPosition.y = currentBoatLocation.y;
}
}
@@ -4261,7 +4261,7 @@ void Vehicle::UpdateMotionBoatHire()
if (remaining_distance >= 0x368A)
{
sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20 = GetLocation();
_vehicleCurPosition = GetLocation();
Invalidate();
for (;;)
@@ -4428,7 +4428,7 @@ void Vehicle::UpdateMotionBoatHire()
TryReconnectBoatToTrack(loc2, flooredLocation);
break;
}
loc2 = unk_F64E20;
loc2 = _vehicleCurPosition;
if (tilePart <= COORDS_XY_HALF_TILE)
{
loc2.y += 1;
@@ -4447,7 +4447,7 @@ void Vehicle::UpdateMotionBoatHire()
TryReconnectBoatToTrack(loc2, flooredLocation);
break;
}
loc2 = unk_F64E20;
loc2 = _vehicleCurPosition;
if (tilePart <= COORDS_XY_HALF_TILE)
{
loc2.x += 1;
@@ -4462,8 +4462,8 @@ void Vehicle::UpdateMotionBoatHire()
remaining_distance = 0;
if (!UpdateMotionCollisionDetection({ loc2, z }, nullptr))
{
unk_F64E20.x = loc2.x;
unk_F64E20.y = loc2.y;
_vehicleCurPosition.x = loc2.x;
_vehicleCurPosition.y = loc2.y;
}
break;
}
@@ -4471,8 +4471,8 @@ void Vehicle::UpdateMotionBoatHire()
}
remaining_distance -= Unk9A36C4[edi].distance;
unk_F64E20.x = loc2.x;
unk_F64E20.y = loc2.y;
_vehicleCurPosition.x = loc2.x;
_vehicleCurPosition.y = loc2.y;
if (remaining_distance < 0x368A)
{
break;
@@ -4480,7 +4480,7 @@ void Vehicle::UpdateMotionBoatHire()
_vehicleUnkF64E10++;
}
MoveTo(unk_F64E20);
MoveTo(_vehicleCurPosition);
}
// loc_6DAAC9:
@@ -6286,9 +6286,9 @@ int32_t Vehicle::UpdateMotionDodgems()
if (remaining_distance >= 13962)
{
sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20.x = x;
unk_F64E20.y = y;
unk_F64E20.z = z;
_vehicleCurPosition.x = x;
_vehicleCurPosition.y = y;
_vehicleCurPosition.z = z;
while (true)
{
@@ -6296,7 +6296,7 @@ int32_t Vehicle::UpdateMotionDodgems()
uint8_t direction = sprite_direction;
direction |= var_35 & 1;
CoordsXY location = unk_F64E20;
CoordsXY location = _vehicleCurPosition;
location.x += Unk9A36C4[direction].x;
location.y += Unk9A36C4[direction].y;
@@ -6306,8 +6306,8 @@ int32_t Vehicle::UpdateMotionDodgems()
}
remaining_distance -= Unk9A36C4[direction].distance;
unk_F64E20.x = location.x;
unk_F64E20.y = location.y;
_vehicleCurPosition.x = location.x;
_vehicleCurPosition.y = location.y;
if (remaining_distance < 13962)
{
break;
@@ -6344,7 +6344,7 @@ int32_t Vehicle::UpdateMotionDodgems()
}
}
MoveTo(unk_F64E20);
MoveTo(_vehicleCurPosition);
}
int32_t eax = velocity / 2;
@@ -6464,7 +6464,7 @@ void Vehicle::UpdateTrackMotionUpStopCheck() const
gForces.LateralG = std::abs(gForces.LateralG);
if (gForces.LateralG <= 150)
{
if (dword_9A2970[Pitch] < 0)
if (AccelerationFromPitch[Pitch] < 0)
{
if (gForces.VerticalG > -40)
{
@@ -6491,7 +6491,7 @@ void Vehicle::UpdateTrackMotionUpStopCheck() const
{
auto gForces = GetGForces();
if (dword_9A2970[Pitch] < 0)
if (AccelerationFromPitch[Pitch] < 0)
{
if (gForces.VerticalG > -45)
{
@@ -7461,7 +7461,8 @@ static void vehicle_update_play_water_splash_sound()
return;
}
OpenRCT2::Audio::Play3D(OpenRCT2::Audio::SoundId::WaterSplash, { unk_F64E20.x, unk_F64E20.y, unk_F64E20.z });
OpenRCT2::Audio::Play3D(
OpenRCT2::Audio::SoundId::WaterSplash, { _vehicleCurPosition.x, _vehicleCurPosition.y, _vehicleCurPosition.z });
}
/**
@@ -8148,19 +8149,19 @@ loc_6DAEB9:
trackType = GetTrackType();
uint8_t moveInfovehicleSpriteType;
{
auto loc = TrackLocation
auto nextVehiclePosition = TrackLocation
+ CoordsXYZ{ moveInfo->x, moveInfo->y, moveInfo->z + GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset };
uint8_t remainingDistanceFlags = 0;
if (loc.x != unk_F64E20.x)
if (nextVehiclePosition.x != _vehicleCurPosition.x)
{
remainingDistanceFlags |= 1;
}
if (loc.y != unk_F64E20.y)
if (nextVehiclePosition.y != _vehicleCurPosition.y)
{
remainingDistanceFlags |= 2;
}
if (loc.z != unk_F64E20.z)
if (nextVehiclePosition.z != _vehicleCurPosition.z)
{
remainingDistanceFlags |= 4;
}
@@ -8178,13 +8179,13 @@ loc_6DAEB9:
ReverseReverserCar();
const rct_vehicle_info* moveInfo2 = GetMoveInfo();
loc.x = x + moveInfo2->x;
loc.y = y + moveInfo2->y;
nextVehiclePosition.x = x + moveInfo2->x;
nextVehiclePosition.y = y + moveInfo2->y;
}
// loc_6DB8A5
remaining_distance -= dword_9A2930[remainingDistanceFlags];
unk_F64E20 = loc;
remaining_distance -= SubpositionTranslationDistances[remainingDistanceFlags];
_vehicleCurPosition = nextVehiclePosition;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
Pitch = moveInfo->Pitch;
@@ -8204,7 +8205,7 @@ loc_6DAEB9:
if (_vehicleVelocityF64E08 >= 0)
{
otherVehicleIndex = prev_vehicle_on_ride;
if (UpdateMotionCollisionDetection(loc, &otherVehicleIndex))
if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex))
{
_vehicleVelocityF64E0C -= remaining_distance + 1;
remaining_distance = -1;
@@ -8254,7 +8255,7 @@ loc_6DAEB9:
return true;
}
acceleration += dword_9A2970[moveInfovehicleSpriteType];
acceleration += AccelerationFromPitch[moveInfovehicleSpriteType];
_vehicleUnkF64E10++;
goto loc_6DAEB9;
}
@@ -8478,26 +8479,26 @@ bool Vehicle::UpdateTrackMotionBackwards(rct_ride_entry_vehicle* vehicleEntry, R
uint8_t moveInfoVehicleSpriteType;
{
const rct_vehicle_info* moveInfo = GetMoveInfo();
auto loc = TrackLocation
auto nextVehiclePosition = TrackLocation
+ CoordsXYZ{ moveInfo->x, moveInfo->y,
moveInfo->z + GetRideTypeDescriptor(curRide->type).Heights.VehicleZOffset };
uint8_t remainingDistanceFlags = 0;
if (loc.x != unk_F64E20.x)
if (nextVehiclePosition.x != _vehicleCurPosition.x)
{
remainingDistanceFlags |= 1;
}
if (loc.y != unk_F64E20.y)
if (nextVehiclePosition.y != _vehicleCurPosition.y)
{
remainingDistanceFlags |= 2;
}
if (loc.z != unk_F64E20.z)
if (nextVehiclePosition.z != _vehicleCurPosition.z)
{
remainingDistanceFlags |= 4;
}
remaining_distance += dword_9A2930[remainingDistanceFlags];
remaining_distance += SubpositionTranslationDistances[remainingDistanceFlags];
unk_F64E20 = loc;
_vehicleCurPosition = nextVehiclePosition;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
Pitch = moveInfo->Pitch;
@@ -8515,7 +8516,7 @@ bool Vehicle::UpdateTrackMotionBackwards(rct_ride_entry_vehicle* vehicleEntry, R
if (_vehicleVelocityF64E08 < 0)
{
otherVehicleIndex = next_vehicle_on_ride;
if (UpdateMotionCollisionDetection(loc, &otherVehicleIndex))
if (UpdateMotionCollisionDetection(nextVehiclePosition, &otherVehicleIndex))
{
_vehicleVelocityF64E0C -= remaining_distance - 0x368A;
remaining_distance = 0x368A;
@@ -8562,7 +8563,7 @@ bool Vehicle::UpdateTrackMotionBackwards(rct_ride_entry_vehicle* vehicleEntry, R
{
return true;
}
acceleration += dword_9A2970[moveInfoVehicleSpriteType];
acceleration += AccelerationFromPitch[moveInfoVehicleSpriteType];
_vehicleUnkF64E10++;
}
}
@@ -8580,7 +8581,7 @@ void Vehicle::UpdateTrackMotionMiniGolfVehicle(Ride* curRide, rct_ride_entry* ri
int32_t direction{};
_vehicleUnkF64E10 = 1;
acceleration = dword_9A2970[Pitch];
acceleration = AccelerationFromPitch[Pitch];
if (!HasUpdateFlag(VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION))
{
remaining_distance = _vehicleVelocityF64E0C + remaining_distance;
@@ -8590,9 +8591,9 @@ void Vehicle::UpdateTrackMotionMiniGolfVehicle(Ride* curRide, rct_ride_entry* ri
goto loc_6DCE02;
}
sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20.x = x;
unk_F64E20.y = y;
unk_F64E20.z = z;
_vehicleCurPosition.x = x;
_vehicleCurPosition.y = y;
_vehicleCurPosition.z = z;
Invalidate();
if (remaining_distance < 0)
goto loc_6DCA9A;
@@ -8854,7 +8855,7 @@ loc_6DC743:
remaining_distance = 0;
}
unk_F64E20 = trackPos;
_vehicleCurPosition = trackPos;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
Pitch = moveInfo->Pitch;
@@ -8891,7 +8892,7 @@ loc_6DC99A:
{
goto loc_6DCDE4;
}
acceleration = dword_9A2970[Pitch];
acceleration = AccelerationFromPitch[Pitch];
_vehicleUnkF64E10++;
goto loc_6DC462;
@@ -8970,7 +8971,7 @@ loc_6DCC2C:
remaining_distance = 0;
}
unk_F64E20 = trackPos;
_vehicleCurPosition = trackPos;
sprite_direction = moveInfo->direction;
bank_rotation = moveInfo->bank_rotation;
Pitch = moveInfo->Pitch;
@@ -9002,7 +9003,7 @@ loc_6DCD2B:
{
goto loc_6DCDE4;
}
acceleration += dword_9A2970[Pitch];
acceleration += AccelerationFromPitch[Pitch];
_vehicleUnkF64E10++;
goto loc_6DCA9A;
@@ -9036,7 +9037,7 @@ loc_6DCD6B:
goto loc_6DC99A;
loc_6DCDE4:
MoveTo(unk_F64E20);
MoveTo(_vehicleCurPosition);
loc_6DCE02:
acceleration /= _vehicleUnkF64E10;
@@ -9412,7 +9413,7 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
{
car->UpdateAdditionalAnimation();
}
car->acceleration = dword_9A2970[car->Pitch];
car->acceleration = AccelerationFromPitch[car->Pitch];
_vehicleUnkF64E10 = 1;
if (!car->HasUpdateFlag(VEHICLE_UPDATE_FLAG_SINGLE_CAR_POSITION))
@@ -9421,9 +9422,9 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
}
car->sound2_flags &= ~VEHICLE_SOUND2_FLAGS_LIFT_HILL;
unk_F64E20.x = car->x;
unk_F64E20.y = car->y;
unk_F64E20.z = car->z;
_vehicleCurPosition.x = car->x;
_vehicleCurPosition.y = car->y;
_vehicleCurPosition.z = car->z;
car->Invalidate();
while (true)
@@ -9440,7 +9441,7 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
{
break;
}
car->acceleration += dword_9A2970[car->Pitch];
car->acceleration += AccelerationFromPitch[car->Pitch];
_vehicleUnkF64E10++;
continue;
}
@@ -9458,12 +9459,12 @@ int32_t Vehicle::UpdateTrackMotion(int32_t* outStation)
{
break;
}
car->acceleration = dword_9A2970[car->Pitch];
car->acceleration = AccelerationFromPitch[car->Pitch];
_vehicleUnkF64E10++;
continue;
}
// loc_6DBF20
car->MoveTo(unk_F64E20);
car->MoveTo(_vehicleCurPosition);
loc_6DBF3E:
car->Sub6DBF3E();

View File

@@ -530,4 +530,4 @@ extern int32_t _vehicleVelocityF64E0C;
extern int32_t _vehicleUnkF64E10;
extern uint8_t _vehicleF64E2C;
extern Vehicle* _vehicleFrontVehicle;
extern CoordsXYZ unk_F64E20;
extern CoordsXYZ _vehicleCurPosition;

View File

@@ -795,28 +795,32 @@ const uint8_t MotionSimulatorTimeToSpriteMap[] = {
const int32_t MotionSimulatorTimeToSpriteMapCount = static_cast<int32_t>(std::size(MotionSimulatorTimeToSpriteMap));
/** rct2: 0x009A2930 */
const int32_t dword_9A2930[] = {
0, // 0000
8716, // 0001
8716, // 0010
12327, // 0011
6554, // 0100
10905, // 0101
10905, // 0110
13961, // 0111
0, // 1000
21790, // 1001
21790, // 1010
30817, // 1011
16385, // 1100
27262, // 1101
27262, // 1110
34902, // 1111
/** rct2: 0x009A2930
The distance between subposition points in a movement direction (but not distance).
*/
const int32_t SubpositionTranslationDistances[] = {
// For a base length of 8716 (0x220C) on the horizontal and 6554 (0x199A) on the vertical, use the Pythagoras theorem and round up.
0, // no movement
8716, // X translation
8716, // Y translation
12327, // XY translation
6554, // Z translation
10905, // XZ translation
10905, // YZ translation
13961, // XYZ translation
// For the reverser car, multiply the horizontal distance by 2.5 and the vertical distance by 4.072.
0, // no movement
21790, // X translation
21790, // Y translation
30817, // Z translation
16385, // XY translation
27262, // XZ translation
27262, // YZ translation
34902, // XYZ translation
};
/** rct2: 0x009A2970 */
const int32_t dword_9A2970[] = {
const int32_t AccelerationFromPitch[] = {
0, // 0
-124548, // 1
-243318, // 2

View File

@@ -26,7 +26,7 @@ extern const top_spin_time_to_sprite_map* TopSpinTimeToSpriteMaps[];
extern const uint8_t MotionSimulatorTimeToSpriteMap[];
extern const int32_t MotionSimulatorTimeToSpriteMapCount;
extern const int32_t dword_9A2930[];
extern const int32_t dword_9A2970[];
extern const int32_t SubpositionTranslationDistances[];
extern const int32_t AccelerationFromPitch[];
extern const int32_t SpriteDirectionToSoundDirection[];