[Client] Catch and ignore attempts to add invalid items to containers

0.8.2
David Cernat 2 years ago
parent 5dbdc92a1c
commit 14a8dae86c

@ -226,23 +226,30 @@ void ObjectList::editContainers(MWWorld::CellStore* cellStore)
if (action == BaseObjectList::SET || action == BaseObjectList::ADD)
{
// Create a ManualRef to be able to set item charge
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), containerItem.refId, 1);
MWWorld::Ptr newPtr = ref.getPtr();
try
{
// Create a ManualRef to be able to set item charge
MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), containerItem.refId, 1);
MWWorld::Ptr newPtr = ref.getPtr();
if (containerItem.count > 1)
newPtr.getRefData().setCount(containerItem.count);
if (containerItem.count > 1)
newPtr.getRefData().setCount(containerItem.count);
if (containerItem.charge > -1)
newPtr.getCellRef().setCharge(containerItem.charge);
if (containerItem.charge > -1)
newPtr.getCellRef().setCharge(containerItem.charge);
if (containerItem.enchantmentCharge > -1)
newPtr.getCellRef().setEnchantmentCharge(containerItem.enchantmentCharge);
if (containerItem.enchantmentCharge > -1)
newPtr.getCellRef().setEnchantmentCharge(containerItem.enchantmentCharge);
if (!containerItem.soul.empty())
newPtr.getCellRef().setSoul(containerItem.soul);
if (!containerItem.soul.empty())
newPtr.getCellRef().setSoul(containerItem.soul);
containerStore.add(newPtr, containerItem.count, ownerPtr);
containerStore.add(newPtr, containerItem.count, ownerPtr);
}
catch (std::exception&)
{
LOG_APPEND(TimedLog::LOG_ERROR, "-- Ignored invalid container item %s", containerItem.refId.c_str());
}
}
else if (action == BaseObjectList::REMOVE && containerItem.actionCount > 0)

Loading…
Cancel
Save