From ab75b8db8496636cfc486cd46ec34cc92bb1a6f6 Mon Sep 17 00:00:00 2001 From: Gymnasiast Date: Sat, 20 May 2017 23:59:51 +0200 Subject: [PATCH] Properly check separate flags when scanning objects and building track list, fixes #3681 --- distribution/changelog.txt | 1 + src/openrct2/object/RideObject.cpp | 3 +- src/openrct2/ride/TrackDesignRepository.cpp | 50 +++++++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index de9b6b7c50..4909f67104 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,5 +1,6 @@ 0.0.8 (in development) ------------------------------------------------------------------------ +- Fix: [#3681] Steel Twister rollercoaster always shows all track designs - Fix: Track components added by OpenRCT2 are now usable in older scenarios. 0.0.7 (2017-05-03) diff --git a/src/openrct2/object/RideObject.cpp b/src/openrct2/object/RideObject.cpp index c07a20fff6..e11373a323 100644 --- a/src/openrct2/object/RideObject.cpp +++ b/src/openrct2/object/RideObject.cpp @@ -405,8 +405,7 @@ void RideObject::SetRepositoryItem(ObjectRepositoryItem * item) const } uint8 flags = 0; - if ((_legacyType.flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE_NAME) && - !rideTypeShouldLoseSeparateFlag(&_legacyType)) + if (_legacyType.flags & RIDE_ENTRY_FLAG_SEPARATE_RIDE) { flags |= ORI_RIDE_FLAG_SEPARATE; } diff --git a/src/openrct2/ride/TrackDesignRepository.cpp b/src/openrct2/ride/TrackDesignRepository.cpp index 922713daa3..82c2a24bf1 100644 --- a/src/openrct2/ride/TrackDesignRepository.cpp +++ b/src/openrct2/ride/TrackDesignRepository.cpp @@ -17,6 +17,7 @@ #include #include #include +#include "../config/Config.h" #include "../core/Collections.hpp" #include "../core/Console.hpp" #include "../core/File.h" @@ -24,6 +25,8 @@ #include "../core/FileStream.hpp" #include "../core/Path.hpp" #include "../core/String.hpp" +#include "../object/ObjectRepository.h" +#include "../object/RideObject.h" #include "../PlatformEnvironment.h" #include "TrackDesignRepository.h" @@ -90,13 +93,32 @@ public: return _items.size(); } + /** + * + * @param rideType + * @param entry The entry name to count the track list of. Leave empty to count track list for the non-separated types (e.g. Hyper-Twister, Car Ride) + * @return + */ size_t GetCountForObjectEntry(uint8 rideType, const std::string &entry) const override { size_t count = 0; + IObjectRepository * repo = GetObjectRepository(); + for (const auto item : _items) { - if (item.RideType == rideType && - (entry.empty() || String::Equals(item.ObjectEntry, entry, true))) + if (item.RideType != rideType) + continue; + + bool entryIsNotSeparate = false; + if (entry.empty()) + { + const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); + + if (gConfigInterface.select_by_track_type || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) + entryIsNotSeparate = true; + } + + if (entryIsNotSeparate || String::Equals(item.ObjectEntry, entry, true)) { count++; } @@ -104,13 +126,33 @@ public: return count; } + /** + * + * @param outRefs + * @param rideType + * @param entry The entry name to build a track list for. Leave empty to build track list for the non-separated types (e.g. Hyper-Twister, Car Ride) + * @return + */ size_t GetItemsForObjectEntry(track_design_file_ref * * outRefs, uint8 rideType, const std::string &entry) const override { std::vector refs; + IObjectRepository * repo = GetObjectRepository(); + for (const auto item : _items) { - if (item.RideType == rideType && - (entry.empty() || String::Equals(item.ObjectEntry, entry, true))) + if (item.RideType != rideType) + continue; + + bool entryIsNotSeparate = false; + if (entry.empty()) + { + const ObjectRepositoryItem * ori = repo->FindObject(item.ObjectEntry.c_str()); + + if (gConfigInterface.select_by_track_type || !(ori->RideFlags & ORI_RIDE_FLAG_SEPARATE)) + entryIsNotSeparate = true; + } + + if (entryIsNotSeparate || String::Equals(item.ObjectEntry, entry, true)) { track_design_file_ref ref; ref.name = String::Duplicate(GetNameFromTrackPath(item.Path));