mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
InvStore::unequipSlot: return an iterator to the unequipped item
This commit is contained in:
parent
59c963b6cc
commit
12dbbde1e3
@ -336,18 +336,21 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
||||
return retCount;
|
||||
}
|
||||
|
||||
void MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)
|
||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)
|
||||
{
|
||||
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, *mSlots[slot]))
|
||||
if (stacks(*iter, *it))
|
||||
{
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + mSlots[slot]->getRefData().getCount());
|
||||
mSlots[slot]->getRefData().setCount(0);
|
||||
iter->getRefData().setCount(iter->getRefData().getCount() + it->getRefData().getCount());
|
||||
it->getRefData().setCount(0);
|
||||
retval = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -377,5 +380,9 @@ void MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)
|
||||
}
|
||||
|
||||
/// \todo update actor model
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
return it;
|
||||
}
|
||||
|
@ -113,7 +113,12 @@ namespace MWWorld
|
||||
///
|
||||
/// @return the number of items actually removed
|
||||
|
||||
void unequipSlot(int slot, const Ptr& actor);
|
||||
ContainerStoreIterator unequipSlot(int slot, const Ptr& actor);
|
||||
///< 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).
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user