From 46d69126ea20e6086b5df217fc72e5269543ee6d Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 7 May 2020 19:35:30 +0100 Subject: [PATCH] Split identifier and legacyIdentifier on Object --- distribution/openrct2.d.ts | 12 +++- src/openrct2/localisation/Language.cpp | 8 +-- src/openrct2/localisation/Language.h | 3 +- src/openrct2/localisation/LanguagePack.cpp | 7 +-- src/openrct2/localisation/LanguagePack.h | 5 +- .../localisation/LocalisationService.cpp | 6 +- .../localisation/LocalisationService.h | 5 +- src/openrct2/object/BannerObject.cpp | 4 +- src/openrct2/object/FootpathItemObject.cpp | 4 +- src/openrct2/object/Object.cpp | 25 ++++---- src/openrct2/object/Object.h | 35 +++++------ src/openrct2/object/ObjectFactory.cpp | 18 ++++-- src/openrct2/object/ObjectRepository.cpp | 8 +-- src/openrct2/object/ObjectRepository.h | 4 +- src/openrct2/object/SmallSceneryObject.cpp | 62 +++++++++---------- src/openrct2/object/WallObject.cpp | 6 +- src/openrct2/scripting/ScObject.hpp | 13 +++- 17 files changed, 121 insertions(+), 104 deletions(-) diff --git a/distribution/openrct2.d.ts b/distribution/openrct2.d.ts index e68e32010f..0b954f223d 100644 --- a/distribution/openrct2.d.ts +++ b/distribution/openrct2.d.ts @@ -480,10 +480,18 @@ declare global { readonly index: number; /** - * The unique name identifier of the object, e.g. "BURGB ". - * This may have trailing spaces if the name is shorter than 8 characters. + * The unique identifier of the object, e.g. "rct2.burgb". + * Only JSON objects will have an identifier. */ readonly identifier: string; + + /** + * The original unique identifier of the object, e.g. "BURGB ". + * This may have trailing spaces if the name is shorter than 8 characters. + * Only .DAT objects or JSON objects based on .DAT objects will have legacy identifiers. + */ + readonly legacyIdentifier: string; + /** * The name in the user's current language. */ diff --git a/src/openrct2/localisation/Language.cpp b/src/openrct2/localisation/Language.cpp index c8be0188e4..b430b4deb3 100644 --- a/src/openrct2/localisation/Language.cpp +++ b/src/openrct2/localisation/Language.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -125,12 +125,6 @@ void language_free_object_string(rct_string_id stringId) localisationService.FreeObjectString(stringId); } -rct_string_id language_get_object_override_string_id(const char* identifier, uint8_t index) -{ - const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); - return localisationService.GetObjectOverrideStringId(identifier, index); -} - rct_string_id language_allocate_object_string(const std::string& target) { auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); diff --git a/src/openrct2/localisation/Language.h b/src/openrct2/localisation/Language.h index 9a0d40886d..89c4ad712c 100644 --- a/src/openrct2/localisation/Language.h +++ b/src/openrct2/localisation/Language.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -105,7 +105,6 @@ std::string rct2_to_utf8(const std::string_view& src, RCT2LanguageId languageId) std::string utf8_to_rct2(const std::string_view& src); bool language_get_localised_scenario_strings(const utf8* scenarioFilename, rct_string_id* outStringIds); void language_free_object_string(rct_string_id stringId); -rct_string_id language_get_object_override_string_id(const char* identifier, uint8_t index); rct_string_id language_allocate_object_string(const std::string& target); std::string language_convert_string_to_tokens(const std::string_view& s); std::string language_convert_string(const std::string_view& s); diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index 8509ae7aa4..ec6e758d1e 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -198,15 +198,14 @@ public: } } - rct_string_id GetObjectOverrideStringId(const char* objectIdentifier, uint8_t index) override + rct_string_id GetObjectOverrideStringId(const std::string_view& legacyIdentifier, uint8_t index) override { - Guard::ArgumentNotNull(objectIdentifier); Guard::Assert(index < ObjectOverrideMaxStringCount); int32_t ooIndex = 0; for (const ObjectOverride& objectOverride : _objectOverrides) { - if (strncmp(objectOverride.name, objectIdentifier, 8) == 0) + if (std::string_view(objectOverride.name, 8) == legacyIdentifier) { if (objectOverride.strings[index].empty()) { diff --git a/src/openrct2/localisation/LanguagePack.h b/src/openrct2/localisation/LanguagePack.h index b65a933eb9..29db0cd165 100644 --- a/src/openrct2/localisation/LanguagePack.h +++ b/src/openrct2/localisation/LanguagePack.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -12,6 +12,7 @@ #include "../common.h" #include +#include interface ILanguagePack { @@ -23,7 +24,7 @@ interface ILanguagePack virtual void RemoveString(rct_string_id stringId) abstract; virtual void SetString(rct_string_id stringId, const std::string& str) abstract; virtual const utf8* GetString(rct_string_id stringId) const abstract; - virtual rct_string_id GetObjectOverrideStringId(const char* objectIdentifier, uint8_t index) abstract; + virtual rct_string_id GetObjectOverrideStringId(const std::string_view& legacyIdentifier, uint8_t index) abstract; virtual rct_string_id GetScenarioOverrideStringId(const utf8* scenarioFilename, uint8_t index) abstract; }; diff --git a/src/openrct2/localisation/LocalisationService.cpp b/src/openrct2/localisation/LocalisationService.cpp index 97588214fc..1378e091be 100644 --- a/src/openrct2/localisation/LocalisationService.cpp +++ b/src/openrct2/localisation/LocalisationService.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -122,13 +122,13 @@ std::tuple LocalisationService::Get return std::make_tuple(result0, result1, result2); } -rct_string_id LocalisationService::GetObjectOverrideStringId(const char* identifier, uint8_t index) const +rct_string_id LocalisationService::GetObjectOverrideStringId(const std::string_view& legacyIdentifier, uint8_t index) const { if (_languageCurrent == nullptr) { return STR_NONE; } - return _languageCurrent->GetObjectOverrideStringId(identifier, index); + return _languageCurrent->GetObjectOverrideStringId(legacyIdentifier, index); } rct_string_id LocalisationService::AllocateObjectString(const std::string& target) diff --git a/src/openrct2/localisation/LocalisationService.h b/src/openrct2/localisation/LocalisationService.h index 01cc53e5a1..6bab2be10b 100644 --- a/src/openrct2/localisation/LocalisationService.h +++ b/src/openrct2/localisation/LocalisationService.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -14,6 +14,7 @@ #include #include #include +#include #include interface ILanguagePack; @@ -56,7 +57,7 @@ namespace OpenRCT2::Localisation const char* GetString(rct_string_id id) const; std::tuple GetLocalisedScenarioStrings( const std::string& scenarioFilename) const; - rct_string_id GetObjectOverrideStringId(const char* identifier, uint8_t index) const; + rct_string_id GetObjectOverrideStringId(const std::string_view& legacyIdentifier, uint8_t index) const; std::string GetLanguagePath(uint32_t languageId) const; void OpenLanguage(int32_t id, IObjectManager& objectManager); diff --git a/src/openrct2/object/BannerObject.cpp b/src/openrct2/object/BannerObject.cpp index 32d58cc1d8..bba21f706d 100644 --- a/src/openrct2/object/BannerObject.cpp +++ b/src/openrct2/object/BannerObject.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -41,7 +41,7 @@ void BannerObject::ReadLegacy(IReadObjectContext* context, IStream* stream) // Add banners to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. - auto identifier = GetIdentifier(); + auto identifier = GetLegacyIdentifier(); auto& objectRepository = context->GetObjectRepository(); auto item = objectRepository.FindObject(identifier); diff --git a/src/openrct2/object/FootpathItemObject.cpp b/src/openrct2/object/FootpathItemObject.cpp index 38b0135e9f..c21a2b8f8d 100644 --- a/src/openrct2/object/FootpathItemObject.cpp +++ b/src/openrct2/object/FootpathItemObject.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -45,7 +45,7 @@ void FootpathItemObject::ReadLegacy(IReadObjectContext* context, IStream* stream // Add path bits to 'Signs and items for footpaths' group, rather than lumping them in the Miscellaneous tab. // Since this is already done the other way round for original items, avoid adding those to prevent duplicates. - auto identifier = GetIdentifier(); + auto identifier = GetLegacyIdentifier(); auto& objectRepository = context->GetObjectRepository(); auto item = objectRepository.FindObject(identifier); diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index abef82fb44..c1ba1f8c81 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -9,28 +9,22 @@ #include "Object.h" +#include "../Context.h" #include "../core/Memory.hpp" #include "../core/String.hpp" #include "../localisation/Language.h" +#include "../localisation/LocalisationService.h" #include "../localisation/StringIds.h" #include "../world/Scenery.h" #include "ObjectLimits.h" #include +#include #include Object::Object(const rct_object_entry& entry) { _objectEntry = entry; - - char name[DAT_NAME_LENGTH + 1] = { 0 }; - std::copy_n(entry.name, DAT_NAME_LENGTH, name); - _identifier = String::Duplicate(name); -} - -Object::~Object() -{ - Memory::Free(_identifier); } void* Object::GetLegacyData() @@ -45,8 +39,9 @@ void Object::ReadLegacy(IReadObjectContext* context, IStream* stream) std::string Object::GetOverrideString(uint8_t index) const { - const char* identifier = GetIdentifier(); - rct_string_id stringId = language_get_object_override_string_id(identifier, index); + auto legacyIdentifier = GetLegacyIdentifier(); + const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); + auto stringId = localisationService.GetObjectOverrideStringId(legacyIdentifier, index); const utf8* result = nullptr; if (stringId != STR_NONE) @@ -115,6 +110,12 @@ std::string Object::GetName(int32_t language) const return GetString(language, OBJ_STRING_ID_NAME); } +void rct_object_entry::SetName(const std::string_view& value) +{ + std::memset(name, ' ', sizeof(name)); + std::memcpy(name, value.data(), std::min(sizeof(name), value.size())); +} + std::optional rct_object_entry::GetSceneryType() const { switch (GetType()) diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index 6cbce012d9..b0f85f9e3f 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -13,6 +13,7 @@ #include "ImageTable.h" #include "StringTable.h" +#include #include #include #include @@ -96,19 +97,7 @@ struct rct_object_entry return std::string_view(name, std::size(name)); } - void SetName(const char* value) - { - auto src = value; - for (size_t i = 0; i < sizeof(name); i++) - { - auto dc = ' '; - if (*src != '\0') - { - dc = *src++; - } - name[i] = dc; - } - } + void SetName(const std::string_view& value); uint8_t GetType() const { @@ -155,6 +144,7 @@ interface IReadObjectContext { virtual ~IReadObjectContext() = default; + virtual std::string_view GetObjectIdentifier() abstract; virtual IObjectRepository& GetObjectRepository() abstract; virtual bool ShouldLoadImages() abstract; virtual std::vector GetData(const std::string_view& path) abstract; @@ -171,7 +161,7 @@ interface IReadObjectContext class Object { private: - char* _identifier; + std::string _identifier; rct_object_entry _objectEntry{}; StringTable _stringTable; ImageTable _imageTable; @@ -198,7 +188,16 @@ protected: public: explicit Object(const rct_object_entry& entry); - virtual ~Object(); + virtual ~Object() = default; + + std::string_view GetIdentifier() const + { + return _identifier; + } + void SetIdentifier(const std::string_view& identifier) + { + _identifier = identifier; + } void MarkAsJsonObject() { @@ -211,9 +210,9 @@ public: }; // Legacy data structures - const char* GetIdentifier() const + std::string_view GetLegacyIdentifier() const { - return _identifier; + return _objectEntry.GetName(); } const rct_object_entry* GetObjectEntry() const { diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index 41e591df0d..9160462542 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -87,7 +87,7 @@ private: IObjectRepository& _objectRepository; const IFileDataRetriever* _fileDataRetriever; - std::string _objectName; + std::string _identifier; bool _loadImages; std::string _basePath; bool _wasWarning = false; @@ -104,15 +104,20 @@ public: } ReadObjectContext( - IObjectRepository& objectRepository, const std::string& objectName, bool loadImages, + IObjectRepository& objectRepository, const std::string& identifier, bool loadImages, const IFileDataRetriever* fileDataRetriever) : _objectRepository(objectRepository) , _fileDataRetriever(fileDataRetriever) - , _objectName(objectName) + , _identifier(identifier) , _loadImages(loadImages) { } + std::string_view GetObjectIdentifier() override + { + return _identifier; + } + IObjectRepository& GetObjectRepository() override { return _objectRepository; @@ -138,7 +143,7 @@ public: if (!String::IsNullOrEmpty(text)) { - Console::Error::WriteLine("[%s] Warning (%d): %s", _objectName.c_str(), code, text); + Console::Error::WriteLine("[%s] Warning (%d): %s", _identifier.c_str(), code, text); } } @@ -148,7 +153,7 @@ public: if (!String::IsNullOrEmpty(text)) { - Console::Error::WriteLine("[%s] Error (%d): %s", _objectName.c_str(), code, text); + Console::Error::WriteLine("[%s] Error (%d): %s", _identifier.c_str(), code, text); } } }; @@ -429,6 +434,7 @@ namespace ObjectFactory std::memcpy(entry.name, originalName.c_str(), minLength); result = CreateObject(entry); + result->SetIdentifier(id); result->MarkAsJsonObject(); auto readContext = ReadObjectContext(objectRepository, id, !gOpenRCT2NoGraphics, fileRetriever); result->ReadJson(&readContext, jRoot); diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index 808e5cc2c4..9673f276a7 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -252,12 +252,10 @@ public: return _items.data(); } - const ObjectRepositoryItem* FindObject(const utf8* name) const override + const ObjectRepositoryItem* FindObject(const std::string_view& legacyIdentifier) const override { rct_object_entry entry = {}; - utf8 entryName[9] = { ' ' }; - String::Set(entryName, sizeof(entryName), name); - std::copy_n(entryName, 8, entry.name); + entry.SetName(legacyIdentifier); auto kvp = _itemMap.find(entry); if (kvp != _itemMap.end()) diff --git a/src/openrct2/object/ObjectRepository.h b/src/openrct2/object/ObjectRepository.h index 8554ac2ff1..2966d06deb 100644 --- a/src/openrct2/object/ObjectRepository.h +++ b/src/openrct2/object/ObjectRepository.h @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -67,7 +67,7 @@ interface IObjectRepository virtual void Construct(int32_t language) abstract; virtual size_t GetNumObjects() const abstract; virtual const ObjectRepositoryItem* GetObjects() const abstract; - virtual const ObjectRepositoryItem* FindObject(const utf8* name) const abstract; + virtual const ObjectRepositoryItem* FindObject(const std::string_view& legacyIdentifier) const abstract; virtual const ObjectRepositoryItem* FindObject(const rct_object_entry* objectEntry) const abstract; virtual Object* LoadObject(const ObjectRepositoryItem* ori) abstract; diff --git a/src/openrct2/object/SmallSceneryObject.cpp b/src/openrct2/object/SmallSceneryObject.cpp index e24256fe89..e5830acd82 100644 --- a/src/openrct2/object/SmallSceneryObject.cpp +++ b/src/openrct2/object/SmallSceneryObject.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -156,14 +156,14 @@ std::vector SmallSceneryObject::ReadFrameOffsets(IStream* stream) // clang-format off void SmallSceneryObject::PerformFixes() { - std::string identifier = GetIdentifier(); + auto identifier = GetLegacyIdentifier(); static const rct_object_entry scgWalls = Object::GetScgWallsHeader(); // ToonTowner's base blocks. Make them allow supports on top and put them in the Walls and Roofs group. - if (String::Equals(identifier, "XXBBCL01") || - String::Equals(identifier, "XXBBMD01") || - String::Equals(identifier, "XXBBBR01") || - String::Equals(identifier, "ARBASE2 ")) + if (identifier == "XXBBCL01" || + identifier == "XXBBMD01" || + identifier == "XXBBBR01" || + identifier == "ARBASE2 ") { SetPrimarySceneryGroup(&scgWalls); @@ -171,48 +171,48 @@ void SmallSceneryObject::PerformFixes() } // ToonTowner's regular roofs. Put them in the Walls and Roofs group. - if (String::Equals(identifier, "TTRFTL02") || - String::Equals(identifier, "TTRFTL03") || - String::Equals(identifier, "TTRFTL04") || - String::Equals(identifier, "TTRFTL07") || - String::Equals(identifier, "TTRFTL08")) + if (identifier == "TTRFTL02" || + identifier == "TTRFTL03" || + identifier == "TTRFTL04" || + identifier == "TTRFTL07" || + identifier == "TTRFTL08") { SetPrimarySceneryGroup(&scgWalls); } // ToonTowner's Pirate roofs. Make them show up in the Pirate Theming. - if (String::Equals(identifier, "TTPIRF02") || - String::Equals(identifier, "TTPIRF03") || - String::Equals(identifier, "TTPIRF04") || - String::Equals(identifier, "TTPIRF05") || - String::Equals(identifier, "TTPIRF07") || - String::Equals(identifier, "TTPIRF08") || - String::Equals(identifier, "TTPRF09 ") || - String::Equals(identifier, "TTPRF10 ") || - String::Equals(identifier, "TTPRF11 ")) + if (identifier == "TTPIRF02" || + identifier == "TTPIRF03" || + identifier == "TTPIRF04" || + identifier == "TTPIRF05" || + identifier == "TTPIRF07" || + identifier == "TTPIRF08" || + identifier == "TTPRF09 " || + identifier == "TTPRF10 " || + identifier == "TTPRF11 ") { static const rct_object_entry scgPirat = GetScgPiratHeader(); SetPrimarySceneryGroup(&scgPirat); } // ToonTowner's wooden roofs. Make them show up in the Mine Theming. - if (String::Equals(identifier, "TTRFWD01") || - String::Equals(identifier, "TTRFWD02") || - String::Equals(identifier, "TTRFWD03") || - String::Equals(identifier, "TTRFWD04") || - String::Equals(identifier, "TTRFWD05") || - String::Equals(identifier, "TTRFWD06") || - String::Equals(identifier, "TTRFWD07") || - String::Equals(identifier, "TTRFWD08")) + if (identifier == "TTRFWD01" || + identifier == "TTRFWD02" || + identifier == "TTRFWD03" || + identifier == "TTRFWD04" || + identifier == "TTRFWD05" || + identifier == "TTRFWD06" || + identifier == "TTRFWD07" || + identifier == "TTRFWD08") { static const rct_object_entry scgMine = GetScgMineHeader(); SetPrimarySceneryGroup(&scgMine); } // ToonTowner's glass roofs. Make them show up in the Abstract Theming. - if (String::Equals(identifier, "TTRFGL01") || - String::Equals(identifier, "TTRFGL02") || - String::Equals(identifier, "TTRFGL03")) + if (identifier == "TTRFGL01" || + identifier == "TTRFGL02" || + identifier == "TTRFGL03") { static const rct_object_entry scgAbstr = GetScgAbstrHeader(); SetPrimarySceneryGroup(&scgAbstr); diff --git a/src/openrct2/object/WallObject.cpp b/src/openrct2/object/WallObject.cpp index 64ba0dd5ba..94b8f7774b 100644 --- a/src/openrct2/object/WallObject.cpp +++ b/src/openrct2/object/WallObject.cpp @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2014-2019 OpenRCT2 developers + * Copyright (c) 2014-2020 OpenRCT2 developers * * For a complete list of all authors, please refer to contributors.md * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2 @@ -43,8 +43,8 @@ void WallObject::ReadLegacy(IReadObjectContext* context, IStream* stream) } // Autofix this object (will be turned into an official object later). - auto identifier = GetIdentifier(); - if (String::Equals(identifier, "XXWLBR03")) + auto identifier = GetLegacyIdentifier(); + if (identifier == "XXWLBR03") { _legacyType.wall.flags2 &= ~WALL_SCENERY_2_DOOR_SOUND_MASK; _legacyType.wall.flags2 |= (1u << WALL_SCENERY_2_DOOR_SOUND_SHIFT) & WALL_SCENERY_2_DOOR_SOUND_MASK; diff --git a/src/openrct2/scripting/ScObject.hpp b/src/openrct2/scripting/ScObject.hpp index 7eeb4bf0c5..e210f96dac 100644 --- a/src/openrct2/scripting/ScObject.hpp +++ b/src/openrct2/scripting/ScObject.hpp @@ -41,6 +41,7 @@ namespace OpenRCT2::Scripting dukglue_register_property(ctx, &ScObject::type_get, nullptr, "type"); dukglue_register_property(ctx, &ScObject::index_get, nullptr, "index"); dukglue_register_property(ctx, &ScObject::identifier_get, nullptr, "identifier"); + dukglue_register_property(ctx, &ScObject::legacyIdentifier_get, nullptr, "legacyIdentifier"); dukglue_register_property(ctx, &ScObject::name_get, nullptr, "name"); } @@ -83,7 +84,17 @@ namespace OpenRCT2::Scripting auto obj = GetObject(); if (obj != nullptr) { - return obj->GetIdentifier(); + return std::string(obj->GetIdentifier()); + } + return {}; + } + + std::string legacyIdentifier_get() const + { + auto obj = GetObject(); + if (obj != nullptr) + { + return std::string(obj->GetLegacyIdentifier()); } return {}; }