1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-02-06 13:15:33 +00:00

Fix recharging items not being updated for actor's initial inventory

This commit is contained in:
scrawl 2014-10-05 18:27:26 +02:00
parent d790506525
commit 04614651fa
2 changed files with 10 additions and 4 deletions

View file

@ -68,6 +68,7 @@ MWWorld::InventoryStore::InventoryStore()
, mUpdatesEnabled (true) , mUpdatesEnabled (true)
, mFirstAutoEquip(true) , mFirstAutoEquip(true)
, mListener(NULL) , mListener(NULL)
, mRechargingItemsUpToDate(false)
{ {
initSlots (mSlots); initSlots (mSlots);
} }
@ -80,6 +81,7 @@ MWWorld::InventoryStore::InventoryStore (const InventoryStore& store)
, mListener(store.mListener) , mListener(store.mListener)
, mUpdatesEnabled(store.mUpdatesEnabled) , mUpdatesEnabled(store.mUpdatesEnabled)
, mPermanentMagicEffectMagnitudes(store.mPermanentMagicEffectMagnitudes) , mPermanentMagicEffectMagnitudes(store.mPermanentMagicEffectMagnitudes)
, mRechargingItemsUpToDate(false)
{ {
copySlots (store); copySlots (store);
} }
@ -90,6 +92,7 @@ MWWorld::InventoryStore& MWWorld::InventoryStore::operator= (const InventoryStor
mMagicEffects = store.mMagicEffects; mMagicEffects = store.mMagicEffects;
mFirstAutoEquip = store.mFirstAutoEquip; mFirstAutoEquip = store.mFirstAutoEquip;
mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes; mPermanentMagicEffectMagnitudes = store.mPermanentMagicEffectMagnitudes;
mRechargingItemsUpToDate = false;
ContainerStore::operator= (store); ContainerStore::operator= (store);
mSlots.clear(); mSlots.clear();
copySlots (store); copySlots (store);
@ -110,8 +113,6 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::add(const Ptr& itemPtr,
autoEquip(actorPtr); autoEquip(actorPtr);
} }
updateRechargingItems();
return retVal; return retVal;
} }
@ -485,8 +486,6 @@ int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor
mSelectedEnchantItem = end(); mSelectedEnchantItem = end();
} }
updateRechargingItems();
return retCount; return retCount;
} }
@ -606,6 +605,11 @@ void MWWorld::InventoryStore::updateRechargingItems()
void MWWorld::InventoryStore::rechargeItems(float duration) void MWWorld::InventoryStore::rechargeItems(float duration)
{ {
if (!mRechargingItemsUpToDate)
{
updateRechargingItems();
mRechargingItemsUpToDate = true;
}
for (TRechargingItems::iterator it = mRechargingItems.begin(); it != mRechargingItems.end(); ++it) for (TRechargingItems::iterator it = mRechargingItems.begin(); it != mRechargingItems.end(); ++it)
{ {
if (it->first->getCellRef().getEnchantmentCharge() == -1 if (it->first->getCellRef().getEnchantmentCharge() == -1

View file

@ -102,6 +102,8 @@ namespace MWWorld
typedef std::vector<std::pair<ContainerStoreIterator, float> > TRechargingItems; typedef std::vector<std::pair<ContainerStoreIterator, float> > TRechargingItems;
TRechargingItems mRechargingItems; TRechargingItems mRechargingItems;
bool mRechargingItemsUpToDate;
void copySlots (const InventoryStore& store); void copySlots (const InventoryStore& store);
void initSlots (TSlots& slots_); void initSlots (TSlots& slots_);