From bc1e726be4b2198f08cb1f4baafd367d26c88777 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 9 Jan 2014 20:15:32 +0000 Subject: [PATCH] - fixed crash on loading modsettings.json from 0.94 --- lib/CModHandler.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/lib/CModHandler.cpp b/lib/CModHandler.cpp index 11500c33b..dfce48945 100644 --- a/lib/CModHandler.cpp +++ b/lib/CModHandler.cpp @@ -543,24 +543,11 @@ std::vector CModHandler::resolveDependencies(std::vector input return output; } -static JsonNode updateModSettingsFormat(JsonNode config) -{ - for (auto & entry : config["activeMods"].Struct()) - { - if (entry.second.getType() == JsonNode::DATA_BOOL) - { - entry.second["active"].Bool() = entry.second.Bool(); - } - } - return config; -} - static JsonNode loadModSettings(std::string path) { if (CResourceHandler::get()->existsResource(ResourceID(path))) { - // mod compatibility: check if modSettings has old, 0.94 format - return updateModSettingsFormat(JsonNode(ResourceID(path, EResType::TEXT))); + return JsonNode(ResourceID(path, EResType::TEXT)); } // Probably new install. Create initial configuration CResourceHandler::get()->createResource(path); @@ -610,10 +597,11 @@ void CModInfo::updateChecksum(ui32 newChecksum) void CModInfo::loadLocalData(const JsonNode & data) { bool validated = false; - if (data.isNull()) + enabled = true; + checksum = 0; + if (data.getType() == JsonNode::DATA_BOOL) { - enabled = true; - checksum = 0; + enabled = data.Bool(); } else {