diff --git a/OpenRCT2.xcodeproj/project.pbxproj b/OpenRCT2.xcodeproj/project.pbxproj index 199f5a71b6..ed9e0c686d 100644 --- a/OpenRCT2.xcodeproj/project.pbxproj +++ b/OpenRCT2.xcodeproj/project.pbxproj @@ -557,7 +557,6 @@ D44270EA1CC81B3200D84D28 /* IStream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = IStream.hpp; sourceTree = ""; usesTabs = 0; }; D44270EB1CC81B3200D84D28 /* Json.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Json.cpp; sourceTree = ""; usesTabs = 0; }; D44270EC1CC81B3200D84D28 /* Json.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Json.hpp; sourceTree = ""; usesTabs = 0; }; - D44270ED1CC81B3200D84D28 /* List.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = List.hpp; sourceTree = ""; usesTabs = 0; }; D44270EE1CC81B3200D84D28 /* Math.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Math.hpp; sourceTree = ""; usesTabs = 0; }; D44270EF1CC81B3200D84D28 /* Memory.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Memory.hpp; sourceTree = ""; usesTabs = 0; }; D44270F01CC81B3200D84D28 /* Path.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Path.cpp; sourceTree = ""; usesTabs = 0; }; @@ -1369,7 +1368,6 @@ D44270EA1CC81B3200D84D28 /* IStream.hpp */, D44270EB1CC81B3200D84D28 /* Json.cpp */, D44270EC1CC81B3200D84D28 /* Json.hpp */, - D44270ED1CC81B3200D84D28 /* List.hpp */, D44270EE1CC81B3200D84D28 /* Math.hpp */, D44270EF1CC81B3200D84D28 /* Memory.hpp */, D464FEBC1D31A66E00CBABAC /* MemoryStream.cpp */, diff --git a/openrct2.vcxproj b/openrct2.vcxproj index 716432f64f..81a261d1d1 100644 --- a/openrct2.vcxproj +++ b/openrct2.vcxproj @@ -363,6 +363,7 @@ + @@ -371,7 +372,6 @@ - diff --git a/src/core/Collections.hpp b/src/core/Collections.hpp new file mode 100644 index 0000000000..7d28f4c173 --- /dev/null +++ b/src/core/Collections.hpp @@ -0,0 +1,104 @@ +#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers +/***************************************************************************** + * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. + * + * OpenRCT2 is the work of many authors, a full list can be found in contributors.md + * For more information, visit https://github.com/OpenRCT2/OpenRCT2 + * + * OpenRCT2 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * A full copy of the GNU General Public License can be found in licence.txt + *****************************************************************************/ +#pragma endregion + +#pragma once + +#include +#include "../common.h" +#include "String.hpp" + +namespace Collections +{ + template + void AddRange(TCollection &collection, std::initializer_list initializerList) + { + collection.insert(collection.end(), initializerList.begin(), initializerList.end()); + } + + template + bool Contains(TCollection &collection, TItem needle, TComparer comparer) + { + for (TItem item : collection) + { + if (comparer(item, needle)) + { + return true; + } + } + return false; + } + + template + size_t IndexOf(TCollection &collection, TItem needle, TComparer comparer) + { + size_t index = 0; + for (TItem item : collection) + { + if (comparer(item, needle)) + { + return index; + } + index++; + } + return SIZE_MAX; + } + + #pragma region String helpers + + template + bool Contains(TCollection &collection, const char * item, bool ignoreCase = false) + { + if (ignoreCase) + { + return Contains(collection, item, + [](const char * a, const char * b) + { + return String::Equals(a, b, true); + }); + } + else + { + return Contains(collection, item, + [](const char * a, const char * b) + { + return String::Equals(a, b, false); + }); + } + } + + template + size_t IndexOf(TCollection &collection, const char * item, bool ignoreCase = false) + { + if (ignoreCase) + { + return IndexOf(collection, item, + [](const char * a, const char * b) + { + return String::Equals(a, b, true); + }); + } + else + { + return IndexOf(collection, item, + [](const char * a, const char * b) + { + return String::Equals(a, b, false); + }); + } + } + + #pragma endregion +} diff --git a/src/core/List.hpp b/src/core/List.hpp deleted file mode 100644 index 70c1897144..0000000000 --- a/src/core/List.hpp +++ /dev/null @@ -1,150 +0,0 @@ -#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers -/***************************************************************************** - * OpenRCT2, an open source clone of Roller Coaster Tycoon 2. - * - * OpenRCT2 is the work of many authors, a full list can be found in contributors.md - * For more information, visit https://github.com/OpenRCT2/OpenRCT2 - * - * OpenRCT2 is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * A full copy of the GNU General Public License can be found in licence.txt - *****************************************************************************/ -#pragma endregion - -#pragma once - -#include -#include - -#include "../common.h" -#include "Guard.hpp" -#include "Memory.hpp" - -/** - * A container that stores elements in contiguous memory. Automatically reallocates memory when required. Equivalent to - * std::vector. - */ -template -class List : public std::vector -{ -public: - typedef typename std::vector::const_reference const_reference; - typedef typename std::vector::reference reference; - size_t GetCapacity() const { return this->capacity(); } - size_t GetCount() const { return this->size(); } - const T * GetItems() const { return this->data(); } - - List() : std::vector() { } - - List(std::initializer_list initializerList) : std::vector(initializerList) { } - - List(size_t capacity) : std::vector(capacity) { } - - List(const T * items, size_t count) : std::vector(items, items + count) { } - - void EnsureCapacity(size_t capacity) - { - this->reserve(capacity); - } - - void ShrinkToLength() - { - this->shrink_to_fit(); - } - - void Clear() - { - this->clear(); - } - - void Add(T item) - { - this->push_back(item); - } - - void AddRange(std::initializer_list initializerList) - { - this->insert(this->end(), initializerList.begin(), initializerList.end()); - } - - void Insert(T item, size_t index) - { - Guard::ArgumentInRange(index, (size_t)0, this->size(), GUARD_LINE); - this->insert(this->begin() + index, item); - } - - bool Remove(T item) - { - for (size_t i = 0; i < this->size(); i++) - { - if (*this[i] == item) - { - RemoveAt(i); - return true; - } - } - return false; - } - - void RemoveAt(size_t index) - { - Guard::ArgumentInRange(index, (size_t)0, this->size() - 1, GUARD_LINE); - this->erase(this->begin() + index); - } - - const T * ToArray() const - { - return Memory::DuplicateArray(this->data(), this->size()); - } - - const_reference operator[](size_t index) const - { - Guard::ArgumentInRange(index, (size_t)0, this->size() - 1, GUARD_LINE); - return std::vector::operator[](index); - } - - reference operator[](size_t index) - { - Guard::ArgumentInRange(index, (size_t)0, this->size() - 1, GUARD_LINE); - return std::vector::operator[](index); - } - - size_t IndexOf(std::function predicate) - { - for (size_t i = 0; i < this->size(); i++) - { - T item = std::vector::operator[](i); - if (predicate(item)) - { - return i; - } - } - return SIZE_MAX; - } - - size_t IndexOf(T item, std::function comparer) - { - for (size_t i = 0; i < this->size(); i++) - { - T element = std::vector::operator[](i); - if (comparer(item, element)) - { - return i; - } - } - return SIZE_MAX; - } - - bool Contains(std::function predicate) - { - return IndexOf(predicate) != SIZE_MAX; - } - - bool Contains(T item, std::function comparer) - { - return IndexOf(item, comparer) != SIZE_MAX; - } -}; diff --git a/src/interface/Theme.cpp b/src/interface/Theme.cpp index 6b57efe7b1..fe03d50712 100644 --- a/src/interface/Theme.cpp +++ b/src/interface/Theme.cpp @@ -14,6 +14,7 @@ *****************************************************************************/ #pragma endregion +#include #include extern "C" @@ -25,7 +26,6 @@ extern "C" } #include "../core/Json.hpp" -#include "../core/List.hpp" #include "../core/Math.hpp" #include "../core/Memory.hpp" #include "../core/Path.hpp" @@ -65,9 +65,9 @@ struct UIThemeWindowEntry class UITheme { public: - utf8 * Name; - List Entries; - uint8 Flags; + utf8 * Name; + std::vector Entries; + uint8 Flags; UITheme(const utf8 * name); UITheme(const UITheme & copy); @@ -323,7 +323,7 @@ void UITheme::SetName(const utf8 * name) const UIThemeWindowEntry * UITheme::GetEntry(rct_windowclass windowClass) const { - for (size_t i = 0; i < Entries.GetCount(); i++) + for (size_t i = 0; i < Entries.size(); i++) { const UIThemeWindowEntry * entry = &Entries[i]; if (entry->WindowClass == windowClass) @@ -337,7 +337,7 @@ const UIThemeWindowEntry * UITheme::GetEntry(rct_windowclass windowClass) const void UITheme::SetEntry(const UIThemeWindowEntry * newEntry) { // Try to replace existing entry - for (size_t i = 0; i < Entries.GetCount(); i++) + for (size_t i = 0; i < Entries.size(); i++) { UIThemeWindowEntry * entry = &Entries[i]; if (entry->WindowClass == newEntry->WindowClass) @@ -347,18 +347,18 @@ void UITheme::SetEntry(const UIThemeWindowEntry * newEntry) } } - Entries.Add(*newEntry); + Entries.push_back(*newEntry); } void UITheme::RemoveEntry(rct_windowclass windowClass) { // Remove existing entry - for (size_t i = 0; i < Entries.GetCount(); i++) + for (size_t i = 0; i < Entries.size(); i++) { UIThemeWindowEntry * entry = &Entries[i]; if (entry->WindowClass == windowClass) { - Entries.RemoveAt(i); + Entries.erase(Entries.begin() + i); break; } } @@ -485,7 +485,7 @@ UITheme UITheme::CreatePredefined(const utf8 * name, const UIThemeWindowEntry * numEntries++; } - theme.Entries = List(entries, numEntries); + theme.Entries = std::vector(entries, entries + numEntries); return theme; } @@ -499,21 +499,21 @@ namespace ThemeManager utf8 Name[96]; }; - utf8 * CurrentThemePath; - UITheme * CurrentTheme; - List AvailableThemes; - size_t ActiveAvailableThemeIndex = SIZE_MAX; - size_t NumPredefinedThemes = 0; + utf8 * CurrentThemePath; + UITheme * CurrentTheme; + std::vector AvailableThemes; + size_t ActiveAvailableThemeIndex = SIZE_MAX; + size_t NumPredefinedThemes = 0; void GetThemeFileName(utf8 * buffer, size_t bufferSize, const utf8 * name); bool EnsureThemeDirectoryExists(); void GetThemePath(utf8 * buffer, size_t bufferSize); - static void GetAvailableThemes(List * outThemes) + static void GetAvailableThemes(std::vector * outThemes) { Guard::ArgumentNotNull(outThemes, GUARD_LINE); - outThemes->Clear(); + outThemes->clear(); NumPredefinedThemes = 0; for (const UITheme * * predefinedTheme = PredefinedThemes; *predefinedTheme != nullptr; predefinedTheme++) @@ -521,7 +521,7 @@ namespace ThemeManager AvailableTheme theme; String::Set(theme.Path, sizeof(theme.Path), String::Empty); String::Set(theme.Name, sizeof(theme.Name), (*predefinedTheme)->Name); - outThemes->Add(theme); + outThemes->push_back(theme); NumPredefinedThemes++; } @@ -540,11 +540,11 @@ namespace ThemeManager Path::GetFileNameWithoutExtension(theme.Name, sizeof(theme.Name), fileInfo.path); GetThemeFileName(theme.Path, sizeof(theme.Path), theme.Name); - outThemes->Add(theme); + outThemes->push_back(theme); if (Path::Equals(CurrentThemePath, fileInfo.path)) { - ActiveAvailableThemeIndex = outThemes->GetCount() - 1; + ActiveAvailableThemeIndex = outThemes->size() - 1; } } platform_enumerate_files_end(handle); @@ -590,7 +590,7 @@ namespace ThemeManager static bool LoadThemeByName(const utf8 * name) { - for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++) + for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++) { if (String::Equals(name, ThemeManager::AvailableThemes[i].Name)) { @@ -660,7 +660,7 @@ extern "C" size_t theme_manager_get_num_available_themes() { - return ThemeManager::AvailableThemes.GetCount(); + return ThemeManager::AvailableThemes.size(); } const utf8 * theme_manager_get_available_theme_path(size_t index) @@ -766,7 +766,7 @@ extern "C" ThemeManager::CurrentTheme->WriteToFile(ThemeManager::CurrentThemePath); theme_manager_load_available_themes(); - for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++) + for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++) { if (Path::Equals(newPath, ThemeManager::AvailableThemes[i].Path)) { @@ -794,7 +794,7 @@ extern "C" ThemeManager::LoadTheme(newPath); theme_manager_load_available_themes(); - for (size_t i = 0; i < ThemeManager::AvailableThemes.GetCount(); i++) + for (size_t i = 0; i < ThemeManager::AvailableThemes.size(); i++) { if (Path::Equals(newPath, ThemeManager::AvailableThemes[i].Path)) { diff --git a/src/network/twitch.cpp b/src/network/twitch.cpp index 5139669f29..6de95de67f 100644 --- a/src/network/twitch.cpp +++ b/src/network/twitch.cpp @@ -29,7 +29,7 @@ #error HTTP must be enabled to use the TWITCH functionality. #endif -#include "../core/List.hpp" +#include #include "../core/Math.hpp" #include "../core/String.hpp" @@ -119,7 +119,7 @@ namespace Twitch static void ParseMessages(); static bool ShouldTrackMember(const AudienceMember * member); static bool ShouldMemberBeGuest(const AudienceMember * member); - static void ManageGuestNames(List &members); + static void ManageGuestNames(std::vector &members); static void ParseChatMessage(const char * message); static void DoChatMessageNews(const char * message); @@ -328,7 +328,7 @@ namespace Twitch http_json_response *jsonResponse = _twitchJsonResponse; if (json_is_array(jsonResponse->root)) { - List members; + std::vector members; size_t audienceCount = json_array_size(jsonResponse->root); for (size_t i = 0; i < audienceCount; i++) @@ -340,7 +340,7 @@ namespace Twitch member.ShouldTrack = ShouldTrackMember(&member); if (ShouldMemberBeGuest(&member)) { - members.Add(member); + members.push_back(member); } } } @@ -405,7 +405,7 @@ namespace Twitch return false; } - static void ManageGuestNames(List &members) + static void ManageGuestNames(std::vector &members) { // Check what followers are already in the park uint16 spriteIndex; @@ -462,13 +462,13 @@ namespace Twitch } // Rename non-named peeps to followers that aren't currently in the park. - if (members.GetCount() > 0) + if (members.size() > 0) { size_t memberIndex = SIZE_MAX; FOR_ALL_GUESTS(spriteIndex, peep) { size_t originalMemberIndex = memberIndex; - for (size_t i = memberIndex + 1; i < members.GetCount(); i++) + for (size_t i = memberIndex + 1; i < members.size(); i++) { if (!members[i].Exists) { diff --git a/src/rct1/S4Importer.cpp b/src/rct1/S4Importer.cpp index cf8e3a510c..64ff11db58 100644 --- a/src/rct1/S4Importer.cpp +++ b/src/rct1/S4Importer.cpp @@ -14,10 +14,12 @@ *****************************************************************************/ #pragma endregion +#include +#include "../core/Collections.hpp" #include "../core/Console.hpp" #include "../core/Exception.hpp" #include "../core/Guard.hpp" -#include "../core/List.hpp" +#include "../core/Memory.hpp" #include "../core/Path.hpp" #include "../core/String.hpp" #include "../core/Util.hpp" @@ -51,10 +53,38 @@ extern "C" #include "../ride/ride_data.h" } -static bool ObjectNameComparer(const char * a, const char * b) +class EntryList { - return String::Equals(a, b, true); -} +private: + std::vector _entries; + +public: + size_t GetCount() const + { + return _entries.size(); + } + + const std::vector & GetEntries() const + { + return _entries; + } + + size_t GetOrAddEntry(const char * entryName) + { + size_t entryIndex = Collections::IndexOf(_entries, entryName, true); + if (entryIndex == SIZE_MAX) + { + entryIndex = _entries.size(); + _entries.push_back(entryName); + } + return entryIndex; + } + + void AddRange(std::initializer_list initializerList) + { + Collections::AddRange(_entries, initializerList); + } +}; class S4Importer : public IS4Importer { @@ -64,13 +94,13 @@ private: uint8 _gameVersion; // Lists of dynamic object entries - List _rideEntries; - List _smallSceneryEntries; - List _largeSceneryEntries; - List _wallEntries; - List _pathEntries; - List _pathAdditionEntries; - List _sceneryGroupEntries; + EntryList _rideEntries; + EntryList _smallSceneryEntries; + EntryList _largeSceneryEntries; + EntryList _wallEntries; + EntryList _pathEntries; + EntryList _pathAdditionEntries; + EntryList _sceneryGroupEntries; // Lookup tables for converting from RCT1 hard coded types to the new dynamic object entries uint8 _rideTypeToRideEntryMap[96]; @@ -335,7 +365,7 @@ private: if (sceneryTheme != 0 && _sceneryThemeTypeToEntryMap[sceneryTheme] == 255) continue; - List objects = RCT1::GetSceneryObjects(sceneryTheme); + std::vector objects = RCT1::GetSceneryObjects(sceneryTheme); for (const char * objectName : objects) { rct_object_entry * foundEntry = object_list_find_by_name(objectName); @@ -349,17 +379,13 @@ private: case OBJECT_TYPE_PATHS: case OBJECT_TYPE_PATH_BITS: { - List * entries = GetEntryList(objectType); + EntryList * entries = GetEntryList(objectType); - // Ran out of available entries - if (entries->GetCount() >= (size_t)object_entry_group_counts[objectType]) + // Check if there are spare entries available + size_t maxEntries = (size_t)object_entry_group_counts[objectType]; + if (entries->GetCount() < maxEntries) { - break; - } - - if (!entries->Contains(objectName, ObjectNameComparer)) - { - entries->Add(objectName); + entries->GetOrAddEntry(objectName); } break; } @@ -375,13 +401,8 @@ private: if (_rideTypeToRideEntryMap[rideType] == 255) { const char * entryName = RCT1::GetRideTypeObject(rideType); + size_t entryIndex = _rideEntries.GetOrAddEntry(entryName); - size_t entryIndex = _rideEntries.IndexOf(entryName, ObjectNameComparer); - if (entryIndex == SIZE_MAX) - { - entryIndex = _rideEntries.GetCount(); - _rideEntries.Add(entryName); - } _rideTypeToRideEntryMap[rideType] = (uint8)entryIndex; } } @@ -392,13 +413,8 @@ private: if (_vehicleTypeToRideEntryMap[vehicleType] == 255) { const char * entryName = RCT1::GetVehicleObject(vehicleType); + size_t entryIndex = _rideEntries.GetOrAddEntry(entryName); - size_t entryIndex = _rideEntries.IndexOf(entryName, ObjectNameComparer); - if (entryIndex == SIZE_MAX) - { - entryIndex = _rideEntries.GetCount(); - _rideEntries.Add(entryName); - } _vehicleTypeToRideEntryMap[vehicleType] = (uint8)entryIndex; _rideTypeToRideEntryMap[rideType] = (uint8)entryIndex; } @@ -410,8 +426,9 @@ private: if (_smallSceneryTypeToEntryMap[smallSceneryType] == 255) { const char * entryName = RCT1::GetSmallSceneryObject(smallSceneryType); - _smallSceneryTypeToEntryMap[smallSceneryType] = (uint8)_smallSceneryEntries.GetCount(); - _smallSceneryEntries.Add(entryName); + size_t entryIndex = _smallSceneryEntries.GetOrAddEntry(entryName); + + _smallSceneryTypeToEntryMap[smallSceneryType] = (uint8)entryIndex; } } @@ -421,8 +438,9 @@ private: if (_largeSceneryTypeToEntryMap[largeSceneryType] == 255) { const char * entryName = RCT1::GetLargeSceneryObject(largeSceneryType); - _largeSceneryTypeToEntryMap[largeSceneryType] = (uint8)_largeSceneryEntries.GetCount(); - _largeSceneryEntries.Add(entryName); + size_t entryIndex = _largeSceneryEntries.GetOrAddEntry(entryName); + + _largeSceneryTypeToEntryMap[largeSceneryType] = (uint8)entryIndex; } } @@ -432,8 +450,9 @@ private: if (_wallTypeToEntryMap[wallType] == 255) { const char * entryName = RCT1::GetWallObject(wallType); - _wallTypeToEntryMap[wallType] = (uint8)_wallEntries.GetCount(); - _wallEntries.Add(entryName); + size_t entryIndex = _wallEntries.GetOrAddEntry(entryName); + + _wallTypeToEntryMap[wallType] = (uint8)entryIndex; } } @@ -443,17 +462,9 @@ private: if (_pathTypeToEntryMap[pathType] == 255) { const char * entryName = RCT1::GetPathObject(pathType); + size_t entryIndex = _pathEntries.GetOrAddEntry(entryName); - size_t index = _pathEntries.IndexOf(entryName, ObjectNameComparer); - if (index != SIZE_MAX) - { - _pathTypeToEntryMap[pathType] = (uint8)index; - } - else - { - _pathTypeToEntryMap[pathType] = (uint8)_pathEntries.GetCount(); - _pathEntries.Add(entryName); - } + _pathTypeToEntryMap[pathType] = (uint8)entryIndex; } } @@ -467,8 +478,9 @@ private: if (_pathAdditionTypeToEntryMap[normalisedPathAdditionType] == 255) { const char * entryName = RCT1::GetPathAddtionObject(normalisedPathAdditionType); - _pathAdditionTypeToEntryMap[normalisedPathAdditionType] = (uint8)_pathAdditionEntries.GetCount(); - _pathAdditionEntries.Add(entryName); + size_t entryIndex = _pathAdditionEntries.GetOrAddEntry(entryName); + + _pathAdditionTypeToEntryMap[normalisedPathAdditionType] = (uint8)entryIndex; } _pathAdditionTypeToEntryMap[pathAdditionType] = _pathAdditionTypeToEntryMap[normalisedPathAdditionType]; @@ -486,16 +498,15 @@ private: else { const char * entryName = RCT1::GetSceneryGroupObject(sceneryThemeType); - uint8 entryIndex = (uint8)_sceneryGroupEntries.GetCount(); - if (entryIndex >= 19) + if (_sceneryGroupEntries.GetCount() >= 19) { Console::WriteLine("Warning: More than 19 (max scenery groups) in RCT1 park."); Console::WriteLine(" [%s] scenery group not added.", entryName); } else { - _sceneryThemeTypeToEntryMap[sceneryThemeType] = (uint8)_sceneryGroupEntries.GetCount(); - _sceneryGroupEntries.Add(entryName); + size_t entryIndex = _sceneryGroupEntries.GetOrAddEntry(entryName); + _sceneryThemeTypeToEntryMap[sceneryThemeType] = (uint8)entryIndex; } } } @@ -779,7 +790,7 @@ private: LoadObjects(OBJECT_TYPE_PATHS, _pathEntries); LoadObjects(OBJECT_TYPE_PATH_BITS, _pathAdditionEntries); LoadObjects(OBJECT_TYPE_SCENERY_SETS, _sceneryGroupEntries); - LoadObjects(OBJECT_TYPE_BANNERS, List({ + LoadObjects(OBJECT_TYPE_BANNERS, std::vector({ "BN1 ", "BN2 ", "BN3 ", @@ -790,11 +801,16 @@ private: "BN8 ", "BN9 " })); - LoadObjects(OBJECT_TYPE_PARK_ENTRANCE, List({ "PKENT1 " })); - LoadObjects(OBJECT_TYPE_WATER, List({ "WTRCYAN " })); + LoadObjects(OBJECT_TYPE_PARK_ENTRANCE, std::vector({ "PKENT1 " })); + LoadObjects(OBJECT_TYPE_WATER, std::vector({ "WTRCYAN " })); } - void LoadObjects(uint8 objectType, List entries) + void LoadObjects(uint8 objectType, const EntryList &entries) + { + LoadObjects(objectType, entries.GetEntries()); + } + + void LoadObjects(uint8 objectType, const std::vector &entries) { IObjectManager * objectManager = GetObjectManager(); @@ -1516,7 +1532,7 @@ private: } } - List * GetEntryList(uint8 objectType) + EntryList * GetEntryList(uint8 objectType) { switch (objectType) { case OBJECT_TYPE_RIDE: return &_rideEntries; @@ -1640,7 +1656,7 @@ extern "C" */ int vehicle_preference_compare(uint8 rideType, const char * a, const char * b) { - List rideEntryOrder = RCT1::GetPreferedRideEntryOrder(rideType); + std::vector rideEntryOrder = RCT1::GetPreferedRideEntryOrder(rideType); for (const char * object : rideEntryOrder) { if (String::Equals(object, a, true)) diff --git a/src/rct1/Tables.h b/src/rct1/Tables.h index a06a3854e0..e723ceaffe 100644 --- a/src/rct1/Tables.h +++ b/src/rct1/Tables.h @@ -20,7 +20,7 @@ #ifdef __cplusplus -#include "../core/List.hpp" +#include namespace RCT1 { @@ -42,9 +42,9 @@ namespace RCT1 const char * GetPathAddtionObject(uint8 pathAdditionType); const char * GetSceneryGroupObject(uint8 sceneryGroupType); - const List GetSceneryObjects(uint8 sceneryType); + const std::vector GetSceneryObjects(uint8 sceneryType); - const List GetPreferedRideEntryOrder(uint8 rideType); + const std::vector GetPreferedRideEntryOrder(uint8 rideType); } extern "C" { diff --git a/src/rct1/tables.cpp b/src/rct1/tables.cpp index 7c6f734098..dfd14d8465 100644 --- a/src/rct1/tables.cpp +++ b/src/rct1/tables.cpp @@ -15,7 +15,7 @@ #pragma endregion #include "../common.h" -#include "../core/List.hpp" +#include "../core/Guard.hpp" #include "../core/Util.hpp" #include "Tables.h" @@ -962,9 +962,9 @@ namespace RCT1 return map[waterType]; } - const List GetPreferedRideEntryOrder(uint8 rideType) + const std::vector GetPreferedRideEntryOrder(uint8 rideType) { - static const List preferedRideEntryOrder[] = + static const std::vector preferedRideEntryOrder[] = { { "SPDRCR "}, // RIDE_TYPE_SPIRAL_ROLLER_COASTER { "TOGST "}, // RIDE_TYPE_STAND_UP_ROLLER_COASTER @@ -1061,15 +1061,15 @@ namespace RCT1 return preferedRideEntryOrder[rideType]; } - const List GetSceneryObjects(uint8 sceneryType) + const std::vector GetSceneryObjects(uint8 sceneryType) { - static const List map[] = + static const std::vector map[] = { // RCT1_SCENERY_THEME_GENERAL (trees, shrubs, garden, walls, fence, path accessories) { "TIC ", "TLC ", "TMC ", "TMP ", "TITC ", "TGHC ", "TAC ", "TGHC2 ", "TCJ ", "TMBJ ", "TCF ", "TCL ", "TRF ", "TRF2 ", "TEL ", "TAP ", "TSP ", "TMZP ", "TCRP ", "TBP ", "TLP ", "TWP ", "TAS ", "TMG ", "TWW ", "TSB ", "TVL ", "TCY ", "TNS ", "TWN ", "TCE ", "TCO ", "THL ", "TCC ", "TF1 ", "TF2 ", "TCT ", "TH1 ", "TH2 ", "TPM ", "TROPT1 ", "TS0 ", "TS1 ", "TS2 ", "TS3 ", "TS4 ", "TS5 ", "TS6 ", "TEF ", "TAL ", "TSQ ", "THT ", "TCB ", "TDM ", "TSD ", "TORN1 ", "TORN2 ", "TGS ", "TUS ", "TBC ", "TSC ", "TWF ", "TSH0 ", "TSH1 ", "TSH2 ", "TSH3 ", "TSH4 ", "TSH5 ", "TDF ", "TSH ", "THRS ", "TSTD ", "TBR ", "TTF ", "WHG ", "WHGG ", "WCH ", "WCHG ", "TG1 ", "TG2 ", "TG3 ", "TG4 ", "TG5 ", "TG6 ", "TG7 ", "TG8 ", "TG9 ", "TG10 ", "TG11 ", "TG12 ", "TG13 ", "TG14 ", "TG15 ", "TG16 ", "TG17 ", "TG18 ", "TG19 ", "TG20 ", "TG21 ", - "WBR1A ", "WBR2A ", "WALLBB34", "WALLTN32", "TNTROOF1", "WALLBB33", "WALLBB32", "WALLBB16", "WALLBB8 ", "ROOF5 ", "ROOF7 ", "WALLRS32", "WALLRS16", "WALLRS8 ", "WALLBR32", "WALLBR16", "WALLBR8 ", "WALLBRDR", "WALLBRWN", "BRBASE ", "ROOF1 ", "ROOF2 ", "ROOF3 ", "ROOF4 ", "WALLCB32", "WALLCB16", "WALLCB8 ", "WALLCBDR", "WALLCBWN", "BRBASE2 ", "CWBCRV33", "CWBCRV32", "BRCRRF1 ", "ROOF6 ", "ROOF8 ", "WALLCF32", "WALLCF16", "WALLCF8 ", "WALLCFDR", "WALLCFWN", "WALLCFAR", "BRBASE3 ", "CWFCRV33", "CWFCRV32", "BRCRRF2 ", "ROOF9 ", "ROOF11 ", "ROOF10 ", "ROOF12 ", "CORROOF2", "WALLCO16", "CORROOF ", "WALLLT32", "WALLSK16", "WALLSK32", "SKTDW2 ", "SKTDW ", "SKTBASE ", "SKTBASET", "SUPPW2 ", "SUPPW1 ", "SUPPW3 ", "SUPPLEG1", "SUPPLEG2", "SUMRF ", "WALLRH32" + "WBR1A ", "WBR2A ", "WALLBB34", "WALLTN32", "TNTROOF1", "WALLBB33", "WALLBB32", "WALLBB16", "WALLBB8 ", "ROOF5 ", "ROOF7 ", "WALLRS32", "WALLRS16", "WALLRS8 ", "WALLBR32", "WALLBR16", "WALLBR8 ", "WALLBRDR", "WALLBRWN", "BRBASE ", "ROOF1 ", "ROOF2 ", "ROOF3 ", "ROOF4 ", "WALLCB32", "WALLCB16", "WALLCB8 ", "WALLCBDR", "WALLCBWN", "BRBASE2 ", "CWBCRV33", "CWBCRV32", "BRCRRF1 ", "ROOF6 ", "ROOF8 ", "WALLCF32", "WALLCF16", "WALLCF8 ", "WALLCFDR", "WALLCFWN", "WALLCFAR", "BRBASE3 ", "CWFCRV33", "CWFCRV32", "BRCRRF2 ", "ROOF9 ", "ROOF11 ", "ROOF10 ", "ROOF12 ", "CORROOF2", "WALLCO16", "CORROOF ", "WALLLT32", "WALLSK16", "WALLSK32", "SKTDW2 ", "SKTDW ", "SKTBASE ", "SKTBASET", "SUPPW2 ", "SUPPW1 ", "SUPPW3 ", "SUPPLEG1", "SUPPLEG2", "SUMRF ", "WALLRH32", "WMF ", "WMFG ", "WSW ", "WSWG ", "WFW1 ", "WFWG ", "WPF ", "WPFG ", "WSW1 ", "WSW2 ", "WBR1 ", "WBRG ", "WBR2 ", "WBR3 ", "WALLMM16", "WALLMM17", "LAMP1 ", "LAMP2 ", "LITTER1 ", "BENCH1 ", "QTV1 ", "BN1 ", "WALLPOST", "WALLSIGN", "SSIG1 ", "SSIG2 ", "SSIG3 ", "SSIG4 " }, // RCT1_SCENERY_THEME_MINE