mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-31 21:26:48 +00:00 
			
		
		
		
	item stacking
This commit is contained in:
		
							parent
							
								
									37095b62c6
								
							
						
					
					
						commit
						5b0251b09f
					
				
					 9 changed files with 60 additions and 2 deletions
				
			
		|  | @ -248,4 +248,12 @@ namespace MWClass | |||
| 
 | ||||
|         return info; | ||||
|     } | ||||
| 
 | ||||
|     std::string Armor::getEnchantment (const MWWorld::Ptr& ptr) const | ||||
|     { | ||||
|         ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref = | ||||
|             ptr.get<ESM::Armor>(); | ||||
| 
 | ||||
|         return ref->base->enchant; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -55,6 +55,9 @@ namespace MWClass | |||
| 
 | ||||
|             virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; | ||||
|             ///< Return the put down sound Id
 | ||||
| 
 | ||||
|             virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const; | ||||
|             ///< @return the enchantment ID if the object is enchanted, otherwise an empty string
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -201,4 +201,12 @@ namespace MWClass | |||
| 
 | ||||
|         return info; | ||||
|     } | ||||
| 
 | ||||
|     std::string Clothing::getEnchantment (const MWWorld::Ptr& ptr) const | ||||
|     { | ||||
|         ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref = | ||||
|             ptr.get<ESM::Clothing>(); | ||||
| 
 | ||||
|         return ref->base->enchant; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -49,6 +49,9 @@ namespace MWClass | |||
| 
 | ||||
|             virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; | ||||
|             ///< Return the put down sound Id
 | ||||
| 
 | ||||
|             virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const; | ||||
|             ///< @return the enchantment ID if the object is enchanted, otherwise an empty string
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -339,4 +339,12 @@ namespace MWClass | |||
| 
 | ||||
|         return info; | ||||
|     } | ||||
| 
 | ||||
|     std::string Weapon::getEnchantment (const MWWorld::Ptr& ptr) const | ||||
|     { | ||||
|         ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref = | ||||
|             ptr.get<ESM::Weapon>(); | ||||
| 
 | ||||
|         return ref->base->enchant; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -55,6 +55,9 @@ namespace MWClass | |||
| 
 | ||||
|             virtual std::string getDownSoundId (const MWWorld::Ptr& ptr) const; | ||||
|             ///< Return the put down sound Id
 | ||||
| 
 | ||||
|             virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const; | ||||
|             ///< @return the enchantment ID if the object is enchanted, otherwise an empty string
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -181,4 +181,9 @@ namespace MWWorld | |||
|     { | ||||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     std::string Class::getEnchantment (const Ptr& ptr) const | ||||
|     { | ||||
|         return ""; | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -136,7 +136,7 @@ namespace MWWorld | |||
|             ///< Set or unset a stance.
 | ||||
| 
 | ||||
|             virtual bool getStance (const Ptr& ptr, Stance stance, bool ignoreForce = false) const; | ||||
|             ////< Check if a stance is active or not.
 | ||||
|             ///< Check if a stance is active or not.
 | ||||
| 
 | ||||
|             virtual float getSpeed (const Ptr& ptr) const; | ||||
|             ///< Return movement speed.
 | ||||
|  | @ -179,6 +179,10 @@ namespace MWWorld | |||
|             virtual std::string getDownSoundId (const Ptr& ptr) const; | ||||
|             ///< Return the down sound ID of \a ptr or throw an exception, if class does not support ID retrieval
 | ||||
|             /// (default implementation: throw an exception)
 | ||||
| 
 | ||||
|             virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const; | ||||
|             ///< @return the enchantment ID if the object is enchanted, otherwise an empty string
 | ||||
|             /// (default implementation: return empty string)
 | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,6 +9,7 @@ | |||
| 
 | ||||
| #include "manualref.hpp" | ||||
| #include "refdata.hpp" | ||||
| #include "class.hpp" | ||||
| 
 | ||||
| namespace | ||||
| { | ||||
|  | @ -46,7 +47,22 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() | |||
| 
 | ||||
| void MWWorld::ContainerStore::add (const Ptr& ptr) | ||||
| { | ||||
|     /// \todo implement item stacking
 | ||||
|     // determine whether to stack or not
 | ||||
|     // item stacking depends on owner, script, enchantment and name
 | ||||
|     for (MWWorld::ContainerStoreIterator iter (begin(getType(ptr))); iter!=end(); ++iter) | ||||
|     { | ||||
|         if (   iter->mCellRef->refID == ptr.mCellRef->refID | ||||
|             && MWWorld::Class::get(*iter).getScript(*iter) == MWWorld::Class::get(ptr).getScript(ptr) | ||||
|             && MWWorld::Class::get(*iter).getEnchantment(*iter) == MWWorld::Class::get(ptr).getEnchantment(ptr) | ||||
|             && iter->mCellRef->owner == ptr.mCellRef->owner) | ||||
|         { | ||||
|             // stack
 | ||||
|             iter->getRefData().setCount( iter->getRefData().getCount() + ptr.getRefData().getCount() ); | ||||
| 
 | ||||
|             flagAsModified(); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     switch (getType (ptr)) | ||||
|     { | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue