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

Move supported track pieces return type to BitSet

This commit is contained in:
spacek531
2022-08-05 11:55:30 -07:00
committed by GitHub
parent 967366c2fe
commit 468084a401
3 changed files with 13 additions and 9 deletions

View File

@@ -26,15 +26,15 @@ namespace RCT2
switch (rct2RideType)
{
case RIDE_TYPE_CORKSCREW_ROLLER_COASTER:
if (rideEntry != nullptr && !(ride_entry_get_supported_track_pieces(rideEntry) & (1ULL << TRACK_VERTICAL_LOOP)))
if (rideEntry != nullptr && !ride_entry_get_supported_track_pieces(rideEntry).get(TRACK_VERTICAL_LOOP))
return RIDE_TYPE_HYPERCOASTER;
return RIDE_TYPE_CORKSCREW_ROLLER_COASTER;
case RIDE_TYPE_JUNIOR_ROLLER_COASTER:
if (rideEntry != nullptr && ride_entry_get_supported_track_pieces(rideEntry) & (1ULL << TRACK_SLOPE_STEEP_DOWN))
if (rideEntry != nullptr && ride_entry_get_supported_track_pieces(rideEntry).get(TRACK_SLOPE_STEEP_DOWN))
return RIDE_TYPE_CLASSIC_MINI_ROLLER_COASTER;
return RIDE_TYPE_JUNIOR_ROLLER_COASTER;
case RIDE_TYPE_CAR_RIDE:
if (rideEntry != nullptr && ride_entry_get_supported_track_pieces(rideEntry) & (1ULL << TRACK_SLOPE_STEEP_DOWN))
if (rideEntry != nullptr && ride_entry_get_supported_track_pieces(rideEntry).get(TRACK_SLOPE_STEEP_DOWN))
return RIDE_TYPE_MONSTER_TRUCKS;
return RIDE_TYPE_CAR_RIDE;
case RIDE_TYPE_TWISTER_ROLLER_COASTER:
@@ -42,8 +42,7 @@ namespace RCT2
return RIDE_TYPE_HYPER_TWISTER;
return RIDE_TYPE_TWISTER_ROLLER_COASTER;
case RIDE_TYPE_STEEL_WILD_MOUSE:
if (rideEntry != nullptr
&& !(ride_entry_get_supported_track_pieces(rideEntry) & (1ULL << TRACK_SLOPE_STEEP_DOWN)))
if (rideEntry != nullptr && !ride_entry_get_supported_track_pieces(rideEntry).get(TRACK_SLOPE_STEEP_DOWN))
return RIDE_TYPE_SPINNING_WILD_MOUSE;
return RIDE_TYPE_STEEL_WILD_MOUSE;

View File

@@ -23,6 +23,7 @@
#include "../audio/audio.h"
#include "../common.h"
#include "../config/Config.h"
#include "../core/BitSet.hpp"
#include "../core/FixedVector.h"
#include "../core/Guard.hpp"
#include "../core/Numerics.hpp"
@@ -4829,7 +4830,7 @@ struct NecessarySpriteGroup
};
// Finds track pieces that a given ride entry has sprites for
uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry)
OpenRCT2::BitSet<TRACK_GROUP_COUNT> ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry)
{
// TODO: Use a std::span when C++20 available as 6 is due to jagged array
static const std::array<NecessarySpriteGroup, 6> trackPieceRequiredSprites[TRACK_GROUP_COUNT] = {
@@ -4945,7 +4946,8 @@ uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry)
// Only check default vehicle; it's assumed the others will have correct sprites if this one does (I've yet to find an
// exception, at least)
auto supportedPieces = std::numeric_limits<uint64_t>::max();
auto supportedPieces = OpenRCT2::BitSet<TRACK_GROUP_COUNT>();
supportedPieces.flip();
auto defaultVehicle = rideEntry->GetDefaultCar();
if (defaultVehicle != nullptr)
{
@@ -4955,7 +4957,7 @@ uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry)
{
auto precision = defaultVehicle->SpriteGroups[static_cast<uint8_t>(group.VehicleSpriteGroup)].spritePrecision;
if (precision < group.MinPrecision)
supportedPieces &= ~(1ULL << i);
supportedPieces.set(i, false);
}
}
}

View File

@@ -12,6 +12,7 @@
#include "../Limits.h"
#include "../actions/ResultWithMessage.h"
#include "../common.h"
#include "../core/BitSet.hpp"
#include "../object/MusicObject.h"
#include "../rct2/DATLimits.h"
#include "../rct2/Limits.h"
@@ -19,6 +20,7 @@
#include "RideColour.h"
#include "RideRatings.h"
#include "RideTypes.h"
#include "Track.h"
#include "VehicleColour.h"
#include <array>
@@ -1061,7 +1063,8 @@ void ride_fix_breakdown(Ride* ride, int32_t reliabilityIncreaseFactor);
uint8_t ride_entry_get_vehicle_at_position(int32_t rideEntryIndex, int32_t numCarsPerTrain, int32_t position);
void ride_update_vehicle_colours(Ride* ride);
uint64_t ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry);
OpenRCT2::BitSet<TRACK_GROUP_COUNT> ride_entry_get_supported_track_pieces(const rct_ride_entry* rideEntry);
enum class RideSetSetting : uint8_t;
money32 set_operating_setting(RideId rideId, RideSetSetting setting, uint8_t value);