Fix #11259: Custom JSON object breaks saves (#11356)

Do not attempt to pack JSON objects into S6 files.
This commit is contained in:
Ted John 2020-04-19 13:18:12 +01:00 committed by GitHub
parent 5bfc41f49e
commit b9e85f6b90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 1 deletions

View File

@ -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.

View File

@ -176,6 +176,7 @@ private:
StringTable _stringTable;
ImageTable _imageTable;
std::vector<uint8_t> _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
{

View File

@ -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())

View File

@ -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);
}