mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-24 03:47:18 +02:00
prevent crash when a mod from save file doesn't exist
This commit is contained in:
parent
e6e7679a2c
commit
cedc9a92ed
@ -842,10 +842,22 @@ void CHeroHandler::loadObstacles()
|
||||
allConfigs.insert(allConfigs.begin(), "core");
|
||||
for(auto & mod : allConfigs)
|
||||
{
|
||||
if(!CResourceHandler::get(mod)->existsResource(ResourceID("config/obstacles.json")))
|
||||
ISimpleResourceLoader * modResourceLoader;
|
||||
try
|
||||
{
|
||||
modResourceLoader = CResourceHandler::get(mod);
|
||||
}
|
||||
catch(const std::out_of_range &)
|
||||
{
|
||||
logMod->warn("Mod '%1%' doesn't exist! Its obstacles won't be loaded!", mod);
|
||||
continue;
|
||||
}
|
||||
|
||||
const ResourceID obstaclesResource{"config/obstacles.json"};
|
||||
if(!modResourceLoader->existsResource(obstaclesResource))
|
||||
continue;
|
||||
|
||||
const JsonNode config(mod, ResourceID("config/obstacles.json"));
|
||||
const JsonNode config(mod, obstaclesResource);
|
||||
loadObstacles(config["obstacles"], false, obstacles);
|
||||
loadObstacles(config["absoluteObstacles"], true, absoluteObstacles);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user