mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	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) { | ||||
|         std::list<MWWorld::Ptr> followers = getActorsSidingWith(actor); | ||||
| 
 | ||||
|         // 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); | ||||
|         if (search != cachedAllies.end()) | ||||
|             out = search->second; | ||||
|             out.insert(search->second.begin(), search->second.end()); | ||||
|         else | ||||
|         { | ||||
|             std::list<MWWorld::Ptr> followers = getActorsSidingWith(actor); | ||||
|             for (std::list<MWWorld::Ptr>::iterator it = followers.begin(); it != followers.end(); ++it) | ||||
|                 if (out.insert(*it).second) | ||||
|                     getActorsSidingWith(*it, out); | ||||
|                     getActorsSidingWith(*it, out, cachedAllies); | ||||
| 
 | ||||
|             // Cache ptrs and their sets of allies
 | ||||
|             cachedAllies.insert(std::make_pair(actor, out)); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue