mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #12636 from Gymnasiast/refactor/to-member-function
Use a 16-bit integer for track type in more places
This commit is contained in:
commit
2d56c8d2de
|
@ -2513,7 +2513,7 @@ void window_ride_construction_update_active_elements_impl()
|
||||||
!= std::nullopt)
|
!= std::nullopt)
|
||||||
{
|
{
|
||||||
_selectedTrackType = tileElement->AsTrack()->GetTrackType();
|
_selectedTrackType = tileElement->AsTrack()->GetTrackType();
|
||||||
if (track_element_has_speed_setting(tileElement->AsTrack()->GetTrackType()))
|
if (TrackTypeHasSpeedSetting(tileElement->AsTrack()->GetTrackType()))
|
||||||
_currentBrakeSpeed2 = tileElement->AsTrack()->GetBrakeBoosterSpeed();
|
_currentBrakeSpeed2 = tileElement->AsTrack()->GetBrakeBoosterSpeed();
|
||||||
_currentSeatRotationAngle = tileElement->AsTrack()->GetSeatRotation();
|
_currentSeatRotationAngle = tileElement->AsTrack()->GetSeatRotation();
|
||||||
}
|
}
|
||||||
|
@ -3065,7 +3065,7 @@ static void window_ride_construction_update_widgets(rct_window* w)
|
||||||
|
|
||||||
bool brakesSelected = _selectedTrackType == TRACK_ELEM_BRAKES
|
bool brakesSelected = _selectedTrackType == TRACK_ELEM_BRAKES
|
||||||
|| _currentTrackCurve == (RideConstructionSpecialPieceSelected | TRACK_ELEM_BRAKES);
|
|| _currentTrackCurve == (RideConstructionSpecialPieceSelected | TRACK_ELEM_BRAKES);
|
||||||
_boosterTrackSelected = track_element_is_booster(ride->type, _selectedTrackType)
|
_boosterTrackSelected = TrackTypeIsBooster(ride->type, _selectedTrackType)
|
||||||
|| (ride->type != RIDE_TYPE_SPINNING_WILD_MOUSE
|
|| (ride->type != RIDE_TYPE_SPINNING_WILD_MOUSE
|
||||||
&& _currentTrackCurve == (RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER));
|
&& _currentTrackCurve == (RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER));
|
||||||
|
|
||||||
|
|
|
@ -633,7 +633,7 @@ public:
|
||||||
map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, CoordsXYZ{ mapLoc, tileElement->GetBaseZ() });
|
map_animation_create(MAP_ANIMATION_TYPE_TRACK_SPINNINGTUNNEL, CoordsXYZ{ mapLoc, tileElement->GetBaseZ() });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (track_element_has_speed_setting(_trackType))
|
if (TrackTypeHasSpeedSetting(_trackType))
|
||||||
{
|
{
|
||||||
tileElement->AsTrack()->SetBrakeBoosterSpeed(_brakeSpeed);
|
tileElement->AsTrack()->SetBrakeBoosterSpeed(_brakeSpeed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2132,7 +2132,7 @@ private:
|
||||||
// Skipping IsHighlighted()
|
// Skipping IsHighlighted()
|
||||||
|
|
||||||
auto trackType = dst2->GetTrackType();
|
auto trackType = dst2->GetTrackType();
|
||||||
if (track_element_has_speed_setting(trackType))
|
if (TrackTypeHasSpeedSetting(trackType))
|
||||||
{
|
{
|
||||||
dst2->SetBrakeBoosterSpeed(src2->GetBrakeBoosterSpeed());
|
dst2->SetBrakeBoosterSpeed(src2->GetBrakeBoosterSpeed());
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ bool RCT12TrackElement::IsInverted() const
|
||||||
|
|
||||||
uint8_t RCT12TrackElement::GetBrakeBoosterSpeed() const
|
uint8_t RCT12TrackElement::GetBrakeBoosterSpeed() const
|
||||||
{
|
{
|
||||||
if (track_element_has_speed_setting(GetTrackType()))
|
if (TrackTypeHasSpeedSetting(GetTrackType()))
|
||||||
{
|
{
|
||||||
return (sequence >> 4) << 1;
|
return (sequence >> 4) << 1;
|
||||||
}
|
}
|
||||||
|
@ -791,7 +791,7 @@ void RCT12TrackElement::SetInverted(bool inverted)
|
||||||
|
|
||||||
void RCT12TrackElement::SetBrakeBoosterSpeed(uint8_t speed)
|
void RCT12TrackElement::SetBrakeBoosterSpeed(uint8_t speed)
|
||||||
{
|
{
|
||||||
if (track_element_has_speed_setting(GetTrackType()))
|
if (TrackTypeHasSpeedSetting(GetTrackType()))
|
||||||
{
|
{
|
||||||
sequence &= ~0b11110000;
|
sequence &= ~0b11110000;
|
||||||
sequence |= ((speed >> 1) << 4);
|
sequence |= ((speed >> 1) << 4);
|
||||||
|
|
|
@ -1130,7 +1130,7 @@ public:
|
||||||
// Skipping IsHighlighted()
|
// Skipping IsHighlighted()
|
||||||
|
|
||||||
auto trackType = dst2->GetTrackType();
|
auto trackType = dst2->GetTrackType();
|
||||||
if (track_element_has_speed_setting(trackType))
|
if (TrackTypeHasSpeedSetting(trackType))
|
||||||
{
|
{
|
||||||
dst2->SetBrakeBoosterSpeed(src2->GetBrakeBoosterSpeed());
|
dst2->SetBrakeBoosterSpeed(src2->GetBrakeBoosterSpeed());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1470,7 +1470,7 @@ void ride_construction_set_default_next_piece()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (track_element_is_booster(ride->type, trackType))
|
if (TrackTypeIsBooster(ride->type, trackType))
|
||||||
{
|
{
|
||||||
curve = RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER;
|
curve = RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER;
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1531,7 @@ void ride_construction_set_default_next_piece()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (track_element_is_booster(ride->type, trackType))
|
if (TrackTypeIsBooster(ride->type, trackType))
|
||||||
{
|
{
|
||||||
curve = RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER;
|
curve = RideConstructionSpecialPieceSelected | TRACK_ELEM_BOOSTER;
|
||||||
}
|
}
|
||||||
|
|
|
@ -559,12 +559,12 @@ const rct_trackdefinition FlatRideTrackDefinitions[256] =
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
PitchAndRoll TrackPitchAndRollStart(uint8_t trackType)
|
PitchAndRoll TrackPitchAndRollStart(track_type_t trackType)
|
||||||
{
|
{
|
||||||
return { TrackDefinitions[trackType].vangle_start, TrackDefinitions[trackType].bank_start };
|
return { TrackDefinitions[trackType].vangle_start, TrackDefinitions[trackType].bank_start };
|
||||||
}
|
}
|
||||||
|
|
||||||
PitchAndRoll TrackPitchAndRollEnd(uint8_t trackType)
|
PitchAndRoll TrackPitchAndRollEnd(track_type_t trackType)
|
||||||
{
|
{
|
||||||
return { TrackDefinitions[trackType].vangle_end, TrackDefinitions[trackType].bank_end };
|
return { TrackDefinitions[trackType].vangle_end, TrackDefinitions[trackType].bank_end };
|
||||||
}
|
}
|
||||||
|
@ -1085,9 +1085,9 @@ void TrackElement::SetHasChain(bool on)
|
||||||
* A beginning of a block can be the end of a station, the end of a lift hill,
|
* A beginning of a block can be the end of a station, the end of a lift hill,
|
||||||
* or a block brake.
|
* or a block brake.
|
||||||
*/
|
*/
|
||||||
bool track_element_is_block_start(TileElement* trackElement)
|
bool TrackElement::IsBlockStart() const
|
||||||
{
|
{
|
||||||
switch (trackElement->AsTrack()->GetTrackType())
|
switch (GetTrackType())
|
||||||
{
|
{
|
||||||
case TRACK_ELEM_END_STATION:
|
case TRACK_ELEM_END_STATION:
|
||||||
case TRACK_ELEM_CABLE_LIFT_HILL:
|
case TRACK_ELEM_CABLE_LIFT_HILL:
|
||||||
|
@ -1097,7 +1097,7 @@ bool track_element_is_block_start(TileElement* trackElement)
|
||||||
case TRACK_ELEM_60_DEG_UP_TO_FLAT:
|
case TRACK_ELEM_60_DEG_UP_TO_FLAT:
|
||||||
case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT:
|
case TRACK_ELEM_DIAG_25_DEG_UP_TO_FLAT:
|
||||||
case TRACK_ELEM_DIAG_60_DEG_UP_TO_FLAT:
|
case TRACK_ELEM_DIAG_60_DEG_UP_TO_FLAT:
|
||||||
if (trackElement->AsTrack()->HasChain())
|
if (HasChain())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1166,7 @@ bool track_type_is_station(track_type_t trackType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool track_element_is_covered(int32_t trackElementType)
|
bool track_element_is_covered(track_type_t trackElementType)
|
||||||
{
|
{
|
||||||
switch (trackElementType)
|
switch (trackElementType)
|
||||||
{
|
{
|
||||||
|
@ -1195,13 +1195,13 @@ bool track_element_is_covered(int32_t trackElementType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool track_element_is_booster(uint8_t rideType, uint8_t trackType)
|
bool TrackTypeIsBooster(uint8_t rideType, track_type_t trackType)
|
||||||
{
|
{
|
||||||
// Boosters share their ID with the Spinning Control track.
|
// Boosters share their ID with the Spinning Control track.
|
||||||
return rideType != RIDE_TYPE_SPINNING_WILD_MOUSE && trackType == TRACK_ELEM_BOOSTER;
|
return rideType != RIDE_TYPE_SPINNING_WILD_MOUSE && trackType == TRACK_ELEM_BOOSTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool track_element_has_speed_setting(uint8_t trackType)
|
bool TrackTypeHasSpeedSetting(track_type_t trackType)
|
||||||
{
|
{
|
||||||
// This does not check if the element is really a Spinning Control track instead of a booster,
|
// This does not check if the element is really a Spinning Control track instead of a booster,
|
||||||
// but this does not cause problems.
|
// but this does not cause problems.
|
||||||
|
|
|
@ -554,8 +554,8 @@ 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];
|
||||||
|
|
||||||
PitchAndRoll TrackPitchAndRollStart(uint8_t trackType);
|
PitchAndRoll TrackPitchAndRollStart(track_type_t trackType);
|
||||||
PitchAndRoll TrackPitchAndRollEnd(uint8_t trackType);
|
PitchAndRoll TrackPitchAndRollEnd(track_type_t trackType);
|
||||||
|
|
||||||
int32_t track_is_connected_by_shape(TileElement* a, TileElement* b);
|
int32_t track_is_connected_by_shape(TileElement* a, TileElement* b);
|
||||||
|
|
||||||
|
@ -571,8 +571,7 @@ bool track_circuit_iterators_match(const track_circuit_iterator* firstIt, const
|
||||||
void track_get_back(CoordsXYE* input, CoordsXYE* output);
|
void track_get_back(CoordsXYE* input, CoordsXYE* output);
|
||||||
void track_get_front(CoordsXYE* input, CoordsXYE* output);
|
void track_get_front(CoordsXYE* input, CoordsXYE* output);
|
||||||
|
|
||||||
bool track_element_is_block_start(TileElement* trackElement);
|
bool track_element_is_covered(track_type_t trackElementType);
|
||||||
bool track_element_is_covered(int32_t trackElementType);
|
|
||||||
bool track_type_is_station(track_type_t trackType);
|
bool track_type_is_station(track_type_t trackType);
|
||||||
|
|
||||||
roll_type_t track_get_actual_bank(TileElement* tileElement, roll_type_t bank);
|
roll_type_t track_get_actual_bank(TileElement* tileElement, roll_type_t bank);
|
||||||
|
@ -586,5 +585,5 @@ money32 maze_set_track(
|
||||||
uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex,
|
uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex,
|
||||||
uint8_t mode);
|
uint8_t mode);
|
||||||
|
|
||||||
bool track_element_is_booster(uint8_t rideType, uint8_t trackType);
|
bool TrackTypeIsBooster(uint8_t rideType, track_type_t trackType);
|
||||||
bool track_element_has_speed_setting(uint8_t trackType);
|
bool TrackTypeHasSpeedSetting(track_type_t trackType);
|
||||||
|
|
|
@ -217,7 +217,7 @@ rct_string_id TrackDesign::CreateTrackDesignTrack(const Ride& ride)
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t trackFlags;
|
uint8_t trackFlags;
|
||||||
if (track_element_has_speed_setting(track.type))
|
if (TrackTypeHasSpeedSetting(track.type))
|
||||||
{
|
{
|
||||||
trackFlags = trackElement.element->AsTrack()->GetBrakeBoosterSpeed() >> 1;
|
trackFlags = trackElement.element->AsTrack()->GetBrakeBoosterSpeed() >> 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6750,7 +6750,7 @@ static void block_brakes_open_previous_section(Ride& ride, const CoordsXYZ& vehi
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (!track_element_is_block_start(trackBeginEnd.begin_element));
|
} while (!(trackBeginEnd.begin_element->AsTrack()->IsBlockStart()));
|
||||||
|
|
||||||
// Get the start of the track block instead of the end
|
// Get the start of the track block instead of the end
|
||||||
location = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z };
|
location = { trackBeginEnd.begin_x, trackBeginEnd.begin_y, trackBeginEnd.begin_z };
|
||||||
|
@ -7917,7 +7917,7 @@ bool Vehicle::UpdateTrackMotionForwardsGetNewTrack(uint16_t trackType, Ride* cur
|
||||||
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_11;
|
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_11;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_element_is_block_start(tileElement))
|
if (tileElement->AsTrack()->IsBlockStart())
|
||||||
{
|
{
|
||||||
if (next_vehicle_on_train == SPRITE_INDEX_NULL)
|
if (next_vehicle_on_train == SPRITE_INDEX_NULL)
|
||||||
{
|
{
|
||||||
|
@ -8130,7 +8130,7 @@ loc_6DAEB9:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (track_element_is_booster(curRide->type, trackType))
|
else if (TrackTypeIsBooster(curRide->type, trackType))
|
||||||
{
|
{
|
||||||
regs.eax = get_booster_speed(curRide->type, (brake_speed << 16));
|
regs.eax = get_booster_speed(curRide->type, (brake_speed << 16));
|
||||||
|
|
||||||
|
@ -8513,7 +8513,7 @@ loc_6DBA33:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_element_is_booster(curRide->type, trackType))
|
if (TrackTypeIsBooster(curRide->type, trackType))
|
||||||
{
|
{
|
||||||
regs.eax = get_booster_speed(curRide->type, (brake_speed << 16));
|
regs.eax = get_booster_speed(curRide->type, (brake_speed << 16));
|
||||||
|
|
||||||
|
|
|
@ -364,7 +364,7 @@ bool window_ride_construction_update_state(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (track_element_has_speed_setting(trackType))
|
if (TrackTypeHasSpeedSetting(trackType))
|
||||||
{
|
{
|
||||||
properties = _currentBrakeSpeed2;
|
properties = _currentBrakeSpeed2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,6 +376,7 @@ public:
|
||||||
void SetDoorBState(uint8_t newState);
|
void SetDoorBState(uint8_t newState);
|
||||||
|
|
||||||
bool IsStation() const;
|
bool IsStation() const;
|
||||||
|
bool IsBlockStart() const;
|
||||||
};
|
};
|
||||||
assert_struct_size(TrackElement, 16);
|
assert_struct_size(TrackElement, 16);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue