mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 20:26:43 +00:00 
			
		
		
		
	Cycle with equipped items if all slots are occupied (Fixes #1395)
This commit is contained in:
		
							parent
							
								
									00775035af
								
							
						
					
					
						commit
						c0f1449004
					
				
					 1 changed files with 18 additions and 9 deletions
				
			
		|  | @ -41,6 +41,8 @@ namespace MWWorld | |||
| 
 | ||||
|         // slots that this item can be equipped in
 | ||||
|         std::pair<std::vector<int>, bool> slots_ = getTarget().getClass().getEquipmentSlots(getTarget()); | ||||
|         if (slots_.first.empty()) | ||||
|             return; | ||||
| 
 | ||||
|         // retrieve ContainerStoreIterator to the item
 | ||||
|         MWWorld::ContainerStoreIterator it = invStore.begin(); | ||||
|  | @ -55,20 +57,13 @@ namespace MWWorld | |||
|         assert(it != invStore.end()); | ||||
| 
 | ||||
|         // equip the item in the first free slot
 | ||||
|         for (std::vector<int>::const_iterator slot=slots_.first.begin(); | ||||
|             slot!=slots_.first.end(); ++slot) | ||||
|         std::vector<int>::const_iterator slot=slots_.first.begin(); | ||||
|         for (;slot!=slots_.first.end(); ++slot) | ||||
|         { | ||||
|             // if the item is equipped already, nothing to do
 | ||||
|             if (invStore.getSlot(*slot) == it) | ||||
|                 return; | ||||
| 
 | ||||
|             // if all slots are occupied, replace the last slot
 | ||||
|             if (slot == --slots_.first.end()) | ||||
|             { | ||||
|                 invStore.equip(*slot, it, actor); | ||||
|                 break; | ||||
|             } | ||||
| 
 | ||||
|             if (invStore.getSlot(*slot) == invStore.end()) | ||||
|             { | ||||
|                 // slot is not occupied
 | ||||
|  | @ -76,5 +71,19 @@ namespace MWWorld | |||
|                 break; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         // all slots are occupied -> cycle
 | ||||
|         // move all slots one towards begin(), then equip the item in the slot that is now free
 | ||||
|         if (slot == slots_.first.end()) | ||||
|         { | ||||
|             for (slot=slots_.first.begin();slot!=slots_.first.end(); ++slot) | ||||
|             { | ||||
|                 invStore.unequipSlot(*slot, actor); | ||||
|                 if (slot+1 != slots_.first.end()) | ||||
|                     invStore.equip(*slot, invStore.getSlot(*(slot+1)), actor); | ||||
|                 else | ||||
|                     invStore.equip(*slot, it, actor); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue