forked from mirror/openmw-tes3mp
InvStore::unequipSlot: return an iterator to the unequipped item
This commit is contained in:
parent
59c963b6cc
commit
12dbbde1e3
2 changed files with 17 additions and 5 deletions
|
@ -336,18 +336,21 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
|
||||||
return retCount;
|
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);
|
ContainerStoreIterator it = getSlot(slot);
|
||||||
|
|
||||||
if (it != end())
|
if (it != end())
|
||||||
{
|
{
|
||||||
// restack item previously in this slot
|
// restack item previously in this slot
|
||||||
|
ContainerStoreIterator retval = it;
|
||||||
for (MWWorld::ContainerStoreIterator iter (begin()); iter != end(); ++iter)
|
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());
|
iter->getRefData().setCount(iter->getRefData().getCount() + it->getRefData().getCount());
|
||||||
mSlots[slot]->getRefData().setCount(0);
|
it->getRefData().setCount(0);
|
||||||
|
retval = iter;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -377,5 +380,9 @@ void MWWorld::InventoryStore::unequipSlot(int slot, const MWWorld::Ptr& actor)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \todo update actor model
|
/// \todo update actor model
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,12 @@ namespace MWWorld
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @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…
Reference in a new issue