mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Pass item count to ManualRef constructor
This remove the need to call setCount in multiple places.
This commit is contained in:
		
							parent
							
								
									0691978603
								
							
						
					
					
						commit
						aefa54d72d
					
				
					 8 changed files with 7 additions and 19 deletions
				
			
		|  | @ -219,7 +219,6 @@ namespace MWClass | |||
|             MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = | ||||
|                 newRef.getPtr().get<ESM::Miscellaneous>(); | ||||
|             newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); | ||||
|             newPtr.getRefData ().setCount(1); | ||||
|             newPtr.getCellRef().mGoldValue = goldAmount; | ||||
|         } else { | ||||
|             MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = | ||||
|  |  | |||
|  | @ -207,8 +207,7 @@ namespace MWGui | |||
| 
 | ||||
|         if (amount > 0) | ||||
|         { | ||||
|             MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); | ||||
|             ref.getPtr().getRefData().setCount(amount); | ||||
|             MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001", amount); | ||||
|             playerStore.add(ref.getPtr(), player); | ||||
|         } | ||||
|         else | ||||
|  |  | |||
|  | @ -84,9 +84,8 @@ namespace MWMechanics | |||
|         enchantment.mEffects = mEffectList; | ||||
| 
 | ||||
|         // Create a new item
 | ||||
|         MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId); | ||||
|         MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), mOldItemId, 1); | ||||
|         const MWWorld::Ptr& newItemPtr = ref.getPtr(); | ||||
|         newItemPtr.getRefData().setCount(1); | ||||
| 
 | ||||
|         // Apply the enchantment
 | ||||
|         const ESM::Enchantment *enchantmentPtr = MWBase::Environment::get().getWorld()->createRecord (enchantment); | ||||
|  |  | |||
|  | @ -53,9 +53,7 @@ namespace MWScript | |||
|                     if (count == 0) | ||||
|                         return; | ||||
| 
 | ||||
|                     MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item); | ||||
| 
 | ||||
|                     ref.getPtr().getRefData().setCount (count); | ||||
|                     MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, count); | ||||
| 
 | ||||
|                     // Configure item's script variables
 | ||||
|                     std::string script = MWWorld::Class::get(ref.getPtr()).getScript(ref.getPtr()); | ||||
|  |  | |||
|  | @ -348,9 +348,7 @@ namespace MWScript | |||
|                     const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); | ||||
|                     store.get<ESM::Creature>().find(creature); // This line throws an exception if it can't find the creature
 | ||||
| 
 | ||||
|                     MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), gem); | ||||
| 
 | ||||
|                     ref.getPtr().getRefData().setCount (1); | ||||
|                     MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), gem, 1); | ||||
| 
 | ||||
|                     ref.getPtr().getCellRef().mSoul = creature; | ||||
| 
 | ||||
|  |  | |||
|  | @ -496,9 +496,8 @@ namespace MWScript | |||
| 
 | ||||
|                     // create item
 | ||||
|                     MWWorld::CellStore* store = actor.getCell(); | ||||
|                     MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(),itemID); | ||||
|                     MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), itemID, count); | ||||
|                     ref.getPtr().getCellRef().mPos = ipos; | ||||
|                     ref.getPtr().getRefData().setCount(count); | ||||
| 
 | ||||
|                     MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(),*store,ipos); | ||||
|                 } | ||||
|  |  | |||
|  | @ -140,11 +140,9 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImp (const Ptr& ptr) | |||
|         || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_025") | ||||
|         || Misc::StringUtils::ciEqual(ptr.getCellRef().mRefID, "gold_100")) | ||||
|     { | ||||
|         MWWorld::ManualRef ref(esmStore, "Gold_001"); | ||||
| 
 | ||||
|         int count = MWWorld::Class::get(ptr).getValue(ptr) * ptr.getRefData().getCount(); | ||||
|         MWWorld::ManualRef ref(esmStore, "Gold_001", count); | ||||
| 
 | ||||
|         ref.getPtr().getRefData().setCount(count); | ||||
|         for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) | ||||
|         { | ||||
|             if (Misc::StringUtils::ciEqual((*iter).get<ESM::Miscellaneous>()->mRef.mRefID, "gold_001")) | ||||
|  | @ -250,7 +248,7 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std:: | |||
| 
 | ||||
|     try | ||||
|     { | ||||
|         ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id); | ||||
|         ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id, count); | ||||
| 
 | ||||
|         if (ref.getPtr().getTypeName()==typeid (ESM::ItemLevList).name()) | ||||
|         { | ||||
|  | @ -300,7 +298,6 @@ void MWWorld::ContainerStore::addInitialItem (const std::string& id, const std:: | |||
|         } | ||||
|         else | ||||
|         { | ||||
|             ref.getPtr().getRefData().setCount (count); | ||||
|             ref.getPtr().getCellRef().mOwner = owner; | ||||
|             addImp (ref.getPtr()); | ||||
|         } | ||||
|  |  | |||
|  | @ -1949,7 +1949,6 @@ namespace MWWorld | |||
|         if(werewolf) | ||||
|         { | ||||
|             ManualRef ref(getStore(), "WerewolfRobe"); | ||||
|             ref.getPtr().getRefData().setCount(1); | ||||
| 
 | ||||
|             // Configure item's script variables
 | ||||
|             std::string script = Class::get(ref.getPtr()).getScript(ref.getPtr()); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue