2024-02-25 12:39:19 +02:00
|
|
|
/*
|
|
|
|
* Settings.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include "StdInc.h"
|
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
#include "Settings.h"
|
|
|
|
#include "../../../lib/mapObjectConstructors/AObjectTypeHandler.h"
|
|
|
|
#include "../../../lib/mapObjectConstructors/CObjectClassesHandler.h"
|
|
|
|
#include "../../../lib/mapObjectConstructors/CBankInstanceConstructor.h"
|
|
|
|
#include "../../../lib/mapObjects/MapObjects.h"
|
|
|
|
#include "../../../lib/modding/CModHandler.h"
|
|
|
|
#include "../../../lib/VCMI_Lib.h"
|
|
|
|
#include "../../../lib/filesystem/Filesystem.h"
|
2024-04-19 17:40:47 +02:00
|
|
|
#include "../../../lib/json/JsonUtils.h"
|
2024-02-25 12:39:19 +02:00
|
|
|
|
|
|
|
namespace NKAI
|
|
|
|
{
|
|
|
|
Settings::Settings()
|
|
|
|
: maxRoamingHeroes(8),
|
|
|
|
mainHeroTurnDistanceLimit(10),
|
|
|
|
scoutHeroTurnDistanceLimit(5),
|
2024-04-16 23:10:15 +02:00
|
|
|
maxGoldPressure(0.3f),
|
2024-04-21 10:13:37 +02:00
|
|
|
maxpass(10),
|
2024-05-19 09:04:45 +02:00
|
|
|
allowObjectGraph(true),
|
|
|
|
useTroopsFromGarrisons(false),
|
2024-07-07 22:44:52 +02:00
|
|
|
openMap(true),
|
|
|
|
useFuzzy(false)
|
2024-02-25 12:39:19 +02:00
|
|
|
{
|
2024-04-19 17:40:47 +02:00
|
|
|
JsonNode node = JsonUtils::assembleFromFiles("config/ai/nkai/nkai-settings");
|
2024-02-25 12:39:19 +02:00
|
|
|
|
|
|
|
if(node.Struct()["maxRoamingHeroes"].isNumber())
|
|
|
|
{
|
|
|
|
maxRoamingHeroes = node.Struct()["maxRoamingHeroes"].Integer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(node.Struct()["mainHeroTurnDistanceLimit"].isNumber())
|
|
|
|
{
|
|
|
|
mainHeroTurnDistanceLimit = node.Struct()["mainHeroTurnDistanceLimit"].Integer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(node.Struct()["scoutHeroTurnDistanceLimit"].isNumber())
|
|
|
|
{
|
|
|
|
scoutHeroTurnDistanceLimit = node.Struct()["scoutHeroTurnDistanceLimit"].Integer();
|
|
|
|
}
|
|
|
|
|
|
|
|
if(node.Struct()["maxpass"].isNumber())
|
|
|
|
{
|
|
|
|
maxpass = node.Struct()["maxpass"].Integer();
|
|
|
|
}
|
|
|
|
|
2024-04-16 23:10:15 +02:00
|
|
|
if(node.Struct()["maxGoldPressure"].isNumber())
|
2024-02-25 12:39:19 +02:00
|
|
|
{
|
2024-04-16 23:10:15 +02:00
|
|
|
maxGoldPressure = node.Struct()["maxGoldPressure"].Float();
|
2024-02-25 12:39:19 +02:00
|
|
|
}
|
2024-03-08 14:39:16 +02:00
|
|
|
|
|
|
|
if(!node.Struct()["allowObjectGraph"].isNull())
|
|
|
|
{
|
|
|
|
allowObjectGraph = node.Struct()["allowObjectGraph"].Bool();
|
|
|
|
}
|
2024-04-19 17:40:29 +02:00
|
|
|
|
2024-05-19 09:04:45 +02:00
|
|
|
if(!node.Struct()["openMap"].isNull())
|
|
|
|
{
|
|
|
|
openMap = node.Struct()["openMap"].Bool();
|
|
|
|
}
|
|
|
|
|
2024-07-07 22:44:52 +02:00
|
|
|
if (!node.Struct()["useFuzzy"].isNull())
|
|
|
|
{
|
|
|
|
useFuzzy = node.Struct()["useFuzzy"].Bool();
|
|
|
|
}
|
|
|
|
|
2024-04-19 17:40:29 +02:00
|
|
|
if(!node.Struct()["useTroopsFromGarrisons"].isNull())
|
|
|
|
{
|
|
|
|
useTroopsFromGarrisons = node.Struct()["useTroopsFromGarrisons"].Bool();
|
|
|
|
}
|
2024-02-25 12:39:19 +02:00
|
|
|
}
|
2024-04-19 17:40:29 +02:00
|
|
|
}
|