1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

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 2019-01-13 20:28:55 +03:00 committed by AlexVinS
parent 36e2075d95
commit f06c8a8725

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;