mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 07:56:37 +00:00 
			
		
		
		
	Simplify logic in AiSequence::execute
This commit is contained in:
		
							parent
							
								
									e60e0b55eb
								
							
						
					
					
						commit
						0ce29a6131
					
				
					 1 changed files with 3 additions and 10 deletions
				
			
		|  | @ -238,8 +238,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac | |||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     auto packageIt = mPackages.begin(); | ||||
|     MWMechanics::AiPackage* package = packageIt->get(); | ||||
|     auto* package = mPackages.front().get(); | ||||
|     if (!package->alwaysActive() && outOfRange) | ||||
|         return; | ||||
| 
 | ||||
|  | @ -301,8 +300,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac | |||
|             std::rotate(mPackages.begin(), itActualCombat, std::next(itActualCombat)); | ||||
|         } | ||||
| 
 | ||||
|         packageIt = mPackages.begin(); | ||||
|         package = packageIt->get(); | ||||
|         package = mPackages.front().get(); | ||||
|         packageTypeId = package->getTypeId(); | ||||
|     } | ||||
| 
 | ||||
|  | @ -310,8 +308,6 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac | |||
|     { | ||||
|         if (package->execute(actor, characterController, mAiState, duration)) | ||||
|         { | ||||
|             const auto packageIdx = std::distance(mPackages.begin(), packageIt); | ||||
| 
 | ||||
|             // Put repeating non-combat AI packages on the end of the stack so they can be used again
 | ||||
|             if (isActualAiPackage(packageTypeId) && package->getRepeat()) | ||||
|             { | ||||
|  | @ -319,12 +315,9 @@ void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& charac | |||
|                 mPackages.push_back(package->clone()); | ||||
|             } | ||||
| 
 | ||||
|             // Iterator may have been invalidated by push back ensure its correct.
 | ||||
|             packageIt = mPackages.begin() + packageIdx; | ||||
| 
 | ||||
|             // To account for the rare case where AiPackage::execute() queued another AI package
 | ||||
|             // (e.g. AiPursue executing a dialogue script that uses startCombat)
 | ||||
|             erase(packageIt); | ||||
|             erase(mPackages.begin()); | ||||
|             if (isActualAiPackage(packageTypeId)) | ||||
|                 mDone = true; | ||||
|         } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue