mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-29 09:32:45 +00:00
[Lua] Fix removing from inventory
This commit is contained in:
parent
488657d9b4
commit
f99582e671
@ -378,7 +378,7 @@ namespace MWLua
|
|||||||
ptr.getRefData().setCount(ptr.getRefData().getCount() + countToRemove);
|
ptr.getRefData().setCount(ptr.getRefData().getCount() + countToRemove);
|
||||||
// And now remove properly
|
// And now remove properly
|
||||||
if (ptr.getContainerStore())
|
if (ptr.getContainerStore())
|
||||||
ptr.getContainerStore()->remove(ptr, countToRemove);
|
ptr.getContainerStore()->remove(ptr, countToRemove, false);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->disable(ptr);
|
MWBase::Environment::get().getWorld()->disable(ptr);
|
||||||
|
@ -211,13 +211,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::findSlot(int slot) cons
|
|||||||
if (mSlots[slot] == end())
|
if (mSlots[slot] == end())
|
||||||
return mSlots[slot];
|
return mSlots[slot];
|
||||||
|
|
||||||
if (mSlots[slot]->getRefData().getCount() < 1)
|
// 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.
|
||||||
// Object has been deleted
|
// The item will be automatically unequiped in the current frame.
|
||||||
// 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");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSlots[slot];
|
return mSlots[slot];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user