mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:23:53 +00:00
Disable equipped item re-stacking when the item is removed from inventory
The item was not removed if it was re-stacked.
This commit is contained in:
parent
d2dcf0b203
commit
bbfd7f4c9d
2 changed files with 17 additions and 13 deletions
|
@ -325,7 +325,8 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
|||
|
||||
if (*mSlots[slot] == item)
|
||||
{
|
||||
unequipSlot(slot, actor);
|
||||
// restacking is disabled cause it may break removal
|
||||
unequipSlot(slot, actor, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -345,22 +346,25 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
|||
return retCount;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)
|
||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor, bool restack)
|
||||
{
|
||||
ContainerStoreIterator it = getSlot(slot);
|
||||
|
||||
if (it != end())
|
||||
{
|
||||
// restack item previously in this slot
|
||||
ContainerStoreIterator retval = it;
|
||||
for (MWWorld::ContainerStoreIterator iter (begin()); iter != end(); ++iter)
|
||||
{
|
||||
if (stacks(*iter, *it))
|
||||
|
||||
if (restack) {
|
||||
// restack item previously in this slot
|
||||
for (MWWorld::ContainerStoreIterator iter (begin()); iter != end(); ++iter)
|
||||
{
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + it->getRefData().getCount());
|
||||
it->getRefData().setCount(0);
|
||||
retval = iter;
|
||||
break;
|
||||
if (stacks(*iter, *it))
|
||||
{
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + it->getRefData().getCount());
|
||||
it->getRefData().setCount(0);
|
||||
retval = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,12 +116,12 @@ namespace MWWorld
|
|||
///
|
||||
/// @return the number of items actually removed
|
||||
|
||||
ContainerStoreIterator unequipSlot(int slot, const Ptr& actor);
|
||||
ContainerStoreIterator unequipSlot(int slot, const Ptr& actor, bool restack = true);
|
||||
///< Unequip \a slot.
|
||||
///
|
||||
/// @return an iterator to the item that was previously in the slot
|
||||
/// (it can be re-stacked so its count may be different than when it
|
||||
/// was equipped).
|
||||
/// (if \a restack is true, the item can be re-stacked so its count
|
||||
/// may differ from when it was equipped).
|
||||
|
||||
ContainerStoreIterator unequipItem(const Ptr& item, const Ptr& actor);
|
||||
///< Unequip an item identified by its Ptr. An exception is thrown
|
||||
|
|
Loading…
Reference in a new issue