From e13a2d70b3134fdb81f546c2a61505728a9ceaca Mon Sep 17 00:00:00 2001 From: Michael Steenbeek Date: Thu, 17 Nov 2022 18:50:20 +0100 Subject: [PATCH] Fix #18606: JSON objects do not take priority over DATs they supersede --- distribution/changelog.txt | 1 + src/openrct2/object/ObjectRepository.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 6ed8f200e4..b40dd3d030 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -41,6 +41,7 @@ - Fix: [#18449] [Plugin] Change type of listview widgets from 'scroll_view' to 'listview'. - Fix: [#18453] Slow walking guests don't get across level crossings in time. - Fix: [#18459] ‘Highlight path issues’ hides fences for paths with additions. +- Fix: [#18606] JSON objects do not take priority over the DAT files they supersede. 0.4.2 (2022-10-05) ------------------------------------------------------------------------ diff --git a/src/openrct2/object/ObjectRepository.cpp b/src/openrct2/object/ObjectRepository.cpp index a9338cdab4..788696de37 100644 --- a/src/openrct2/object/ObjectRepository.cpp +++ b/src/openrct2/object/ObjectRepository.cpp @@ -419,6 +419,7 @@ private: { conflict = FindObject(item.Identifier); } + if (conflict == nullptr) { size_t index = _items.size(); @@ -435,6 +436,21 @@ private: } return true; } + // When there is a conflict between a DAT file and a JSON file, the JSON should take precedence. + else if (item.Generation == ObjectGeneration::JSON && conflict->Generation == ObjectGeneration::DAT) + { + const auto id = conflict->Id; + const auto oldPath = conflict->Path; + _items[id] = item; + _items[id].Id = id; + if (!item.Identifier.empty()) + { + _newItemMap[item.Identifier] = id; + } + + Console::Error::WriteLine("Object conflict: '%s' was overridden by '%s'", oldPath.c_str(), item.Path.c_str()); + return true; + } Console::Error::WriteLine("Object conflict: '%s'", conflict->Path.c_str()); Console::Error::WriteLine(" : '%s'", item.Path.c_str());