|
|
|
@ -4,6 +4,12 @@
|
|
|
|
|
#include <iterator>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
#include <components/esm/loadench.hpp>
|
|
|
|
|
|
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwworld/world.hpp"
|
|
|
|
|
|
|
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
|
|
|
|
|
|
|
|
|
#include "class.hpp"
|
|
|
|
@ -32,13 +38,13 @@ void MWWorld::InventoryStore::initSlots (TSlots& slots)
|
|
|
|
|
slots.push_back (end());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::InventoryStore::InventoryStore()
|
|
|
|
|
MWWorld::InventoryStore::InventoryStore() : mMagicEffectsUpToDate (false)
|
|
|
|
|
{
|
|
|
|
|
initSlots (mSlots);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::InventoryStore::InventoryStore (const InventoryStore& store)
|
|
|
|
|
: ContainerStore (store)
|
|
|
|
|
: ContainerStore (store), mMagicEffectsUpToDate (false)
|
|
|
|
|
{
|
|
|
|
|
copySlots (store);
|
|
|
|
|
}
|
|
|
|
@ -201,6 +207,38 @@ void MWWorld::InventoryStore::autoEquip (const MWMechanics::NpcStats& stats)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects()
|
|
|
|
|
{
|
|
|
|
|
if (!mMagicEffectsUpToDate)
|
|
|
|
|
{
|
|
|
|
|
mMagicEffects = MWMechanics::MagicEffects();
|
|
|
|
|
|
|
|
|
|
for (TSlots::const_iterator iter (mSlots.begin()); iter!=mSlots.end(); ++iter)
|
|
|
|
|
if (*iter!=end())
|
|
|
|
|
{
|
|
|
|
|
std::string enchantmentId = MWWorld::Class::get (**iter).getEnchantment (**iter);
|
|
|
|
|
|
|
|
|
|
if (!enchantmentId.empty())
|
|
|
|
|
{
|
|
|
|
|
const ESM::Enchantment& enchantment =
|
|
|
|
|
*MWBase::Environment::get().getWorld()->getStore().enchants.find (enchantmentId);
|
|
|
|
|
|
|
|
|
|
if (enchantment.data.type==ESM::Enchantment::ConstantEffect)
|
|
|
|
|
mMagicEffects.add (enchantment.effects);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mMagicEffectsUpToDate = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return mMagicEffects;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MWWorld::InventoryStore::flagAsModified()
|
|
|
|
|
{
|
|
|
|
|
mMagicEffectsUpToDate = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool MWWorld::InventoryStore::stacks(const Ptr& ptr1, const Ptr& ptr2)
|
|
|
|
|
{
|
|
|
|
|
bool canStack = MWWorld::ContainerStore::stacks(ptr1, ptr2);
|
|
|
|
|