mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-18 20:43:04 +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
@@ -24,6 +24,7 @@
|
||||
#include "../core/FileScanner.h"
|
||||
#include "../core/FileStream.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "RideGroupManager.h"
|
||||
#include "../core/String.hpp"
|
||||
#include "../object/ObjectRepository.h"
|
||||
#include "../object/RideObject.h"
|
||||
@@ -104,12 +105,14 @@ public:
|
||||
size_t GetCountForObjectEntry(uint8 rideType, const std::string &entry) const override
|
||||
{
|
||||
size_t count = 0;
|
||||
IObjectRepository * repo = GetObjectRepository();
|
||||
const IObjectRepository * repo = GetObjectRepository();
|
||||
|
||||
for (const auto item : _items)
|
||||
for (const auto &item : _items)
|
||||
{
|
||||
if (item.RideType != rideType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool entryIsNotSeparate = false;
|
||||
if (entry.empty())
|
||||
@@ -128,6 +131,30 @@ public:
|
||||
return count;
|
||||
}
|
||||
|
||||
size_t GetCountForRideGroup(uint8 rideType, const ride_group * rideGroup) const override
|
||||
{
|
||||
size_t count = 0;
|
||||
const IObjectRepository * repo = GetObjectRepository();
|
||||
|
||||
for (const auto &item : _items)
|
||||
{
|
||||
if (item.RideType != rideType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str());
|
||||
ride_group * itemRideGroup = ride_group_find(rideType, ori->RideGroupIndex);
|
||||
|
||||
if (itemRideGroup != NULL && ride_groups_are_equal(itemRideGroup, rideGroup))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param outRefs
|
||||
@@ -138,12 +165,14 @@ public:
|
||||
size_t GetItemsForObjectEntry(track_design_file_ref * * outRefs, uint8 rideType, const std::string &entry) const override
|
||||
{
|
||||
std::vector<track_design_file_ref> refs;
|
||||
IObjectRepository * repo = GetObjectRepository();
|
||||
const IObjectRepository * repo = GetObjectRepository();
|
||||
|
||||
for (const auto item : _items)
|
||||
for (const auto &item : _items)
|
||||
{
|
||||
if (item.RideType != rideType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool entryIsNotSeparate = false;
|
||||
if (entry.empty())
|
||||
@@ -167,6 +196,34 @@ public:
|
||||
return refs.size();
|
||||
}
|
||||
|
||||
size_t GetItemsForRideGroup(track_design_file_ref **outRefs, uint8 rideType, const ride_group * rideGroup) const override
|
||||
{
|
||||
std::vector<track_design_file_ref> refs;
|
||||
const IObjectRepository * repo = GetObjectRepository();
|
||||
|
||||
for (const auto &item : _items)
|
||||
{
|
||||
if (item.RideType != rideType)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str());
|
||||
ride_group * itemRideGroup = ride_group_find(rideType, ori->RideGroupIndex);
|
||||
|
||||
if (itemRideGroup != NULL && ride_groups_are_equal(itemRideGroup, rideGroup))
|
||||
{
|
||||
track_design_file_ref ref;
|
||||
ref.name = String::Duplicate(GetNameFromTrackPath(item.Path));
|
||||
ref.path = String::Duplicate(item.Path);
|
||||
refs.push_back(ref);
|
||||
}
|
||||
}
|
||||
|
||||
*outRefs = Collections::ToArray(refs);
|
||||
return refs.size();
|
||||
}
|
||||
|
||||
void Scan() override
|
||||
{
|
||||
std::string rct2Directory = _env->GetDirectoryPath(DIRBASE::RCT2, DIRID::TRACK);
|
||||
@@ -424,12 +481,24 @@ extern "C"
|
||||
return repo->GetCountForObjectEntry(rideType, String::ToStd(entry));
|
||||
}
|
||||
|
||||
size_t track_repository_get_count_for_ride_group(uint8 rideType, const ride_group * rideGroup)
|
||||
{
|
||||
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
||||
return repo->GetCountForRideGroup(rideType, rideGroup);
|
||||
}
|
||||
|
||||
size_t track_repository_get_items_for_ride(track_design_file_ref * * outRefs, uint8 rideType, const utf8 * entry)
|
||||
{
|
||||
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
||||
return repo->GetItemsForObjectEntry(outRefs, rideType, String::ToStd(entry));
|
||||
}
|
||||
|
||||
size_t track_repository_get_items_for_ride_group(track_design_file_ref * * outRefs, uint8 rideType, const ride_group * rideGroup)
|
||||
{
|
||||
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
||||
return repo->GetItemsForRideGroup(outRefs, rideType, rideGroup);
|
||||
}
|
||||
|
||||
bool track_repository_delete(const utf8 * path)
|
||||
{
|
||||
ITrackDesignRepository * repo = GetTrackDesignRepository();
|
||||
|
||||
Reference in New Issue
Block a user