mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-19 22:53:53 +00:00
Fix remove item regression
This commit is contained in:
parent
3ccb424faf
commit
0512a574e8
5 changed files with 12 additions and 45 deletions
|
@ -246,7 +246,7 @@ namespace MWScript
|
||||||
auto& store = container.getClass().getContainerStore(container);
|
auto& store = container.getClass().getContainerStore(container);
|
||||||
// Note that unlike AddItem, RemoveItem only removes from unresolved containers
|
// Note that unlike AddItem, RemoveItem only removes from unresolved containers
|
||||||
if(!store.isResolved())
|
if(!store.isResolved())
|
||||||
store.remove(item, count, ptr, false);
|
store.remove(item, count, ptr, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -463,7 +463,7 @@ void MWWorld::ContainerStore::updateRechargingItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const Ptr& actor, bool resolveFirst)
|
int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement, bool resolveFirst)
|
||||||
{
|
{
|
||||||
if(resolveFirst)
|
if(resolveFirst)
|
||||||
resolve();
|
resolve();
|
||||||
|
@ -471,7 +471,7 @@ int MWWorld::ContainerStore::remove(const std::string& itemId, int count, const
|
||||||
|
|
||||||
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
||||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
||||||
toRemove -= removeImp(*iter, toRemove, actor);
|
toRemove -= remove(*iter, toRemove, actor, equipReplacement, resolveFirst);
|
||||||
|
|
||||||
flagAsModified();
|
flagAsModified();
|
||||||
|
|
||||||
|
@ -490,16 +490,12 @@ bool MWWorld::ContainerStore::hasVisibleItems() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor)
|
int MWWorld::ContainerStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement, bool resolveFirst)
|
||||||
{
|
{
|
||||||
assert(this == item.getContainerStore());
|
assert(this == item.getContainerStore());
|
||||||
resolve();
|
if(resolveFirst)
|
||||||
|
resolve();
|
||||||
|
|
||||||
return removeImp(item, count, actor);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWWorld::ContainerStore::removeImp(const Ptr& item, int count, const Ptr& actor)
|
|
||||||
{
|
|
||||||
int toRemove = count;
|
int toRemove = count;
|
||||||
RefData& itemRef = item.getRefData();
|
RefData& itemRef = item.getRefData();
|
||||||
|
|
||||||
|
|
|
@ -129,8 +129,6 @@ namespace MWWorld
|
||||||
void addInitialItem (const std::string& id, const std::string& owner, int count, Misc::Rng::Seed* seed, bool topLevel=true);
|
void addInitialItem (const std::string& id, const std::string& owner, int count, Misc::Rng::Seed* seed, bool topLevel=true);
|
||||||
void addInitialItemImp (const MWWorld::Ptr& ptr, const std::string& owner, int count, Misc::Rng::Seed* seed, bool topLevel=true);
|
void addInitialItemImp (const MWWorld::Ptr& ptr, const std::string& owner, int count, Misc::Rng::Seed* seed, bool topLevel=true);
|
||||||
|
|
||||||
int removeImp(const Ptr& item, int count, const Ptr& actor);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ContainerStoreIterator getState (CellRefList<T>& collection,
|
ContainerStoreIterator getState (CellRefList<T>& collection,
|
||||||
const ESM::ObjectState& state);
|
const ESM::ObjectState& state);
|
||||||
|
@ -180,12 +178,12 @@ namespace MWWorld
|
||||||
ContainerStoreIterator add(const std::string& id, int count, const Ptr& actorPtr);
|
ContainerStoreIterator add(const std::string& id, int count, const Ptr& actorPtr);
|
||||||
///< Utility to construct a ManualRef and call add(ptr, count, actorPtr, true)
|
///< Utility to construct a ManualRef and call add(ptr, count, actorPtr, true)
|
||||||
|
|
||||||
int remove(const std::string& itemId, int count, const Ptr& actor, bool resolve = true);
|
int remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement = 0, bool resolve = true);
|
||||||
///< Remove \a count item(s) designated by \a itemId from this container.
|
///< Remove \a count item(s) designated by \a itemId from this container.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor);
|
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement = 0, bool resolve = true);
|
||||||
///< Remove \a count item(s) designated by \a item from this inventory.
|
///< Remove \a count item(s) designated by \a item from this inventory.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
|
@ -710,33 +710,9 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::getSelectedEnchantItem(
|
||||||
return mSelectedEnchantItem;
|
return mSelectedEnchantItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor)
|
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement, bool resolve)
|
||||||
{
|
{
|
||||||
return remove(itemId, count, actor, false);
|
int retCount = ContainerStore::remove(item, count, actor, equipReplacement, resolve);
|
||||||
}
|
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor)
|
|
||||||
{
|
|
||||||
return remove(item, count, actor, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement)
|
|
||||||
{
|
|
||||||
int toRemove = count;
|
|
||||||
|
|
||||||
for (ContainerStoreIterator iter(begin()); iter != end() && toRemove > 0; ++iter)
|
|
||||||
if (Misc::StringUtils::ciEqual(iter->getCellRef().getRefId(), itemId))
|
|
||||||
toRemove -= remove(*iter, toRemove, actor, equipReplacement);
|
|
||||||
|
|
||||||
flagAsModified();
|
|
||||||
|
|
||||||
// number of removed items
|
|
||||||
return count - toRemove;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWWorld::InventoryStore::remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement)
|
|
||||||
{
|
|
||||||
int retCount = ContainerStore::remove(item, count, actor);
|
|
||||||
|
|
||||||
bool wasEquipped = false;
|
bool wasEquipped = false;
|
||||||
if (!item.getRefData().getCount())
|
if (!item.getRefData().getCount())
|
||||||
|
|
|
@ -165,11 +165,8 @@ namespace MWWorld
|
||||||
bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const override;
|
bool stacks (const ConstPtr& ptr1, const ConstPtr& ptr2) const override;
|
||||||
///< @return true if the two specified objects can stack with each other
|
///< @return true if the two specified objects can stack with each other
|
||||||
|
|
||||||
virtual int remove(const std::string& itemId, int count, const Ptr& actor);
|
using ContainerStore::remove;
|
||||||
virtual int remove(const std::string& itemId, int count, const Ptr& actor, bool equipReplacement);
|
int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement = 0, bool resolve = true) override;
|
||||||
|
|
||||||
int remove(const Ptr& item, int count, const Ptr& actor) override;
|
|
||||||
virtual int remove(const Ptr& item, int count, const Ptr& actor, bool equipReplacement);
|
|
||||||
///< Remove \a count item(s) designated by \a item from this inventory.
|
///< Remove \a count item(s) designated by \a item from this inventory.
|
||||||
///
|
///
|
||||||
/// @return the number of items actually removed
|
/// @return the number of items actually removed
|
||||||
|
|
Loading…
Reference in a new issue