From b58a17c7311342603bacf431e194f39713fdc8b1 Mon Sep 17 00:00:00 2001 From: duncanspumpkin Date: Mon, 22 May 2023 08:50:19 +0100 Subject: [PATCH] Remove localisation object overrides --- src/openrct2/localisation/LanguagePack.cpp | 57 ------------------- src/openrct2/localisation/LanguagePack.h | 1 - .../localisation/LocalisationService.cpp | 9 --- .../localisation/LocalisationService.h | 1 - src/openrct2/object/Object.cpp | 21 +------ src/openrct2/object/Object.h | 1 - 6 files changed, 1 insertion(+), 89 deletions(-) diff --git a/src/openrct2/localisation/LanguagePack.cpp b/src/openrct2/localisation/LanguagePack.cpp index 51efc6209c..8fec52df7a 100644 --- a/src/openrct2/localisation/LanguagePack.cpp +++ b/src/openrct2/localisation/LanguagePack.cpp @@ -182,27 +182,6 @@ public: return nullptr; } - StringId GetObjectOverrideStringId(std::string_view legacyIdentifier, uint8_t index) override - { - Guard::Assert(index < ObjectOverrideMaxStringCount); - - int32_t ooIndex = 0; - for (const ObjectOverride& objectOverride : _objectOverrides) - { - if (std::string_view(objectOverride.name, 8) == legacyIdentifier) - { - if (objectOverride.strings[index].empty()) - { - return STR_NONE; - } - return ObjectOverrideBase + (ooIndex * ObjectOverrideMaxStringCount) + index; - } - ooIndex++; - } - - return STR_NONE; - } - StringId GetScenarioOverrideStringId(const utf8* scenarioFilename, uint8_t index) override { Guard::ArgumentNotNull(scenarioFilename); @@ -226,17 +205,6 @@ public: } private: - ObjectOverride* GetObjectOverride(const std::string& objectIdentifier) - { - for (auto& oo : _objectOverrides) - { - if (strncmp(oo.name, objectIdentifier.c_str(), 8) == 0) - { - return &oo; - } - } - return nullptr; - } ScenarioOverride* GetScenarioOverride(const std::string& scenarioIdentifier) { @@ -376,31 +344,6 @@ private: } sb.Append(codepoint); } - - if (closedCorrectly) - { - while (sb.GetLength() < 8) - { - sb.Append(' '); - } - if (sb.GetLength() == 8) - { - _currentGroup = sb.GetStdString(); - _currentObjectOverride = GetObjectOverride(_currentGroup); - _currentScenarioOverride = nullptr; - if (_currentObjectOverride == nullptr) - { - if (_objectOverrides.size() == MAX_OBJECT_OVERRIDES) - { - LOG_WARNING("Maximum number of localised object strings exceeded."); - } - - _objectOverrides.emplace_back(); - _currentObjectOverride = &_objectOverrides[_objectOverrides.size() - 1]; - std::copy_n(_currentGroup.c_str(), 8, _currentObjectOverride->name); - } - } - } } void ParseGroupScenario(IStringReader* reader) diff --git a/src/openrct2/localisation/LanguagePack.h b/src/openrct2/localisation/LanguagePack.h index f5b8b9e8be..45ba2b7ef2 100644 --- a/src/openrct2/localisation/LanguagePack.h +++ b/src/openrct2/localisation/LanguagePack.h @@ -26,7 +26,6 @@ struct ILanguagePack virtual void RemoveString(StringId stringId) abstract; virtual void SetString(StringId stringId, const std::string& str) abstract; virtual const utf8* GetString(StringId stringId) const abstract; - virtual StringId GetObjectOverrideStringId(std::string_view legacyIdentifier, uint8_t index) abstract; virtual StringId GetScenarioOverrideStringId(const utf8* scenarioFilename, uint8_t index) abstract; }; diff --git a/src/openrct2/localisation/LocalisationService.cpp b/src/openrct2/localisation/LocalisationService.cpp index 6716223312..a8985a5232 100644 --- a/src/openrct2/localisation/LocalisationService.cpp +++ b/src/openrct2/localisation/LocalisationService.cpp @@ -153,15 +153,6 @@ std::tuple LocalisationService::GetLocalisedScenar return std::make_tuple(result0, result1, result2); } -StringId LocalisationService::GetObjectOverrideStringId(std::string_view legacyIdentifier, uint8_t index) const -{ - if (_loadedLanguages.empty()) - { - return STR_NONE; - } - return _loadedLanguages[0]->GetObjectOverrideStringId(legacyIdentifier, index); -} - StringId LocalisationService::AllocateObjectString(const std::string& target) { if (_availableObjectStringIds.empty()) diff --git a/src/openrct2/localisation/LocalisationService.h b/src/openrct2/localisation/LocalisationService.h index d7b76b4c52..0bd2661299 100644 --- a/src/openrct2/localisation/LocalisationService.h +++ b/src/openrct2/localisation/LocalisationService.h @@ -59,7 +59,6 @@ namespace OpenRCT2::Localisation const char* GetString(StringId id) const; std::tuple GetLocalisedScenarioStrings(const std::string& scenarioFilename) const; - StringId GetObjectOverrideStringId(std::string_view legacyIdentifier, uint8_t index) const; std::string GetLanguagePath(uint32_t languageId) const; void OpenLanguage(int32_t id); diff --git a/src/openrct2/object/Object.cpp b/src/openrct2/object/Object.cpp index 94a3aff0e9..46f46d59db 100644 --- a/src/openrct2/object/Object.cpp +++ b/src/openrct2/object/Object.cpp @@ -115,28 +115,9 @@ void Object::PopulateTablesFromJson(IReadObjectContext* context, json_t& root) _usesFallbackImages = _imageTable.ReadJson(context, root); } -std::string Object::GetOverrideString(uint8_t index) const -{ - auto legacyIdentifier = GetLegacyIdentifier(); - const auto& localisationService = OpenRCT2::GetContext()->GetLocalisationService(); - auto stringId = localisationService.GetObjectOverrideStringId(legacyIdentifier, index); - - const utf8* result = nullptr; - if (stringId != STR_NONE) - { - result = LanguageGetString(stringId); - } - return String::ToStd(result); -} - std::string Object::GetString(ObjectStringID index) const { - auto sz = GetOverrideString(static_cast(index)); - if (sz.empty()) - { - sz = GetStringTable().GetString(index); - } - return sz; + return GetStringTable().GetString(index); } std::string Object::GetString(int32_t language, ObjectStringID index) const diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index c01bd6a75c..e5eab6d27e 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -220,7 +220,6 @@ protected: */ void PopulateTablesFromJson(IReadObjectContext* context, json_t& root); - std::string GetOverrideString(uint8_t index) const; std::string GetString(ObjectStringID index) const; std::string GetString(int32_t language, ObjectStringID index) const;