mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Add InventoryStore::unequipItem()
This commit is contained in:
parent
12dbbde1e3
commit
37e91a278e
@ -386,3 +386,15 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipSlot(int slot, c
|
||||
|
||||
return it;
|
||||
}
|
||||
|
||||
MWWorld::ContainerStoreIterator MWWorld::InventoryStore::unequipItem(const MWWorld::Ptr& item, const MWWorld::Ptr& actor)
|
||||
{
|
||||
for (int slot=0; slot<MWWorld::InventoryStore::Slots; ++slot)
|
||||
{
|
||||
MWWorld::ContainerStoreIterator equipped = getSlot(slot);
|
||||
if (equipped != end() && *equipped == item)
|
||||
return unequipSlot(slot, actor);
|
||||
}
|
||||
|
||||
throw std::runtime_error ("attempt to unequip an item that is not currently equipped");
|
||||
}
|
||||
|
@ -119,6 +119,14 @@ namespace MWWorld
|
||||
/// @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).
|
||||
|
||||
ContainerStoreIterator unequipItem(const Ptr& item, const Ptr& actor);
|
||||
///< Unequip an item identified by its Ptr. An exception is thrown
|
||||
/// if the item is not currently equipped.
|
||||
///
|
||||
/// @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