diff --git a/distribution/changelog.txt b/distribution/changelog.txt index bc9f9e3cca..c52a296f86 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Feature: [#11306] Path additions are now kept when replacing the path. - Fix: [#6119]: Advertising campaign for ride window not updated properly (original bug). - Fix: [#11072] Land and water tools working out of bounds (original bug). +- Fix: [#11259] Custom JSON object breaks saves. - Fix: [#11315] Ride that has never opened is shown as favorite ride of many guests. - Improved: [#6530] Allow water and land height changes on park borders. diff --git a/src/openrct2/object/Object.h b/src/openrct2/object/Object.h index faa521910d..eb02e35cbf 100644 --- a/src/openrct2/object/Object.h +++ b/src/openrct2/object/Object.h @@ -176,6 +176,7 @@ private: StringTable _stringTable; ImageTable _imageTable; std::vector _sourceGames; + bool _isJsonObject{}; protected: StringTable& GetStringTable() @@ -199,6 +200,16 @@ public: explicit Object(const rct_object_entry& entry); virtual ~Object(); + void MarkAsJsonObject() + { + _isJsonObject = true; + } + + bool IsJsonObject() const + { + return _isJsonObject; + }; + // Legacy data structures const char* GetIdentifier() const { diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index d5211c71f6..0b86ba2048 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -429,6 +429,7 @@ namespace ObjectFactory std::memcpy(entry.name, originalName.c_str(), minLength); result = CreateObject(entry); + result->MarkAsJsonObject(); auto readContext = ReadObjectContext(objectRepository, id, !gOpenRCT2NoGraphics, fileRetriever); result->ReadJson(&readContext, jRoot); if (readContext.WasError()) diff --git a/src/openrct2/object/ObjectManager.cpp b/src/openrct2/object/ObjectManager.cpp index 2be3024d77..51dd835f95 100644 --- a/src/openrct2/object/ObjectManager.cpp +++ b/src/openrct2/object/ObjectManager.cpp @@ -207,7 +207,8 @@ public: for (size_t i = 0; i < numObjects; i++) { const ObjectRepositoryItem* item = &_objectRepository.GetObjects()[i]; - if (item->LoadedObject != nullptr && IsObjectCustom(item) && item->LoadedObject->GetLegacyData() != nullptr) + if (item->LoadedObject != nullptr && IsObjectCustom(item) && item->LoadedObject->GetLegacyData() != nullptr + && !item->LoadedObject->IsJsonObject()) { objects.push_back(item); }