Remove missing souls, remove some runaway exceptions (Fixes #4111)

pull/392/head
scrawl 6 years ago
parent 7f39dbb129
commit 870c658500
No known key found for this signature in database
GPG Key ID: 2E6CC3676024C402

@ -83,8 +83,9 @@ namespace MWClass
if (ptr.getCellRef().getSoul() != "")
{
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(ref->mRef.getSoul());
value *= creature->mData.mSoul;
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ref->mRef.getSoul());
if (creature)
value *= creature->mData.mSoul;
}
return value;
@ -148,8 +149,9 @@ namespace MWClass
if (ref->mRef.getSoul() != "")
{
const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.getSoul());
info.caption += " (" + creature->mName + ")";
const ESM::Creature *creature = store.get<ESM::Creature>().search(ref->mRef.getSoul());
if (creature)
info.caption += " (" + creature->mName + ")";
}
std::string text;
@ -210,7 +212,7 @@ namespace MWClass
std::shared_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr) const
{
if (ptr.getCellRef().getSoul().empty())
if (ptr.getCellRef().getSoul().empty() || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ptr.getCellRef().getSoul()))
return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
else
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr));

@ -208,7 +208,7 @@ namespace MWGui
if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
return false;
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name()
|| base.getCellRef().getSoul() == ""))
|| base.getCellRef().getSoul() == "" || !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(base.getCellRef().getSoul())))
return false;
if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name()))
return false;

@ -242,8 +242,11 @@ namespace MWMechanics
return 0;
if(mSoulGemPtr.getCellRef().getSoul()=="")
return 0;
const ESM::Creature* soul = store.get<ESM::Creature>().find(mSoulGemPtr.getCellRef().getSoul());
return soul->mData.mSoul;
const ESM::Creature* soul = store.get<ESM::Creature>().search(mSoulGemPtr.getCellRef().getSoul());
if(soul)
return soul->mData.mSoul;
else
return 0;
}
int Enchanting::getMaxEnchantValue() const

@ -48,6 +48,12 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
}
mClass->readAdditionalState (ptr, state);
if (!mRef.getSoul().empty() && !MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(mRef.getSoul()))
{
std::cerr << "Soul '" << mRef.getSoul() << "' not found, removing the soul from soul gem" << std::endl;
mRef.setSoul(std::string());
}
}
void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const

Loading…
Cancel
Save