diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 6d668ed984..c38bde4002 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -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. diff --git a/src/openrct2/object/ObjectFactory.cpp b/src/openrct2/object/ObjectFactory.cpp index 4c076389fb..ee26068eb8 100644 --- a/src/openrct2/object/ObjectFactory.cpp +++ b/src/openrct2/object/ObjectFactory.cpp @@ -529,9 +529,15 @@ namespace OpenRCT2::ObjectFactory std::unique_ptr 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(path.length()), path.data()); + return nullptr; + } + if (!jRoot["objectType"].is_string()) + { + LOG_VERBOSE("Ignoring JSON file (%.*s): objectType is not a string", static_cast(path.length()), path.data()); + return nullptr; } LOG_VERBOSE("CreateObjectFromJson(...)");