mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- fixed crash on loading modsettings.json from 0.94
This commit is contained in:
parent
edacdf34e5
commit
bc1e726be4
@ -543,24 +543,11 @@ std::vector <TModID> CModHandler::resolveDependencies(std::vector <TModID> 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 = data.Bool();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user