forked from mirror/openmw-tes3mp
Minor changes to getActorsSidingWith
This commit is contained in:
parent
6272e1c674
commit
470988f9ef
1 changed files with 3 additions and 4 deletions
|
@ -1597,17 +1597,16 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actors::getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out, std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >& cachedAllies) {
|
void Actors::getActorsSidingWith(const MWWorld::Ptr &actor, std::set<MWWorld::Ptr>& out, std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >& cachedAllies) {
|
||||||
std::list<MWWorld::Ptr> followers = getActorsSidingWith(actor);
|
|
||||||
|
|
||||||
// If we have already found actor's allies, use the cache
|
// If we have already found actor's allies, use the cache
|
||||||
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >::const_iterator search = cachedAllies.find(actor);
|
std::map<const MWWorld::Ptr, const std::set<MWWorld::Ptr> >::const_iterator search = cachedAllies.find(actor);
|
||||||
if (search != cachedAllies.end())
|
if (search != cachedAllies.end())
|
||||||
out = search->second;
|
out.insert(search->second.begin(), search->second.end());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
std::list<MWWorld::Ptr> followers = getActorsSidingWith(actor);
|
||||||
for (std::list<MWWorld::Ptr>::iterator it = followers.begin(); it != followers.end(); ++it)
|
for (std::list<MWWorld::Ptr>::iterator it = followers.begin(); it != followers.end(); ++it)
|
||||||
if (out.insert(*it).second)
|
if (out.insert(*it).second)
|
||||||
getActorsSidingWith(*it, out);
|
getActorsSidingWith(*it, out, cachedAllies);
|
||||||
|
|
||||||
// Cache ptrs and their sets of allies
|
// Cache ptrs and their sets of allies
|
||||||
cachedAllies.insert(std::make_pair(actor, out));
|
cachedAllies.insert(std::make_pair(actor, out));
|
||||||
|
|
Loading…
Reference in a new issue