VisitObjEngine: avoid crashes if object is no longer visible

This really shouldn't happen, but better safe than sorry
This commit is contained in:
Arseniy Shestakov authored and AlexVinS committed 2019-01-27 05:58:46 +03:00
1 parent 36e2075d95
commit f06c8a8725
1 file changed
+5 -1
+5 -1
View File
@@ -391,7 +391,11 @@ float VisitObjEngine::evaluate(Goals::VisitObj & goal)
return 0;
auto obj = ai->myCb->getObj(ObjectInstanceID(goal.objid));
if(!obj)
{
logAi->error("Goals::VisitObj objid " + std::to_string(goal.objid) + " no longer visible, probably goal used for something it's not intended");
return -100; // FIXME: Added check when goal was used for hero instead of VisitHero, but crashes are bad anyway
}
boost::optional<int> objValueKnownByAI = MapObjectsEvaluator::getInstance().getObjectValue(obj);
int objValue = 0;