From e0ea994656eb0cd8d41dfe211eae500263bda69e Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 22 Jun 2023 17:03:18 +0300 Subject: [PATCH] Moved some pathfinding options to game settings --- AI/VCAI/Pathfinding/AIPathfinderConfig.cpp | 5 ++ config/gameConfig.json | 14 +++++ config/schemas/settings.json | 70 +--------------------- lib/GameSettings.cpp | 5 ++ lib/GameSettings.h | 5 ++ lib/pathfinder/PathfinderOptions.cpp | 27 ++++----- 6 files changed, 43 insertions(+), 83 deletions(-) diff --git a/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp b/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp index cf80922ed..68e516e1a 100644 --- a/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp +++ b/AI/VCAI/Pathfinding/AIPathfinderConfig.cpp @@ -41,6 +41,11 @@ namespace AIPathfinding std::shared_ptr nodeStorage) :PathfinderConfig(nodeStorage, makeRuleset(cb, ai, nodeStorage)), hero(nodeStorage->getHero()) { + options.useEmbarkAndDisembark = true; + options.useTeleportTwoWay = true; + options.useTeleportOneWay = true; + options.useTeleportOneWayRandom = true; + options.useTeleportWhirlpool = true; } AIPathfinderConfig::~AIPathfinderConfig() = default; diff --git a/config/gameConfig.json b/config/gameConfig.json index 0e98de99d..92c1158c8 100644 --- a/config/gameConfig.json +++ b/config/gameConfig.json @@ -329,6 +329,20 @@ "commanders": false }, + "pathfinder" : + { + // if enabled, pathfinder will take use of any available boats + "useBoat" : true, + // if enabled, pathfinder will take use of any bidirectional monoliths + "useMonolithTwoWay" : true, + // if enabled, pathfinder will take use of one-way monolith that only have one known exit + "useMonolithOneWayUnique" : false, + // if enabled, pathfinder will take use of one-way monoliths with multiple exits. + "useMonolithOneWayRandom" : false, + // if enabled and hero has whirlpool protection effect, pathfinder will take use of whirpools + "useWhirlpool" : true + }, + "bonuses" : { "global" : diff --git a/config/schemas/settings.json b/config/schemas/settings.json index 8b2d7a3c3..0c91cfb7a 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -3,7 +3,7 @@ { "type" : "object", "$schema" : "http://json-schema.org/draft-04/schema", - "required" : [ "general", "video", "adventure", "pathfinder", "battle", "server", "logging", "launcher", "gameTweaks" ], + "required" : [ "general", "video", "adventure", "battle", "server", "logging", "launcher", "gameTweaks" ], "definitions" : { "logLevelEnum" : { "type" : "string", @@ -221,74 +221,6 @@ } } }, - "pathfinder" : { - "type" : "object", - "additionalProperties" : false, - "default" : {}, - "required" : [ "teleports", "layers", "oneTurnSpecialLayersLimit", "originalMovementRules", "lightweightFlyingMode" ], - "properties" : { - "layers" : { - "type" : "object", - "additionalProperties" : false, - "default" : {}, - "required" : [ "sailing", "waterWalking", "flying" ], - "properties" : { - "sailing" : { - "type" : "boolean", - "default" : true - }, - "waterWalking" : { - "type" : "boolean", - "default" : true - }, - "flying" : { - "type" : "boolean", - "default" : true - } - } - }, - "teleports" : { - "type" : "object", - "additionalProperties" : false, - "default" : {}, - "required" : [ "twoWay", "oneWay", "oneWayRandom", "whirlpool", "castleGate" ], - "properties" : { - "twoWay" : { - "type" : "boolean", - "default" : true - }, - "oneWay" : { - "type" : "boolean", - "default" : true - }, - "oneWayRandom" : { - "type" : "boolean", - "default" : false - }, - "whirlpool" : { - "type" : "boolean", - "default" : true - }, - "castleGate" : { - "type" : "boolean", - "default" : false - } - } - }, - "oneTurnSpecialLayersLimit" : { - "type" : "boolean", - "default" : true - }, - "originalMovementRules" : { - "type" : "boolean", - "default" : false - }, - "lightweightFlyingMode" : { - "type" : "boolean", - "default" : false - } - } - }, "battle" : { "type" : "object", "additionalProperties" : false, diff --git a/lib/GameSettings.cpp b/lib/GameSettings.cpp index 0d9432a61..053aee7eb 100644 --- a/lib/GameSettings.cpp +++ b/lib/GameSettings.cpp @@ -91,6 +91,11 @@ void GameSettings::load(const JsonNode & input) {EGameSettings::TEXTS_ROAD, "textData", "road" }, {EGameSettings::TEXTS_SPELL, "textData", "spell" }, {EGameSettings::TEXTS_TERRAIN, "textData", "terrain" }, + {EGameSettings::PATHFINDER_USE_BOAT, "pathfinder", "useBoat" }, + {EGameSettings::PATHFINDER_USE_MONOLITH_TWO_WAY, "pathfinder", "useMonolithTwoWay" }, + {EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_UNIQUE, "pathfinder", "useMonolithOneWayUnique" }, + {EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_RANDOM, "pathfinder", "useMonolithOneWayRandom" }, + {EGameSettings::PATHFINDER_USE_WHIRLPOOL, "pathfinder", "useWhirlpool" }, {EGameSettings::TOWNS_BUILDINGS_PER_TURN_CAP, "towns", "buildingsPerTurnCap" }, {EGameSettings::TOWNS_STARTING_DWELLING_CHANCES, "towns", "startingDwellingChances" }, }; diff --git a/lib/GameSettings.h b/lib/GameSettings.h index 29ccec476..68222cd20 100644 --- a/lib/GameSettings.h +++ b/lib/GameSettings.h @@ -57,6 +57,11 @@ enum class EGameSettings MAP_FORMAT_HORN_OF_THE_ABYSS, MAP_FORMAT_JSON_VCMI, MAP_FORMAT_IN_THE_WAKE_OF_GODS, + PATHFINDER_USE_BOAT, + PATHFINDER_USE_MONOLITH_TWO_WAY, + PATHFINDER_USE_MONOLITH_ONE_WAY_UNIQUE, + PATHFINDER_USE_MONOLITH_ONE_WAY_RANDOM, + PATHFINDER_USE_WHIRLPOOL, TOWNS_BUILDINGS_PER_TURN_CAP, TOWNS_STARTING_DWELLING_CHANCES, COMBAT_ONE_HEX_TRIGGERS_OBSTACLES, diff --git a/lib/pathfinder/PathfinderOptions.cpp b/lib/pathfinder/PathfinderOptions.cpp index c473b9321..02b5d8b6a 100644 --- a/lib/pathfinder/PathfinderOptions.cpp +++ b/lib/pathfinder/PathfinderOptions.cpp @@ -10,7 +10,8 @@ #include "StdInc.h" #include "PathfinderOptions.h" -#include "../CConfigHandler.h" +#include "../GameSettings.h" +#include "../VCMI_Lib.h" #include "NodeStorage.h" #include "PathfindingRules.h" #include "CPathfinder.h" @@ -18,20 +19,18 @@ VCMI_LIB_NAMESPACE_BEGIN PathfinderOptions::PathfinderOptions() + : useFlying(true) + , useWaterWalking(true) + , useEmbarkAndDisembark(VLC->settings()->getBoolean(EGameSettings::PATHFINDER_USE_BOAT)) + , useTeleportTwoWay(VLC->settings()->getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_TWO_WAY)) + , useTeleportOneWay(VLC->settings()->getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_UNIQUE)) + , useTeleportOneWayRandom(VLC->settings()->getBoolean(EGameSettings::PATHFINDER_USE_MONOLITH_ONE_WAY_RANDOM)) + , useTeleportWhirlpool(VLC->settings()->getBoolean(EGameSettings::PATHFINDER_USE_WHIRLPOOL)) + , useCastleGate(false) + , lightweightFlyingMode(false) + , oneTurnSpecialLayersLimit(true) + , originalMovementRules(false) { - useFlying = settings["pathfinder"]["layers"]["flying"].Bool(); - useWaterWalking = settings["pathfinder"]["layers"]["waterWalking"].Bool(); - useEmbarkAndDisembark = settings["pathfinder"]["layers"]["sailing"].Bool(); - useTeleportTwoWay = settings["pathfinder"]["teleports"]["twoWay"].Bool(); - useTeleportOneWay = settings["pathfinder"]["teleports"]["oneWay"].Bool(); - useTeleportOneWayRandom = settings["pathfinder"]["teleports"]["oneWayRandom"].Bool(); - useTeleportWhirlpool = settings["pathfinder"]["teleports"]["whirlpool"].Bool(); - - useCastleGate = settings["pathfinder"]["teleports"]["castleGate"].Bool(); - - lightweightFlyingMode = settings["pathfinder"]["lightweightFlyingMode"].Bool(); - oneTurnSpecialLayersLimit = settings["pathfinder"]["oneTurnSpecialLayersLimit"].Bool(); - originalMovementRules = settings["pathfinder"]["originalMovementRules"].Bool(); } PathfinderConfig::PathfinderConfig(std::shared_ptr nodeStorage, std::vector> rules):