diff --git a/AI/Nullkiller/Behaviors/StartupBehavior.cpp b/AI/Nullkiller/Behaviors/StartupBehavior.cpp index f4a2af679..517504d19 100644 --- a/AI/Nullkiller/Behaviors/StartupBehavior.cpp +++ b/AI/Nullkiller/Behaviors/StartupBehavior.cpp @@ -53,7 +53,8 @@ const CGHeroInstance * getNearestHero(const CGTownInstance * town) auto shortestPath = getShortestPath(town, paths); - if(shortestPath.nodes.size() > 1 + if(shortestPath.nodes.size() > 1 + || shortestPath.turn() != 0 || shortestPath.targetHero->visitablePos().dist2dSQ(town->visitablePos()) > 4 || town->garrisonHero && shortestPath.targetHero == town->garrisonHero.get()) return nullptr; diff --git a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp index 261b0fd36..394a9c48a 100644 --- a/AI/Nullkiller/Goals/ExecuteHeroChain.cpp +++ b/AI/Nullkiller/Goals/ExecuteHeroChain.cpp @@ -102,13 +102,23 @@ void ExecuteHeroChain::accept(VCAI * ai) { //TODO: decompose } + + if(!hero.validAndSet()) + { + logAi->error("Hero %s was lost trying to execute special action. Exit hero chain.", hero.name); + + return; + } } if(node.turns == 0 && node.coord != hero->visitablePos()) { auto targetNode = cb->getPathsInfo(hero.get())->getPathInfo(node.coord); - if(!targetNode->accessible || targetNode->turns != 0) + if(targetNode->accessible == CGPathNode::EAccessibility::NOT_SET + || targetNode->accessible == CGPathNode::EAccessibility::BLOCKED + || targetNode->accessible == CGPathNode::EAccessibility::FLYABLE + || targetNode->turns != 0) { logAi->error( "Enable to complete chain. Expected hero %s to arive to %s in 0 turns but he can not do this", @@ -127,6 +137,13 @@ void ExecuteHeroChain::accept(VCAI * ai) } catch(cannotFulfillGoalException) { + if(!hero.validAndSet()) + { + logAi->error("Hero %s was lost. Exit hero chain.", hero.name); + + return; + } + if(hero->movement > 0) { CGPath path; diff --git a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp index a8e6669e9..61639b0d1 100644 --- a/AI/Nullkiller/Pathfinding/AINodeStorage.cpp +++ b/AI/Nullkiller/Pathfinding/AINodeStorage.cpp @@ -411,7 +411,9 @@ void AINodeStorage::calculateHeroChain( continue; if(node->action == CGPathNode::ENodeAction::BATTLE - || node->action == CGPathNode::ENodeAction::TELEPORT_BATTLE) + || node->action == CGPathNode::ENodeAction::TELEPORT_BATTLE + || node->action == CGPathNode::ENodeAction::TELEPORT_NORMAL + || node->action == CGPathNode::ENodeAction::TELEPORT_BLOCKING_VISIT) { continue; } diff --git a/AI/Nullkiller/VCAI.cpp b/AI/Nullkiller/VCAI.cpp index 38b06aae7..1d634ead4 100644 --- a/AI/Nullkiller/VCAI.cpp +++ b/AI/Nullkiller/VCAI.cpp @@ -200,11 +200,15 @@ void VCAI::gameOver(PlayerColor player, const EVictoryLossCheckResult & victoryL LOG_TRACE_PARAMS(logAi, "victoryLossCheckResult '%s'", victoryLossCheckResult.messageToSelf); NET_EVENT_HANDLER; logAi->debug("Player %d (%s): I heard that player %d (%s) %s.", playerID, playerID.getStr(), player, player.getStr(), (victoryLossCheckResult.victory() ? "won" : "lost")); + + // some whitespace to flush stream + logAi->debug(std::string(200, ' ')); + if(player == playerID) { if(victoryLossCheckResult.victory()) { - logAi->debug("VCAI: I won! Incredible!"); + logAi->debug("VCAI: Player %d (%s) won. I won! Incredible!", player, player.getStr()); logAi->debug("Turn nr %d", myCb->getDate()); } else