diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index c041beffa..4639a1d2d 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -77,31 +77,31 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::end() return ContainerStoreIterator (this); } -bool MWWorld::ContainerStore::stacks(const Ptr& stack, const Ptr& item) +bool MWWorld::ContainerStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { - const MWWorld::Class& cls1 = MWWorld::Class::get(stack); - const MWWorld::Class& cls2 = MWWorld::Class::get(item); + const MWWorld::Class& cls1 = MWWorld::Class::get(ptr1); + const MWWorld::Class& cls2 = MWWorld::Class::get(ptr2); /// \todo add current enchantment charge here when it is implemented - return stack != item // an item never stacks onto itself - && Misc::StringUtils::ciEqual(stack.getCellRef().mRefID, item.getCellRef().mRefID) - && stack.getCellRef().mOwner == item.getCellRef().mOwner - && stack.getCellRef().mSoul == item.getCellRef().mSoul + return ptr1 != ptr2 // an item never stacks onto itself + && Misc::StringUtils::ciEqual(ptr1.getCellRef().mRefID, ptr2.getCellRef().mRefID) + && ptr1.getCellRef().mOwner == ptr2.getCellRef().mOwner + && ptr1.getCellRef().mSoul == ptr2.getCellRef().mSoul // item with a script never stacks - && cls1.getScript(stack) == "" - && cls2.getScript(item) == "" + && cls1.getScript(ptr1) == "" + && cls2.getScript(ptr2) == "" // item with enchantment never stacks (we could revisit this later, // but for now it makes selecting items in the spell window much easier) - && cls1.getEnchantment(stack) == "" - && cls2.getEnchantment(item) == "" + && cls1.getEnchantment(ptr1) == "" + && cls2.getEnchantment(ptr2) == "" // item that is already partly used up never stacks - && (!cls1.hasItemHealth(stack) || stack.getCellRef().mCharge == -1 - || cls1.getItemMaxHealth(stack) == stack.getCellRef().mCharge) - && (!cls2.hasItemHealth(item) || item.getCellRef().mCharge == -1 - || cls2.getItemMaxHealth(item) == item.getCellRef().mCharge); + && (!cls1.hasItemHealth(ptr1) || ptr1.getCellRef().mCharge == -1 + || cls1.getItemMaxHealth(ptr1) == ptr1.getCellRef().mCharge) + && (!cls2.hasItemHealth(ptr2) || ptr2.getCellRef().mCharge == -1 + || cls2.getItemMaxHealth(ptr2) == ptr2.getCellRef().mCharge); } MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr, const Ptr& actorPtr) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index 7278135d8..ca6609ecf 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -91,7 +91,7 @@ namespace MWWorld public: - virtual bool stacks (const Ptr& stack, const Ptr& item); + virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2); ///< @return true if the two specified objects can stack with each other void fill (const ESM::InventoryList& items, const std::string& owner, const MWWorld::ESMStore& store); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 430218058..7bfc11d84 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -285,9 +285,9 @@ void MWWorld::InventoryStore::flagAsModified() mMagicEffectsUpToDate = false; } -bool MWWorld::InventoryStore::stacks(const Ptr& stack, const Ptr& item) +bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2) { - bool canStack = MWWorld::ContainerStore::stacks(stack, item); + bool canStack = MWWorld::ContainerStore::stacks(ptr1, ptr2); if (!canStack) return false; @@ -295,7 +295,7 @@ bool MWWorld::InventoryStore::stacks(const Ptr& stack, const Ptr& item) for (TSlots::const_iterator iter (mSlots.begin()); iter!=mSlots.end(); ++iter) { - if (*iter != end() && (stack == **iter || item == **iter)) + if (*iter != end() && (ptr1 == **iter || ptr2 == **iter)) { bool stackWhenEquipped = MWWorld::Class::get(**iter).getEquipmentSlots(**iter).second; if (!stackWhenEquipped) diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index a974c0dae..b7d374824 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -107,7 +107,7 @@ namespace MWWorld ///< \attention This function is internal to the world model and should not be called from /// outside. - virtual bool stacks (const Ptr& stack, const Ptr& item); + virtual bool stacks (const Ptr& ptr1, const Ptr& ptr2); ///< @return true if the two specified objects can stack with each other virtual int remove(const Ptr& item, int count, const Ptr& actor);