Browse Source

Merge pull request #3801 from vcmi/fixes

Fixes
Andrii Danylchenko 1 year ago
parent
commit
23fd47ae63

+ 12 - 0
AI/BattleAI/BattleEvaluator.cpp

@@ -64,6 +64,18 @@ std::vector<BattleHex> BattleEvaluator::getBrokenWallMoatHexes() const
 		auto moatHex = wallHex.cloneInDirection(BattleHex::LEFT);
 
 		result.push_back(moatHex);
+
+		moatHex = moatHex.cloneInDirection(BattleHex::LEFT);
+		auto obstaclesSecondRow = cb->getBattle(battleID)->battleGetAllObstaclesOnPos(moatHex, false);
+
+		for(auto obstacle : obstaclesSecondRow)
+		{
+			if(obstacle->obstacleType == CObstacleInstance::EObstacleType::MOAT)
+			{
+				result.push_back(moatHex);
+				break;
+			}
+		}
 	}
 
 	return result;

+ 1 - 1
AI/Nullkiller/Engine/Settings.cpp

@@ -27,7 +27,7 @@ namespace NKAI
 		mainHeroTurnDistanceLimit(10),
 		scoutHeroTurnDistanceLimit(5),
 		maxGoldPressure(0.3f), 
-		maxpass(30),
+		maxpass(10),
 		allowObjectGraph(false)
 	{
 		ResourcePath resource("config/ai/nkai/nkai-settings", EResType::JSON);

+ 9 - 2
AI/Nullkiller/Pathfinding/ObjectGraph.cpp

@@ -112,7 +112,9 @@ public:
 
 	void addMinimalDistanceJunctions()
 	{
-		pforeachTilePaths(ai->cb->getMapSize(), ai, [this](const int3 & pos, std::vector<AIPath> & paths)
+		tbb::concurrent_unordered_set<int3, std::hash<int3>> junctions;
+
+		pforeachTilePaths(ai->cb->getMapSize(), ai, [this, &junctions](const int3 & pos, std::vector<AIPath> & paths)
 			{
 				if(target->hasNodeAt(pos))
 					return;
@@ -129,9 +131,14 @@ public:
 
 				if(currentCost.avg < neighborCost)
 				{
-					addJunctionActor(pos);
+					junctions.insert(pos);
 				}
 			});
+
+		for(auto pos : junctions)
+		{
+			addJunctionActor(pos);
+		}
 	}
 
 private:

+ 2 - 1
lib/mapObjects/MiscObjects.cpp

@@ -709,7 +709,8 @@ void CGWhirlpool::teleportDialogAnswered(const CGHeroInstance *hero, ui32 answer
 bool CGWhirlpool::isProtected(const CGHeroInstance * h)
 {
 	return h->hasBonusOfType(BonusType::WHIRLPOOL_PROTECTION)
-	|| (h->stacksCount() == 1 && h->Slots().begin()->second->count == 1);
+		|| (h->stacksCount() == 1 && h->Slots().begin()->second->count == 1)
+		|| (h->stacksCount() == 0 && h->commander && h->commander->alive);
 }
 
 ArtifactID CGArtifact::getArtifact() const