mirror of https://github.com/OpenRCT2/OpenRCT2.git
Remove global _vehicleVAngleAndBank
This commit is contained in:
parent
affa0dd30b
commit
23cf4b580e
|
@ -233,7 +233,6 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
|
||||||
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
uint16_t trackTotalProgress = vehicle_get_move_info_size(TrackSubposition, track_type);
|
||||||
if (trackProgress >= trackTotalProgress)
|
if (trackProgress >= trackTotalProgress)
|
||||||
{
|
{
|
||||||
_vehicleVAngleAndBank = VAngleAndBankEnd(trackType);
|
|
||||||
TileElement* trackElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
TileElement* trackElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
||||||
|
|
||||||
CoordsXYE output;
|
CoordsXYE output;
|
||||||
|
@ -245,7 +244,7 @@ bool Vehicle::CableLiftUpdateTrackMotionForwards()
|
||||||
if (!track_block_get_next(&input, &output, &outputZ, &outputDirection))
|
if (!track_block_get_next(&input, &output, &outputZ, &outputDirection))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_vehicleVAngleAndBank != VAngleAndBankStart(output.element->AsTrack()->GetTrackType()))
|
if (track_vangle_and_bank_end(trackType) != track_vangle_and_bank_start(output.element->AsTrack()->GetTrackType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TrackLocation = { output, outputZ };
|
TrackLocation = { output, outputZ };
|
||||||
|
@ -298,8 +297,6 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
|
||||||
if (static_cast<int16_t>(trackProgress) == -1)
|
if (static_cast<int16_t>(trackProgress) == -1)
|
||||||
{
|
{
|
||||||
uint8_t trackType = GetTrackType();
|
uint8_t trackType = GetTrackType();
|
||||||
_vehicleVAngleAndBank = VAngleAndBankStart(trackType);
|
|
||||||
|
|
||||||
TileElement* trackElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
TileElement* trackElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
||||||
|
|
||||||
auto input = CoordsXYE{ TrackLocation, trackElement };
|
auto input = CoordsXYE{ TrackLocation, trackElement };
|
||||||
|
@ -308,7 +305,8 @@ bool Vehicle::CableLiftUpdateTrackMotionBackwards()
|
||||||
if (!track_block_get_previous(input, &output))
|
if (!track_block_get_previous(input, &output))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_vehicleVAngleAndBank != VAngleAndBankEnd(output.begin_element->AsTrack()->GetTrackType()))
|
if (track_vangle_and_bank_start(trackType)
|
||||||
|
!= track_vangle_and_bank_end(output.begin_element->AsTrack()->GetTrackType()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
TrackLocation = { output.begin_x, output.begin_y, output.begin_z };
|
TrackLocation = { output.begin_x, output.begin_y, output.begin_z };
|
||||||
|
|
|
@ -560,6 +560,16 @@ const rct_trackdefinition FlatRideTrackDefinitions[256] =
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
VAngleAndBank track_vangle_and_bank_start(uint8_t trackType)
|
||||||
|
{
|
||||||
|
return { TrackDefinitions[trackType].vangle_start, TrackDefinitions[trackType].bank_start };
|
||||||
|
}
|
||||||
|
|
||||||
|
VAngleAndBank track_vangle_and_bank_end(uint8_t trackType)
|
||||||
|
{
|
||||||
|
return { TrackDefinitions[trackType].vangle_end, TrackDefinitions[trackType].bank_end };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to determine if a connects to b by its bank and angle, not location.
|
* Helper method to determine if a connects to b by its bank and angle, not location.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -33,6 +33,20 @@ struct rct_trackdefinition
|
||||||
assert_struct_size(rct_trackdefinition, 8);
|
assert_struct_size(rct_trackdefinition, 8);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct VAngleAndBank
|
||||||
|
{
|
||||||
|
uint8_t VAngle;
|
||||||
|
uint8_t Bank;
|
||||||
|
};
|
||||||
|
bool operator==(const VAngleAndBank& vb1, const VAngleAndBank& vb2)
|
||||||
|
{
|
||||||
|
return vb1.VAngle == vb2.VAngle && vb1.Bank == vb2.Bank;
|
||||||
|
}
|
||||||
|
bool operator!=(const VAngleAndBank& vb1, const VAngleAndBank& vb2)
|
||||||
|
{
|
||||||
|
return !(vb1 == vb2);
|
||||||
|
}
|
||||||
|
|
||||||
/* size 0x0A */
|
/* size 0x0A */
|
||||||
struct rct_preview_track
|
struct rct_preview_track
|
||||||
{
|
{
|
||||||
|
@ -538,6 +552,9 @@ struct track_circuit_iterator
|
||||||
extern const rct_trackdefinition FlatRideTrackDefinitions[256];
|
extern const rct_trackdefinition FlatRideTrackDefinitions[256];
|
||||||
extern const rct_trackdefinition TrackDefinitions[256];
|
extern const rct_trackdefinition TrackDefinitions[256];
|
||||||
|
|
||||||
|
VAngleAndBank track_vangle_and_bank_start(uint8_t trackType);
|
||||||
|
VAngleAndBank track_vangle_and_bank_end(uint8_t trackType);
|
||||||
|
|
||||||
int32_t track_is_connected_by_shape(TileElement* a, TileElement* b);
|
int32_t track_is_connected_by_shape(TileElement* a, TileElement* b);
|
||||||
|
|
||||||
const rct_preview_track* get_track_def_from_ride(Ride* ride, int32_t trackType);
|
const rct_preview_track* get_track_def_from_ride(Ride* ride, int32_t trackType);
|
||||||
|
|
|
@ -65,7 +65,6 @@ uint32_t _vehicleMotionTrackFlags;
|
||||||
int32_t _vehicleVelocityF64E08;
|
int32_t _vehicleVelocityF64E08;
|
||||||
int32_t _vehicleVelocityF64E0C;
|
int32_t _vehicleVelocityF64E0C;
|
||||||
int32_t _vehicleUnkF64E10;
|
int32_t _vehicleUnkF64E10;
|
||||||
VAngleAndBank _vehicleVAngleAndBank;
|
|
||||||
uint8_t _vehicleF64E2C;
|
uint8_t _vehicleF64E2C;
|
||||||
Vehicle* _vehicleFrontVehicle;
|
Vehicle* _vehicleFrontVehicle;
|
||||||
CoordsXYZ unk_F64E20;
|
CoordsXYZ unk_F64E20;
|
||||||
|
@ -7480,7 +7479,7 @@ static void vehicle_update_scenery_door(Vehicle* vehicle)
|
||||||
*
|
*
|
||||||
* rct2: 0x006DB38B
|
* rct2: 0x006DB38B
|
||||||
*/
|
*/
|
||||||
static VAngleAndBank VehicleVAngleAndBankStart(bool useInvertedSprites, TileElement* tileElement)
|
static VAngleAndBank VAngleAndBankStart(bool useInvertedSprites, TileElement* tileElement)
|
||||||
{
|
{
|
||||||
int32_t trackType = tileElement->AsTrack()->GetTrackType();
|
int32_t trackType = tileElement->AsTrack()->GetTrackType();
|
||||||
return VAngleAndBank{ TrackDefinitions[trackType].vangle_start, track_get_actual_bank_3(useInvertedSprites, tileElement) };
|
return VAngleAndBank{ TrackDefinitions[trackType].vangle_start, track_get_actual_bank_3(useInvertedSprites, tileElement) };
|
||||||
|
@ -7930,17 +7929,6 @@ static void sub_6DBF3E(Vehicle* vehicle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO move these to Track.cpp
|
|
||||||
VAngleAndBank VAngleAndBankStart(uint8_t trackType)
|
|
||||||
{
|
|
||||||
return { TrackDefinitions[trackType].vangle_start, TrackDefinitions[trackType].bank_start };
|
|
||||||
}
|
|
||||||
|
|
||||||
VAngleAndBank VAngleAndBankEnd(uint8_t trackType)
|
|
||||||
{
|
|
||||||
return { TrackDefinitions[trackType].vangle_end, TrackDefinitions[trackType].bank_end };
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* rct2: 0x006DB08C
|
* rct2: 0x006DB08C
|
||||||
|
@ -7949,7 +7937,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* cur
|
||||||
{
|
{
|
||||||
CoordsXYZD location = {};
|
CoordsXYZD location = {};
|
||||||
|
|
||||||
_vehicleVAngleAndBank = VAngleAndBankEnd(trackType);
|
auto vangleAndBankEnd = track_vangle_and_bank_end(trackType);
|
||||||
TileElement* tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
TileElement* tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
||||||
|
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
|
@ -8037,8 +8025,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* cur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VehicleVAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement)
|
if (VAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement) != vangleAndBankEnd)
|
||||||
!= _vehicleVAngleAndBank)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8371,8 +8358,7 @@ loc_6DB967:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VAngleAndBank VehicleVAngleAndBankEnd(
|
static VAngleAndBank VAngleAndBankEnd(Ride* curRide, bool useInvertedSprites, uint16_t trackType, TileElement* tileElement)
|
||||||
Ride* curRide, bool useInvertedSprites, uint16_t trackType, TileElement* tileElement)
|
|
||||||
{
|
{
|
||||||
bool isInverted = useInvertedSprites ^ tileElement->AsTrack()->IsInverted();
|
bool isInverted = useInvertedSprites ^ tileElement->AsTrack()->IsInverted();
|
||||||
return { TrackDefinitions[trackType].vangle_end,
|
return { TrackDefinitions[trackType].vangle_end,
|
||||||
|
@ -8385,7 +8371,7 @@ static VAngleAndBank VehicleVAngleAndBankEnd(
|
||||||
*/
|
*/
|
||||||
bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* curRide, uint16_t* progress)
|
bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* curRide, uint16_t* progress)
|
||||||
{
|
{
|
||||||
_vehicleVAngleAndBank = VAngleAndBankStart(trackType);
|
auto vangleAndBankStart = track_vangle_and_bank_start(trackType);
|
||||||
TileElement* tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
TileElement* tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
||||||
|
|
||||||
if (tileElement == nullptr)
|
if (tileElement == nullptr)
|
||||||
|
@ -8430,8 +8416,8 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* cu
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VehicleVAngleAndBankEnd(curRide, HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), trackType, tileElement)
|
if (VAngleAndBankEnd(curRide, HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), trackType, tileElement)
|
||||||
!= _vehicleVAngleAndBank)
|
!= vangleAndBankStart)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8803,11 +8789,8 @@ loc_6DC476:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
auto vangleAndBankEnd = track_vangle_and_bank_end(GetTrackType());
|
||||||
uint16_t trackType = GetTrackType();
|
tileElement = map_get_track_element_at_of_type_seq(TrackLocation, GetTrackType(), 0);
|
||||||
_vehicleVAngleAndBank = VAngleAndBankEnd(trackType);
|
|
||||||
tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
|
||||||
}
|
|
||||||
int32_t direction;
|
int32_t direction;
|
||||||
{
|
{
|
||||||
CoordsXYE output;
|
CoordsXYE output;
|
||||||
|
@ -8822,8 +8805,7 @@ loc_6DC476:
|
||||||
direction = outDirection;
|
direction = outDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VehicleVAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement)
|
if (VAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement) != vangleAndBankEnd)
|
||||||
!= _vehicleVAngleAndBank)
|
|
||||||
{
|
{
|
||||||
goto loc_6DC9BC;
|
goto loc_6DC9BC;
|
||||||
}
|
}
|
||||||
|
@ -9017,12 +8999,8 @@ loc_6DCA9A:
|
||||||
goto loc_6DCC2C;
|
goto loc_6DCC2C;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
auto vangleAndBankEnd = track_vangle_and_bank_end(GetTrackType());
|
||||||
uint16_t trackType = GetTrackType();
|
tileElement = map_get_track_element_at_of_type_seq(TrackLocation, GetTrackType(), 0);
|
||||||
_vehicleVAngleAndBank = VAngleAndBankEnd(trackType);
|
|
||||||
|
|
||||||
tileElement = map_get_track_element_at_of_type_seq(TrackLocation, trackType, 0);
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
track_begin_end trackBeginEnd;
|
track_begin_end trackBeginEnd;
|
||||||
if (!track_block_get_previous({ TrackLocation, tileElement }, &trackBeginEnd))
|
if (!track_block_get_previous({ TrackLocation, tileElement }, &trackBeginEnd))
|
||||||
|
@ -9034,8 +9012,7 @@ loc_6DCA9A:
|
||||||
tileElement = trackBeginEnd.begin_element;
|
tileElement = trackBeginEnd.begin_element;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VehicleVAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement)
|
if (VAngleAndBankStart(HasUpdateFlag(VEHICLE_UPDATE_FLAG_USE_INVERTED_SPRITES), tileElement) != vangleAndBankEnd)
|
||||||
!= _vehicleVAngleAndBank)
|
|
||||||
{
|
{
|
||||||
goto loc_6DCD4A;
|
goto loc_6DCD4A;
|
||||||
}
|
}
|
||||||
|
|
|
@ -608,21 +608,6 @@ enum
|
||||||
SOUND_RANGE_NONE = 255
|
SOUND_RANGE_NONE = 255
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO move these to Track.h
|
|
||||||
struct VAngleAndBank
|
|
||||||
{
|
|
||||||
uint8_t VAngle;
|
|
||||||
uint8_t Bank;
|
|
||||||
};
|
|
||||||
bool operator==(const VAngleAndBank& vb1, const VAngleAndBank& vb2)
|
|
||||||
{
|
|
||||||
return vb1.VAngle == vb2.VAngle && vb1.Bank == vb2.Bank;
|
|
||||||
}
|
|
||||||
bool operator!=(const VAngleAndBank& vb1, const VAngleAndBank& vb2)
|
|
||||||
{
|
|
||||||
return !(vb1 == vb2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define VEHICLE_SEAT_PAIR_FLAG 0x80
|
#define VEHICLE_SEAT_PAIR_FLAG 0x80
|
||||||
#define VEHICLE_SEAT_NUM_MASK 0x7F
|
#define VEHICLE_SEAT_NUM_MASK 0x7F
|
||||||
|
|
||||||
|
@ -638,15 +623,10 @@ extern uint32_t _vehicleMotionTrackFlags;
|
||||||
extern int32_t _vehicleVelocityF64E08;
|
extern int32_t _vehicleVelocityF64E08;
|
||||||
extern int32_t _vehicleVelocityF64E0C;
|
extern int32_t _vehicleVelocityF64E0C;
|
||||||
extern int32_t _vehicleUnkF64E10;
|
extern int32_t _vehicleUnkF64E10;
|
||||||
extern VAngleAndBank _vehicleVAngleAndBank;
|
|
||||||
extern uint8_t _vehicleF64E2C;
|
extern uint8_t _vehicleF64E2C;
|
||||||
extern Vehicle* _vehicleFrontVehicle;
|
extern Vehicle* _vehicleFrontVehicle;
|
||||||
extern CoordsXYZ unk_F64E20;
|
extern CoordsXYZ unk_F64E20;
|
||||||
|
|
||||||
// TODO move these to Track.h
|
|
||||||
VAngleAndBank VAngleAndBankStart(uint8_t trackType);
|
|
||||||
VAngleAndBank VAngleAndBankEnd(uint8_t trackType);
|
|
||||||
|
|
||||||
/** Helper macro until rides are stored in this module. */
|
/** Helper macro until rides are stored in this module. */
|
||||||
#define GET_VEHICLE(sprite_index) &(get_sprite(sprite_index)->vehicle)
|
#define GET_VEHICLE(sprite_index) &(get_sprite(sprite_index)->vehicle)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue