mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-28 07:32:00 -04: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
@ -325,7 +325,8 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
|||||||
|
|
||||||
if (*mSlots[slot] == item)
|
if (*mSlots[slot] == item)
|
||||||
{
|
{
|
||||||
unequipSlot(slot, actor);
|
// restacking is disabled cause it may break removal
|
||||||
|
unequipSlot(slot, actor, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,14 +346,16 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
|||||||
return retCount;
|
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);
|
ContainerStoreIterator it = getSlot(slot);
|
||||||
|
|
||||||
if (it != end())
|
if (it != end())
|
||||||
{
|
{
|
||||||
// restack item previously in this slot
|
|
||||||
ContainerStoreIterator retval = it;
|
ContainerStoreIterator retval = it;
|
||||||
|
|
||||||
|
if (restack) {
|
||||||
|
// restack item previously in this slot
|
||||||
for (MWWorld::ContainerStoreIterator iter (begin()); iter != end(); ++iter)
|
for (MWWorld::ContainerStoreIterator iter (begin()); iter != end(); ++iter)
|
||||||
{
|
{
|
||||||
if (stacks(*iter, *it))
|
if (stacks(*iter, *it))
|
||||||
@ -363,6 +366,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// empty this slot
|
// empty this slot
|
||||||
mSlots[slot] = end();
|
mSlots[slot] = end();
|
||||||
|
@ -116,12 +116,12 @@ namespace MWWorld
|
|||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @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.
|
///< Unequip \a slot.
|
||||||
///
|
///
|
||||||
/// @return an iterator to the item that was previously in the 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
|
/// (if \a restack is true, the item can be re-stacked so its count
|
||||||
/// was equipped).
|
/// may differ from when it was equipped).
|
||||||
|
|
||||||
ContainerStoreIterator unequipItem(const Ptr& item, const Ptr& actor);
|
ContainerStoreIterator unequipItem(const Ptr& item, const Ptr& actor);
|
||||||
///< Unequip an item identified by its Ptr. An exception is thrown
|
///< Unequip an item identified by its Ptr. An exception is thrown
|
||||||
|
Loading…
x
Reference in New Issue
Block a user