mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 16:56:42 +00:00 
			
		
		
		
	Fix an issue with InventoryStore copy constructor. Don't copy the iterator directly - mContainer will be wrong and comparisons against end() will always fail.
This caused an exception when looting a creature that had moved cells.
This commit is contained in:
		
							parent
							
								
									365ae15532
								
							
						
					
					
						commit
						ba67bf45f8
					
				
					 1 changed files with 11 additions and 3 deletions
				
			
		|  | @ -34,6 +34,13 @@ void MWWorld::InventoryStore::copySlots (const InventoryStore& store) | |||
| 
 | ||||
|         mSlots.push_back (slot); | ||||
|     } | ||||
| 
 | ||||
|     // some const-trickery, required because of a flaw in the handling of MW-references and the
 | ||||
|     // resulting workarounds
 | ||||
|     std::size_t distance = std::distance (const_cast<InventoryStore&> (store).begin(), const_cast<InventoryStore&> (store).mSelectedEnchantItem); | ||||
|     ContainerStoreIterator slot = begin(); | ||||
|     std::advance (slot, distance); | ||||
|     mSelectedEnchantItem = slot; | ||||
| } | ||||
| 
 | ||||
| void MWWorld::InventoryStore::initSlots (TSlots& slots_) | ||||
|  | @ -54,18 +61,19 @@ MWWorld::InventoryStore::InventoryStore() | |||
| MWWorld::InventoryStore::InventoryStore (const InventoryStore& store) | ||||
| : ContainerStore (store) | ||||
|  , mSelectedEnchantItem(end()) | ||||
|  , mListener(NULL) | ||||
|  , mUpdatesEnabled(true) | ||||
| { | ||||
|     mMagicEffects = store.mMagicEffects; | ||||
|     mFirstAutoEquip = store.mFirstAutoEquip; | ||||
|     mSelectedEnchantItem = store.mSelectedEnchantItem; | ||||
|     mListener = store.mListener; | ||||
|     mUpdatesEnabled = store.mUpdatesEnabled; | ||||
| 
 | ||||
|     mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes; | ||||
|     copySlots (store); | ||||
| } | ||||
| 
 | ||||
| MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStore& store) | ||||
| { | ||||
|     mListener = store.mListener; | ||||
|     mMagicEffects = store.mMagicEffects; | ||||
|     mFirstAutoEquip = store.mFirstAutoEquip; | ||||
|     mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes; | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue