mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-29 01:35:06 +01:00
Sort rides into ride groups when in select-by-track-type mode
* Add ride groups * Convert ride groups to C++ * Fix linking and crashes in Xcode * Comment out .field syntax to make Visual Studio happy * Fix alignment, fix changelog, cleanup * Properly save ride group index in the ride object repository and bump its version * Fix fallback behaviour when the ride entry is not available or not invented * Fix include * Rename RideGroup to RideGroupManager, add const, cleanup * Break after finding matching ride group
This commit is contained in:
committed by
GitHub
parent
fda2f38097
commit
96a7a8ab50
@@ -20,6 +20,7 @@
|
||||
#include "../core/Util.hpp"
|
||||
#include "ObjectRepository.h"
|
||||
#include "RideObject.h"
|
||||
#include "../ride/RideGroupManager.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -27,6 +28,7 @@ extern "C"
|
||||
#include "../drawing/drawing.h"
|
||||
#include "../localisation/localisation.h"
|
||||
#include "../rct1.h"
|
||||
#include "../ride/ride.h"
|
||||
#include "../ride/track.h"
|
||||
}
|
||||
|
||||
@@ -76,26 +78,18 @@ void RideObject::ReadLegacy(IReadObjectContext * context, IStream * stream)
|
||||
GetStringTable()->Read(context, stream, OBJ_STRING_ID_NAME);
|
||||
GetStringTable()->Read(context, stream, OBJ_STRING_ID_DESCRIPTION);
|
||||
|
||||
// TODO: Move to its own function when ride construction window is merged.
|
||||
if (gConfigInterface.select_by_track_type)
|
||||
// Add boosters if the track type is eligible
|
||||
for (sint32 i = 0; i < 3; i++)
|
||||
{
|
||||
_legacyType.enabledTrackPieces = 0xFFFFFFFFFFFFFFFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When not in select by track type mode, add boosters if the track type is eligible
|
||||
for (sint32 i = 0; i < 3; i++)
|
||||
{
|
||||
if (_legacyType.ride_type[i] == RIDE_TYPE_LOOPING_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_CORKSCREW_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_TWISTER_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_GIGA_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_JUNIOR_ROLLER_COASTER)
|
||||
{
|
||||
|
||||
_legacyType.enabledTrackPieces |= (1ULL << TRACK_BOOSTER);
|
||||
}
|
||||
if (
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_LOOPING_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_CORKSCREW_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_TWISTER_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_VERTICAL_DROP_ROLLER_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_GIGA_COASTER ||
|
||||
_legacyType.ride_type[i] == RIDE_TYPE_JUNIOR_ROLLER_COASTER
|
||||
) {
|
||||
_legacyType.enabledTrackPieces |= (1ULL << TRACK_BOOSTER);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,6 +408,34 @@ void RideObject::SetRepositoryItem(ObjectRepositoryItem * item) const
|
||||
flags |= ORI_RIDE_FLAG_SEPARATE;
|
||||
}
|
||||
item->RideFlags = flags;
|
||||
|
||||
// Find the first non-null ride type, to be used when checking the ride group
|
||||
uint8 rideTypeIdx = ride_entry_get_first_non_null_ride_type((rct_ride_entry *)&_legacyType);
|
||||
|
||||
// Determines the ride group. Will fall back to 0 if there is none found.
|
||||
uint8 rideGroupIndex = 0;
|
||||
|
||||
const ride_group * rideGroup = get_ride_group(rideTypeIdx, (rct_ride_entry *)&_legacyType);
|
||||
|
||||
// If the ride group is NULL, the track type does not have ride groups.
|
||||
if (rideGroup != NULL)
|
||||
{
|
||||
for (uint8 i = rideGroupIndex + 1; i < MAX_RIDE_GROUPS_PER_RIDE_TYPE; i++)
|
||||
{
|
||||
ride_group * irg = ride_group_find(rideTypeIdx, i);
|
||||
|
||||
if (irg != NULL)
|
||||
{
|
||||
if (ride_groups_are_equal(irg, rideGroup))
|
||||
{
|
||||
rideGroupIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item->RideGroupIndex = rideGroupIndex;
|
||||
}
|
||||
|
||||
void RideObject::ReadLegacyVehicle(IReadObjectContext * context, IStream * stream, rct_ride_entry_vehicle * vehicle)
|
||||
|
||||
Reference in New Issue
Block a user