forked from mirror/openmw-tes3mp
Merge branch 'itemstacking' into inventoryGUI
Conflicts: apps/openmw/mwclass/armor.hpp apps/openmw/mwclass/clothing.hpp apps/openmw/mwclass/weapon.hpp apps/openmw/mwworld/class.hpp
This commit is contained in:
commit
6ee4e8fb5a
9 changed files with 63 additions and 5 deletions
|
@ -256,4 +256,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +58,9 @@ namespace MWClass
|
|||
|
||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -209,4 +209,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ namespace MWClass
|
|||
|
||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -347,4 +347,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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace MWClass
|
|||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
|
||||
virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
|
||||
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -187,4 +187,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.
|
||||
|
@ -182,6 +182,10 @@ namespace MWWorld
|
|||
|
||||
virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
|
||||
///< Return name of inventory icon.
|
||||
|
||||
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,9 +47,26 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end()
|
|||
|
||||
void MWWorld::ContainerStore::add (const Ptr& ptr)
|
||||
{
|
||||
/// \todo implement item stacking
|
||||
int type = getType(ptr);
|
||||
|
||||
switch (getType (ptr))
|
||||
// determine whether to stack or not
|
||||
// item stacking depends on owner, script, enchantment and name
|
||||
for (MWWorld::ContainerStoreIterator iter (begin(type)); 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 (type)
|
||||
{
|
||||
case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); break;
|
||||
case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); break;
|
||||
|
@ -456,4 +474,4 @@ bool MWWorld::operator== (const ContainerStoreIterator& left, const ContainerSto
|
|||
bool MWWorld::operator!= (const ContainerStoreIterator& left, const ContainerStoreIterator& right)
|
||||
{
|
||||
return !(left==right);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue