From 9a0b5a0afc785085c07390ed60db8c5ad38a9e8c Mon Sep 17 00:00:00 2001 From: Andrii Danylchenko Date: Tue, 6 Nov 2018 21:45:29 +0200 Subject: [PATCH] AI: fix freeze when AI has a win condition to control own town --- AI/VCAI/Goals.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/AI/VCAI/Goals.cpp b/AI/VCAI/Goals.cpp index 6e433ea67..5192de437 100644 --- a/AI/VCAI/Goals.cpp +++ b/AI/VCAI/Goals.cpp @@ -422,7 +422,17 @@ TSubgoal Win::whatToDoToAchieve() { if(goal.object) { - return sptr(Goals::VisitObj(goal.object->id.getNum())); + auto objRelations = cb->getPlayerRelations(ai->playerID, goal.object->tempOwner); + + if(objRelations == PlayerRelations::ENEMIES) + { + return sptr(Goals::VisitObj(goal.object->id.getNum())); + } + else + { + // TODO: Defance + break; + } } else {