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

AI won't ignore owned objects taken by enemies.

This commit is contained in:
DjWarmonger 2015-01-24 21:38:22 +01:00
parent a90d603c16
commit 60932d9ed0

View File

@ -496,9 +496,19 @@ void VCAI::objectPropertyChanged(const SetObjectProperty * sop)
NET_EVENT_HANDLER;
if(sop->what == ObjProperty::OWNER)
{
//we don't want to visit know object twice (do we really?)
if(sop->val == playerID.getNum())
erase_if_present(visitableObjs, myCb->getObj(sop->id));
//TODO restore lost obj
else if (myCb->getPlayerRelations(playerID, (PlayerColor)sop->val) == PlayerRelations::ENEMIES)
{
//we want to visit objects owned by oppponents
auto obj = myCb->getObj(sop->id, false);
if (obj)
{
visitableObjs.insert(obj);
erase_if_present(alreadyVisited, obj);
}
}
}
}