1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-01 03:21:41 +00:00

Merge branch 'fix_remove_from_inventory' into 'master'

[Lua] Fix removing from inventory

See merge request OpenMW/openmw!3229
This commit is contained in:
psi29a 2023-07-27 09:32:08 +00:00
commit cf8af70764
2 changed files with 4 additions and 8 deletions

View File

@ -378,7 +378,7 @@ namespace MWLua
ptr.getRefData().setCount(ptr.getRefData().getCount() + countToRemove);
// And now remove properly
if (ptr.getContainerStore())
ptr.getContainerStore()->remove(ptr, countToRemove);
ptr.getContainerStore()->remove(ptr, countToRemove, false);
else
{
MWBase::Environment::get().getWorld()->disable(ptr);

View File

@ -211,13 +211,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::findSlot(int slot) cons
if (mSlots[slot] == end())
return mSlots[slot];
if (mSlots[slot]->getRefData().getCount() < 1)
{
// Object has been deleted
// This should no longer happen, since the new remove function will unequip first
throw std::runtime_error(
"Invalid slot, make sure you are not calling RefData::setCount for a container object");
}
// NOTE: mSlots[slot]->getRefData().getCount() can be zero if the item is marked
// for removal by a Lua script, but the removal action is not yet processed.
// The item will be automatically unequiped in the current frame.
return mSlots[slot];
}