From e8e44468860c6e52fc5743c127f51f7770e850f9 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Fri, 19 Apr 2024 18:40:47 +0300 Subject: [PATCH] Simplify NKAI settings loading code --- AI/Nullkiller/Engine/Settings.cpp | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/AI/Nullkiller/Engine/Settings.cpp b/AI/Nullkiller/Engine/Settings.cpp index 6ed16936a..d10bb0048 100644 --- a/AI/Nullkiller/Engine/Settings.cpp +++ b/AI/Nullkiller/Engine/Settings.cpp @@ -18,7 +18,7 @@ #include "../../../lib/modding/CModHandler.h" #include "../../../lib/VCMI_Lib.h" #include "../../../lib/filesystem/Filesystem.h" -#include "../../../lib/json/JsonNode.h" +#include "../../../lib/json/JsonUtils.h" namespace NKAI { @@ -31,27 +31,8 @@ namespace NKAI allowObjectGraph(false), useTroopsFromGarrisons(false) { - ResourcePath resource("config/ai/nkai/nkai-settings", EResType::JSON); + JsonNode node = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings"); - loadFromMod("core", resource); - - for(const auto & modName : VLC->modh->getActiveMods()) - { - if(CResourceHandler::get(modName)->existsResource(resource)) - loadFromMod(modName, resource); - } - } - - void Settings::loadFromMod(const std::string & modName, const ResourcePath & resource) - { - if(!CResourceHandler::get(modName)->existsResource(resource)) - { - logGlobal->error("Failed to load font %s from mod %s", resource.getName(), modName); - return; - } - - JsonNode node(JsonPath::fromResource(resource), modName); - if(node.Struct()["maxRoamingHeroes"].isNumber()) { maxRoamingHeroes = node.Struct()["maxRoamingHeroes"].Integer();