Bläddra i källkod

Nullkiller: fix crash and freeze

Andrii Danylchenko 4 år sedan
förälder
incheckning
7e88819105

+ 9 - 4
AI/Nullkiller/Pathfinding/AINodeStorage.cpp

@@ -175,6 +175,11 @@ std::vector<CGPathNode *> AINodeStorage::getInitialNodes()
 			getOrCreateNode(actor->initialPosition, actor->layer, actor)
 			.get();
 
+		if(!initialNode)
+			continue;
+
+		initialNode->inPQ = false;
+		initialNode->pq = nullptr;
 		initialNode->turns = actor->initialTurn;
 		initialNode->moveRemains = actor->initialMovement;
 		initialNode->danger = 0;
@@ -254,7 +259,7 @@ void AINodeStorage::commit(
 		"Commited %s -> %s, cost: %f, turn: %s, mp: %d, hero: %s, mask: %x, army: %lld",
 		source->coord.toString(),
 		destination->coord.toString(),
-		destination->cost,
+		destination->getCost(),
 		std::to_string(destination->turns),
 		destination->moveRemains,
 		destination->actor->toString(),
@@ -599,8 +604,8 @@ void AINodeStorage::addHeroChain(const std::vector<ExchangeCandidate> & result)
 			logAi->trace(
 				"Exchange at %s is is not effective enough. %f < %f", 
 				exchangeNode->coord.toString(), 
-				exchangeNode->cost, 
-				chainInfo.cost);
+				exchangeNode->getCost(), 
+				chainInfo.getCost());
 #endif
 			continue;
 		}
@@ -629,7 +634,7 @@ void AINodeStorage::addHeroChain(const std::vector<ExchangeCandidate> & result)
 			other->actor->toString(), 
 			exchangeNode->actor->toString(),
 			exchangeNode->actor->chainMask,
-			exchangeNode->cost,
+			exchangeNode->getCost(),
 			std::to_string(exchangeNode->turns),
 			exchangeNode->moveRemains,
 			exchangeNode->actor->armyValue);

+ 17 - 1
AI/Nullkiller/Pathfinding/Rules/AIMovementAfterDestinationRule.cpp

@@ -45,6 +45,14 @@ namespace AIPathfinding
 			return;
 		}
 
+#if PATHFINDER_TRACE_LEVEL >= 2
+		logAi->trace(
+			"Movement from tile %s is blocked. Try to bypass. Action: %d, blocker: %d",
+			destination.coord.toString(),
+			(int)destination.action,
+			(int)blocker);
+#endif
+
 		auto destGuardians = cb->getGuardingCreatures(destination.coord);
 		bool allowBypass = false;
 
@@ -56,7 +64,15 @@ namespace AIPathfinding
 			break;
 
 		case BlockingReason::DESTINATION_BLOCKVIS:
-			allowBypass = destination.nodeObject && bypassRemovableObject(source, destination, pathfinderConfig, pathfinderHelper);
+			if(destination.nodeHero && destination.heroRelations != PlayerRelations::ENEMIES)
+			{
+				allowBypass = destination.heroRelations == PlayerRelations::SAME_PLAYER
+					&& destination.nodeHero == nodeStorage->getHero(destination.node);
+			}
+			else
+			{
+				allowBypass = destination.nodeObject && bypassRemovableObject(source, destination, pathfinderConfig, pathfinderHelper);
+			}
 			
 			if(allowBypass && destGuardians.size())
 				allowBypass = bypassDestinationGuards(destGuardians, source, destination, pathfinderConfig, pathfinderHelper);

+ 2 - 1
AI/Nullkiller/VCAI.cpp

@@ -744,10 +744,11 @@ void VCAI::makeTurn()
 		}
 	}
 
+	cb->sendMessage("vcmieagles");
+
 	if(cb->getDate(Date::DAY) == 1)
 	{
 		retrieveVisitableObjs();
-		cb->sendMessage("vcmieagles");
 	}
 
 	try