1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Update CModHandler.cpp

Corrected error handling in CModHandler::loadConfigFromFile
This commit is contained in:
Macron1Robot 2014-04-28 11:03:54 +04:00
parent 7c1d3d17fc
commit 13cd400d27

View File

@ -515,24 +515,24 @@ bool CModHandler::loadConfigFromFile (std::string name)
settings.MAX_HEROES_ON_MAP_PER_PLAYER = hardcodedFeatures["MAX_HEROES_ON_MAP_PER_PLAYER"].Float();
if (settings.MAX_HEROES_AVAILABLE_PER_PLAYER<=0)
{
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE must be higher than MAX_HEROES_ON_MAP";
return true;
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE_PER_PLAYER must be positive. Setting to 16";
settings.MAX_HEROES_AVAILABLE_PER_PLAYER = 16;
}
if (settings.MAX_HEROES_ON_MAP_PER_PLAYER <= 0)
{
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE must be higher than MAX_HEROES_ON_MAP";
return true;
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE_PER_PLAYER must be positive. Setting to 8";
settings.MAX_HEROES_ON_MAP_PER_PLAYER = 8;
}
if (settings.MAX_HEROES_AVAILABLE_PER_PLAYER<settings.MAX_HEROES_ON_MAP_PER_PLAYER)
{
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE must be higher than MAX_HEROES_ON_MAP";
return true;
logGlobal->errorStream() << "Error: MAX_HEROES_AVAILABLE_PER_PLAYER must be higher than MAX_HEROES_ON_MAP_PER_PLAYER. Setting to equal values";
settings.MAX_HEROES_AVAILABLE_PER_PLAYER = settings.MAX_HEROES_ON_MAP_PER_PLAYER;
}
settings.CREEP_SIZE = hardcodedFeatures["CREEP_SIZE"].Float();
if (settings.CREEP_SIZE<=0)
{
logGlobal->errorStream() << "Error: CREEP_SIZE must be positive value";
return true;
logGlobal->errorStream() << "Error: CREEP_SIZE must be positive value. Setting to 4000";
settings.CREEP_SIZE = 4000;
}
settings.WEEKLY_GROWTH = hardcodedFeatures["WEEKLY_GROWTH_PERCENT"].Float();
settings.WEEKLY_GROWTH = hardcodedFeatures["CREEP_SIZE"].Float();
@ -540,8 +540,8 @@ bool CModHandler::loadConfigFromFile (std::string name)
settings.MAX_BUILDING_PER_TURN = hardcodedFeatures["MAX_BUILDING_PER_TURN"].Float();
if (settings.MAX_BUILDING_PER_TURN <= 0)
{
logGlobal->errorStream() << "Error: MAX_BUILDING_PER_TURN must be positive value";
return true;
logGlobal->errorStream() << "Error: MAX_BUILDING_PER_TURN must be positive value. Setting to 1";
settings.MAX_BUILDING_PER_TURN=1;
}
settings.DWELLINGS_ACCUMULATE_CREATURES = hardcodedFeatures["DWELLINGS_ACCUMULATE_CREATURES"].Bool();
settings.ALL_CREATURES_GET_DOUBLE_MONTHS = hardcodedFeatures["ALL_CREATURES_GET_DOUBLE_MONTHS"].Bool();
@ -551,7 +551,7 @@ bool CModHandler::loadConfigFromFile (std::string name)
modules.STACK_ARTIFACT = gameModules["STACK_ARTIFACTS"].Bool();
modules.COMMANDERS = gameModules["COMMANDERS"].Bool();
modules.MITHRIL = gameModules["MITHRIL"].Bool();
return false;
return true;
}
// currentList is passed by value to get current list of depending mods
@ -816,9 +816,9 @@ CModInfo & CModHandler::getModData(TModID modId)
void CModHandler::initializeConfig()
{
if (loadConfigFromFile("defaultMods.json")==true)
if (!loadConfigFromFile("defaultMods.json"))
{
logGlobal->errorStream() << "Error: defaultMods.json HAS ERRORS";
logGlobal->errorStream() << "Error: defaultMods.json has errors";
}
}