mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 18:19:55 +00:00
Enchantment error handling fix (Fixes #2959)
Catch errors about missing enchantments before they propagate up the stack and interrupt the whole frame update.
This commit is contained in:
parent
ee450471fd
commit
f36d463617
2 changed files with 18 additions and 4 deletions
|
@ -1,5 +1,7 @@
|
||||||
#include "spellmodel.hpp"
|
#include "spellmodel.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
|
@ -79,8 +81,13 @@ namespace MWGui
|
||||||
const std::string enchantId = item.getClass().getEnchantment(item);
|
const std::string enchantId = item.getClass().getEnchantment(item);
|
||||||
if (enchantId.empty())
|
if (enchantId.empty())
|
||||||
continue;
|
continue;
|
||||||
const ESM::Enchantment* enchant =
|
const ESM::Enchantment* enchant = esmStore.get<ESM::Enchantment>().search(enchantId);
|
||||||
esmStore.get<ESM::Enchantment>().find(item.getClass().getEnchantment(item));
|
if (!enchant)
|
||||||
|
{
|
||||||
|
std::cerr << "Can't find enchantment '" << enchantId << "' on item " << item.getCellRef().getRefId() << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (enchant->mData.mType != ESM::Enchantment::WhenUsed && enchant->mData.mType != ESM::Enchantment::CastOnce)
|
if (enchant->mData.mType != ESM::Enchantment::WhenUsed && enchant->mData.mType != ESM::Enchantment::CastOnce)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -645,8 +645,15 @@ void MWWorld::InventoryStore::updateRechargingItems()
|
||||||
{
|
{
|
||||||
if (it->getClass().getEnchantment(*it) != "")
|
if (it->getClass().getEnchantment(*it) != "")
|
||||||
{
|
{
|
||||||
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(
|
std::string enchantmentId = it->getClass().getEnchantment(*it);
|
||||||
it->getClass().getEnchantment(*it));
|
const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().search(
|
||||||
|
enchantmentId);
|
||||||
|
if (!enchantment)
|
||||||
|
{
|
||||||
|
std::cerr << "Can't find enchantment '" << enchantmentId << "' on item " << it->getCellRef().getRefId() << std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed
|
if (enchantment->mData.mType == ESM::Enchantment::WhenUsed
|
||||||
|| enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
|| enchantment->mData.mType == ESM::Enchantment::WhenStrikes)
|
||||||
mRechargingItems.push_back(std::make_pair(it, static_cast<float>(enchantment->mData.mCharge)));
|
mRechargingItems.push_back(std::make_pair(it, static_cast<float>(enchantment->mData.mCharge)));
|
||||||
|
|
Loading…
Reference in a new issue