From 62e5366a085965cfbffd7e1dbff594632d1589e6 Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Sat, 15 May 2021 21:04:11 +0300 Subject: [PATCH] AI: rough hero chain stabilisation --- AI/Nullkiller/CMakeLists.txt | 2 -- AI/Nullkiller/Pathfinding/AINodeStorage.cpp | 6 ++-- AI/Nullkiller/Pathfinding/AINodeStorage.h | 2 ++ .../Pathfinding/AIPathfinderConfig.cpp | 2 +- .../Pathfinding/Rules/AIMovementCostRule.cpp | 27 -------------- .../Pathfinding/Rules/AIMovementCostRule.h | 35 ------------------- 6 files changed, 6 insertions(+), 68 deletions(-) delete mode 100644 AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.cpp delete mode 100644 AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.h diff --git a/AI/Nullkiller/CMakeLists.txt b/AI/Nullkiller/CMakeLists.txt index ff0fc828e..71d2f92c1 100644 --- a/AI/Nullkiller/CMakeLists.txt +++ b/AI/Nullkiller/CMakeLists.txt @@ -20,7 +20,6 @@ set(VCAI_SRCS Pathfinding/Rules/AIMovementAfterDestinationRule.cpp Pathfinding/Rules/AIMovementToDestinationRule.cpp Pathfinding/Rules/AIPreviousNodeRule.cpp - Pathfinding/Rules/AIMovementCostRule.cpp AIUtility.cpp AIhelper.cpp ResourceManager.cpp @@ -77,7 +76,6 @@ set(VCAI_HEADERS Pathfinding/Rules/AIMovementAfterDestinationRule.h Pathfinding/Rules/AIMovementToDestinationRule.h Pathfinding/Rules/AIPreviousNodeRule.h - Pathfinding/Rules/AIMovementCostRule.h AIUtility.h AIhelper.h ResourceManager.h diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp index d325ee939..28a24514d 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp +++ b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp @@ -186,7 +186,7 @@ void AINodeStorage::commit( int movementLeft, float cost) const { - destination->action = source->action; + destination->action = action; destination->cost = cost; destination->moveRemains = movementLeft; destination->turns = turn; @@ -322,9 +322,9 @@ void AINodeStorage::commitExchange( #ifdef VCMI_TRACE_PATHFINDER logAi->trace( "Accepted hero exhange at %s, carrier %s, mp cost %f", - destination.coord.toString(), + exchangeNode->coord.toString(), carrierActor->hero->name, - destination.cost); + cost); #endif commit(exchangeNode, carrierParentNode, carrierParentNode->action, turns, movementLeft, cost); diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.h b/AI/Nullkiller/Pathfinding/AINodeStorage.h index 6111758ac..acf1297d8 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.h +++ b/AI/Nullkiller/Pathfinding/AINodeStorage.h @@ -10,6 +10,8 @@ #pragma once +#define VCMI_TRACE_PATHFINDER + #include "../../../lib/CPathfinder.h" #include "../../../lib/mapObjects/CGHeroInstance.h" #include "../AIUtility.h" diff --git a/AI/Nullkiller/Pathfinding/AIPathfinderConfig.cpp b/AI/Nullkiller/Pathfinding/AIPathfinderConfig.cpp index 4444f44ae..d52b19e38 100644 --- a/AI/Nullkiller/Pathfinding/AIPathfinderConfig.cpp +++ b/AI/Nullkiller/Pathfinding/AIPathfinderConfig.cpp @@ -26,7 +26,7 @@ namespace AIPathfinding std::make_shared(cb, ai, nodeStorage), std::make_shared(), std::make_shared(nodeStorage), - std::make_shared(nodeStorage), + std::make_shared(), std::make_shared(nodeStorage), std::make_shared(cb, nodeStorage) }; diff --git a/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.cpp b/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.cpp deleted file mode 100644 index ca0bbf32a..000000000 --- a/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -* AIMovementCostRule.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 "AIMovementCostRule.h" - -namespace AIPathfinding -{ - AIMovementCostRule::AIMovementCostRule(std::shared_ptr nodeStorage) - : nodeStorage(nodeStorage) - { - } - - void AIMovementCostRule::process( - const PathNodeInfo & source, - CDestinationNodeInfo & destination, - const PathfinderConfig * pathfinderConfig, - CPathfinderHelper * pathfinderHelper) const - { - } -} diff --git a/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.h b/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.h deleted file mode 100644 index 3c205784f..000000000 --- a/AI/Nullkiller/Pathfinding/Rules/AIMovementCostRule.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -* AIMovementCostRule.h, 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 -* -*/ - -#pragma once - -#include "../AINodeStorage.h" -#include "../../VCAI.h" -#include "../../../../CCallback.h" -#include "../../../../lib/mapping/CMap.h" -#include "../../../../lib/mapObjects/MapObjects.h" - -namespace AIPathfinding -{ - class AIMovementCostRule : public MovementCostRule - { - private: - std::shared_ptr nodeStorage; - - public: - AIMovementCostRule(std::shared_ptr nodeStorage); - - virtual void process( - const PathNodeInfo & source, - CDestinationNodeInfo & destination, - const PathfinderConfig * pathfinderConfig, - CPathfinderHelper * pathfinderHelper) const override; - }; -}