Part of #13874: replace flags table

This commit is contained in:
frutiemax 2021-08-22 09:59:09 -04:00
parent 675777efaf
commit 1bfa26e4c5
6 changed files with 19 additions and 13 deletions

View File

@ -19,6 +19,7 @@
#include "../world/Surface.h"
#include "RideSetSettingAction.h"
using namespace OpenRCT2::TrackMetaData;
TrackPlaceActionResult::TrackPlaceActionResult()
: GameActions::Result(GameActions::Status::Ok, STR_RIDE_CONSTRUCTION_CANT_CONSTRUCT_THIS_HERE)
{
@ -146,7 +147,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
if ((_trackPlaceFlags & CONSTRUCTION_LIFT_HILL_SELECTED)
&& !ride->GetRideTypeDescriptor().SupportsTrackPiece(TRACK_LIFT_HILL_STEEP) && !gCheatsEnableChainLiftOnAllTrack)
{
if (TrackFlags[_trackType] & TRACK_ELEM_FLAG_IS_STEEP_UP)
const auto& teDescriptor = GetTrackElementDescriptor(_trackType);
if (teDescriptor.Flags & TRACK_ELEM_FLAG_IS_STEEP_UP)
{
return std::make_unique<TrackPlaceActionResult>(GameActions::Status::Disallowed, STR_TOO_STEEP_FOR_LIFT_HILL);
}
@ -176,7 +178,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
}
if (!gCheatsAllowTrackPlaceInvalidHeights)
{
if (TrackFlags[_trackType] & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT)
const auto& teDescriptor = GetTrackElementDescriptor(_trackType);
if (teDescriptor.Flags & TRACK_ELEM_FLAG_STARTS_AT_HALF_HEIGHT)
{
if ((_origin.z & 0x0F) != 8)
{
@ -260,7 +263,8 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
res->GroundFlags = mapGroundFlags;
if (TrackFlags[_trackType] & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND)
const auto& teDescriptor = GetTrackElementDescriptor(_trackType);
if (teDescriptor.Flags & TRACK_ELEM_FLAG_ONLY_ABOVE_GROUND)
{
if (res->GroundFlags & ELEMENT_IS_UNDERGROUND)
{
@ -269,7 +273,7 @@ GameActions::Result::Ptr TrackPlaceAction::Query() const
}
}
if (TrackFlags[_trackType] & TRACK_ELEM_FLAG_ONLY_UNDERWATER)
if (teDescriptor.Flags & TRACK_ELEM_FLAG_ONLY_UNDERWATER)
{ // No element has this flag
if (canBuild->GroundFlags & ELEMENT_IS_UNDERWATER)
{

View File

@ -2663,7 +2663,8 @@ static bool ride_check_track_contains_inversions(CoordsXYE* input, CoordsXYE* ou
while (track_circuit_iterator_next(&it))
{
auto trackType = it.current.element->AsTrack()->GetTrackType();
if (TrackFlags[trackType] & TRACK_ELEM_FLAG_INVERSION_TO_NORMAL)
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
if (teDescriptor.Flags & TRACK_ELEM_FLAG_INVERSION_TO_NORMAL)
{
*output = it.current;
return true;
@ -2721,7 +2722,8 @@ static bool ride_check_track_contains_banked(CoordsXYE* input, CoordsXYE* output
while (track_circuit_iterator_next(&it))
{
auto trackType = output->element->AsTrack()->GetTrackType();
if (TrackFlags[trackType] & TRACK_ELEM_FLAG_BANKED)
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
if (teDescriptor.Flags & TRACK_ELEM_FLAG_BANKED)
{
*output = it.current;
return true;

View File

@ -4858,7 +4858,7 @@ const uint8_t TrackSequenceElementAllowedWallEdges[TrackElemType::Count][MaxSequ
};
/** rct2: 0x0099423C */
const uint16_t TrackFlags[TrackElemType::Count] = {
const static uint16_t TrackFlags[TrackElemType::Count] = {
/* TrackElemType::Flat */ TRACK_ELEM_FLAG_ALLOW_LIFT_HILL,
/* TrackElemType::EndStation */ 0,
/* TrackElemType::BeginStation */ 0,

View File

@ -68,8 +68,6 @@ extern const uint32_t TrackHeightMarkerPositions[TrackElemType::Count];
extern const uint8_t TrackSequenceElementAllowedWallEdges[TrackElemType::Count][16];
extern const uint16_t TrackFlags[TrackElemType::Count];
struct TrackElementDescriptor
{
rct_track_coordinates Coordinates;

View File

@ -1707,7 +1707,8 @@ void Vehicle::UpdateMeasurements()
}
}
uint16_t trackFlags = TrackFlags[trackElemType];
const auto& teDescriptor = GetTrackElementDescriptor(trackElemType);
uint16_t trackFlags = teDescriptor.Flags;
uint32_t testingFlags = curRide->testing_flags;
if (testingFlags & RIDE_TESTING_TURN_LEFT && trackFlags & TRACK_ELEM_FLAG_TURN_LEFT)
@ -8545,7 +8546,8 @@ bool Vehicle::UpdateTrackMotionBackwardsGetNewTrack(uint16_t trackType, Ride* cu
if (next_vehicle_on_train == SPRITE_INDEX_NULL)
{
trackType = tileElement->AsTrack()->GetTrackType();
if (!(TrackFlags[trackType] & TRACK_ELEM_FLAG_DOWN))
const auto& teDescriptor = GetTrackElementDescriptor(trackType);
if (!(teDescriptor.Flags & TRACK_ELEM_FLAG_DOWN))
{
_vehicleMotionTrackFlags |= VEHICLE_UPDATE_MOTION_TRACK_FLAG_9;
}

View File

@ -349,13 +349,13 @@ bool window_ride_construction_update_state(
bool turnOffLiftHill = false;
if (!(_enabledRidePieces & (1ULL << TRACK_LIFT_HILL_CURVE)))
{
if (TrackFlags[trackType] & TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT)
if (teDescriptor.Flags & TRACK_ELEM_FLAG_CURVE_ALLOWS_LIFT)
{
turnOffLiftHill = true;
}
}
if (!(TrackFlags[trackType] & TRACK_ELEM_FLAG_ALLOW_LIFT_HILL))
if (!(teDescriptor.Flags & TRACK_ELEM_FLAG_ALLOW_LIFT_HILL))
{
turnOffLiftHill = true;
}