瀏覽代碼

#4139 - attempt to fix crash on portal probbing

Andrii Danylchenko 1 年之前
父節點
當前提交
cd4aaf93ee
共有 1 個文件被更改,包括 22 次插入7 次删除
  1. 22 7
      AI/Nullkiller/AIGateway.cpp

+ 22 - 7
AI/Nullkiller/AIGateway.cpp

@@ -1331,17 +1331,32 @@ bool AIGateway::moveHeroToTile(int3 dst, HeroPtr h)
 		auto doChannelProbing = [&]() -> void
 		{
 			auto currentPos = h->visitablePos();
-			auto currentExit = getObj(currentPos, true)->id;
+			auto currentTeleport = getObj(currentPos, true);
 
-			status.setChannelProbing(true);
-			for(auto exit : teleportChannelProbingList)
-				doTeleportMovement(exit, int3(-1));
-			teleportChannelProbingList.clear();
-			status.setChannelProbing(false);
+			if(currentTeleport)
+			{
+				auto currentExit = currentTeleport->id;
+
+				status.setChannelProbing(true);
+				for(auto exit : teleportChannelProbingList)
+					doTeleportMovement(exit, int3(-1));
+				teleportChannelProbingList.clear();
+				status.setChannelProbing(false);
+
+				doTeleportMovement(currentExit, currentPos);
+			}
+			else
+			{
+				logAi->debug("Unexpected channel probbing at " + currentPos.toString());
 
-			doTeleportMovement(currentExit, currentPos);
+				teleportChannelProbingList.clear();
+				status.setChannelProbing(false);
+			}
 		};
 
+		teleportChannelProbingList.clear();
+		status.setChannelProbing(false);
+
 		for(; i > 0; i--)
 		{
 			int3 currentCoord = path.nodes[i].coord;