1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-12 02:28:11 +02:00

Check against nullptr in VisitHero::fulfillsMe()

This commit is contained in:
Vadim Markovtsev 2016-01-19 20:25:15 +03:00
parent 02c3c226e6
commit 6eefce23fe

View File

@ -435,10 +435,18 @@ TSubgoal VisitHero::whatToDoToAchieve()
bool VisitHero::fulfillsMe (TSubgoal goal)
{
if (goal->goalType == Goals::VISIT_TILE && cb->getObj(ObjectInstanceID(objid))->visitablePos() == goal->tile)
return true;
else
if (goal->goalType != Goals::VISIT_TILE)
{
return false;
}
auto obj = cb->getObj(ObjectInstanceID(objid));
if (!obj)
{
logAi->errorStream() << boost::format("Hero %s: VisitHero::fulfillsMe at %s: object %d not found")
% hero.name % goal->tile % objid;
return false;
}
return obj->visitablePos() == goal->tile;
}
TSubgoal GetArtOfType::whatToDoToAchieve()