Pārlūkot izejas kodu

VCAI::objectRemoved: handle hero boat removal. Fix issue 2350

Avoid situation when AI attempt to visit boat after it's killed hero who used it.
Arseniy Shestakov 9 gadi atpakaļ
vecāks
revīzija
8e94b1c4d2
1 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  1. 10 0
      AI/VCAI/VCAI.cpp

+ 10 - 0
AI/VCAI/VCAI.cpp

@@ -398,6 +398,16 @@ void VCAI::objectRemoved(const CGObjectInstance *obj)
 	for (auto h : cb->getHeroesInfo())
 		unreserveObject(h, obj);
 
+	//TODO: Find better way to handle hero boat removal
+	if(auto hero = dynamic_cast<const CGHeroInstance *>(obj))
+	{
+		if(hero->boat)
+		{
+			vstd::erase_if_present(visitableObjs, hero->boat);
+			vstd::erase_if_present(alreadyVisited, hero->boat);
+		}
+	}
+
 	cachedSectorMaps.clear(); //invalidate all paths
 
 	//TODO