Fix #16807: Log and skip invalid object JSON files (#27117)

This commit is contained in:
Paul Harley authored and GitHub committed 2026-10-11 09:44:42 +00:00
1 parent 41b1cd01bc
commit e87de05792
2 files changed
+9 -2

No files matched your search

+1
View File
@@ -1,5 +1,6 @@
0.5.7 (in development)
------------------------------------------------------------------------
- Fix: [#16807] Error messages when trying to load regular JSON files as custom objects.
- Fix: [#24524] Some build types (like AppImage) lack information about their specific build.
- Fix: [#27264] Headless server crashes when loading a recolourable terrain surface.
+8 -2
View File
@@ -529,9 +529,15 @@ namespace OpenRCT2::ObjectFactory
std::unique_ptr<Object> CreateObjectFromJson(
json_t& jRoot, const IFileDataRetriever* fileRetriever, bool loadImageTable, const std::string_view path)
{
if (!jRoot.is_object())
if (!jRoot.is_object() || !jRoot.contains("objectType"))
{
throw std::runtime_error("Object JSON root was not an object");
LOG_VERBOSE("Ignoring JSON file (%.*s): not an object file", static_cast<int>(path.length()), path.data());
return nullptr;
}
if (!jRoot["objectType"].is_string())
{
LOG_VERBOSE("Ignoring JSON file (%.*s): objectType is not a string", static_cast<int>(path.length()), path.data());
return nullptr;
}
LOG_VERBOSE("CreateObjectFromJson(...)");