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

pull/392/head
scrawl 7 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() != "") if (ptr.getCellRef().getSoul() != "")
{ {
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(ref->mRef.getSoul()); const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().search(ref->mRef.getSoul());
value *= creature->mData.mSoul; if (creature)
value *= creature->mData.mSoul;
} }
return value; return value;
@ -148,8 +149,9 @@ namespace MWClass
if (ref->mRef.getSoul() != "") if (ref->mRef.getSoul() != "")
{ {
const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.getSoul()); const ESM::Creature *creature = store.get<ESM::Creature>().search(ref->mRef.getSoul());
info.caption += " (" + creature->mName + ")"; if (creature)
info.caption += " (" + creature->mName + ")";
} }
std::string text; std::string text;
@ -210,7 +212,7 @@ namespace MWClass
std::shared_ptr<MWWorld::Action> Miscellaneous::use (const MWWorld::Ptr& ptr) const 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()); return std::shared_ptr<MWWorld::Action>(new MWWorld::NullAction());
else else
return std::shared_ptr<MWWorld::Action>(new MWWorld::ActionSoulgem(ptr)); 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)) if ((mFilter & Filter_OnlyEnchanted) && !(item.mFlags & ItemStack::Flag_Enchanted))
return false; return false;
if ((mFilter & Filter_OnlyChargedSoulstones) && (base.getTypeName() != typeid(ESM::Miscellaneous).name() 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; return false;
if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name())) if ((mFilter & Filter_OnlyRepairTools) && (base.getTypeName() != typeid(ESM::Repair).name()))
return false; return false;

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

@ -48,6 +48,12 @@ void MWWorld::LiveCellRefBase::loadImp (const ESM::ObjectState& state)
} }
mClass->readAdditionalState (ptr, 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 void MWWorld::LiveCellRefBase::saveImp (ESM::ObjectState& state) const

Loading…
Cancel
Save