1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

- Restored evaluation of wander targets at every step.

- First wander target will be sorted by distance (closest) as well.
This commit is contained in:
DjWarmonger 2015-04-07 08:55:13 +02:00
parent 2f588b548e
commit 264a0c4fe7

View File

@ -1413,8 +1413,10 @@ void VCAI::wander(HeroPtr h)
}
//end of objs empty
while (dests.size()) //performance improvement
if (dests.size()) //performance improvement
{
boost::sort(dests, CDistanceSorter(h.get())); //find next closest one
//wander should not cause heroes to be reserved - they are always considered free
const ObjectIdRef&dest = dests.front();
logAi->debugStream() << boost::format("Of all %d destinations, object oid=%d seems nice") % dests.size() % dest.id.getNum();
@ -1430,22 +1432,6 @@ void VCAI::wander(HeroPtr h)
return;
}
}
//TODO: refactor removing deleted objects from the list
std::vector<const CGObjectInstance *> hlp;
retreiveVisitableObjs(hlp, true);
auto shouldBeErased = [&](const CGObjectInstance *obj) -> bool
{
if(!vstd::contains(hlp, obj))
{
return true;
}
return false;
};
erase_if(dests, shouldBeErased);
erase_if_present(dests, dest); //why that fails sometimes when removing monsters?
boost::sort(dests, CDistanceSorter(h.get())); //find next closest one
}
if (h->visitedTown)