Merge remote-tracking branch 'scrawl/enchantment_error'

openmw-37
Marc Zinnschlag 9 years ago
commit 90036e23b3

@ -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…
Cancel
Save