mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 12:42:11 +00:00
Remove ItemModel::copyItem(), it is obsolete.
This commit is contained in:
parent
8c3c5238d7
commit
6e03d710ba
@ -33,14 +33,6 @@ namespace MWGui
|
||||
return InventoryItemModel::addItem(item, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
MWWorld::Ptr CompanionItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
{
|
||||
if (hasProfit(mActor))
|
||||
modifyProfit(mActor, item.mBase.getClass().getValue(item.mBase) * count);
|
||||
|
||||
return InventoryItemModel::copyItem(item, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
void CompanionItemModel::removeItem(const ItemStack& item, size_t count)
|
||||
{
|
||||
if (hasProfit(mActor))
|
||||
|
@ -14,7 +14,6 @@ namespace MWGui
|
||||
CompanionItemModel(const MWWorld::Ptr& actor);
|
||||
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
void removeItem(const ItemStack& item, size_t count) override;
|
||||
|
||||
bool hasProfit(const MWWorld::Ptr& actor);
|
||||
|
@ -99,12 +99,12 @@ namespace MWGui
|
||||
return -1;
|
||||
}
|
||||
|
||||
MWWorld::Ptr ContainerItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
MWWorld::Ptr ContainerItemModel::addItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
{
|
||||
auto& source = mItemSources[0];
|
||||
MWWorld::ContainerStore& store = source.first.getClass().getContainerStore(source.first);
|
||||
if (item.mBase.getContainerStore() == &store)
|
||||
throw std::runtime_error("Item to copy needs to be from a different container!");
|
||||
throw std::runtime_error("Item needs to be from a different container!");
|
||||
return *store.add(item.mBase, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ namespace MWGui
|
||||
ModelIndex getIndex(const ItemStack& item) override;
|
||||
size_t getItemCount() override;
|
||||
|
||||
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
void removeItem(const ItemStack& item, size_t count) override;
|
||||
|
||||
void update() override;
|
||||
|
@ -46,30 +46,20 @@ namespace MWGui
|
||||
}
|
||||
virtual ~WorldItemModel() override {}
|
||||
|
||||
MWWorld::Ptr dropItemImpl(const ItemStack& item, size_t count, bool copy)
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override
|
||||
{
|
||||
MWBase::World* world = MWBase::Environment::get().getWorld();
|
||||
|
||||
MWWorld::Ptr dropped;
|
||||
if (world->canPlaceObject(mLeft, mTop))
|
||||
dropped = world->placeObject(item.mBase, mLeft, mTop, count, copy);
|
||||
dropped = world->placeObject(item.mBase, mLeft, mTop, count, false);
|
||||
else
|
||||
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count, copy);
|
||||
dropped = world->dropObjectOnGround(world->getPlayerPtr(), item.mBase, count, false);
|
||||
dropped.getCellRef().setOwner(ESM::RefId());
|
||||
|
||||
return dropped;
|
||||
}
|
||||
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override
|
||||
{
|
||||
return dropItemImpl(item, count, false);
|
||||
}
|
||||
|
||||
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool /*allowAutoEquip*/) override
|
||||
{
|
||||
return dropItemImpl(item, count, true);
|
||||
}
|
||||
|
||||
void removeItem(const ItemStack& item, size_t count) override
|
||||
{
|
||||
throw std::runtime_error("removeItem not implemented");
|
||||
|
@ -53,13 +53,6 @@ namespace MWGui
|
||||
return *mActor.getClass().getContainerStore(mActor).add(item.mBase, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
MWWorld::Ptr InventoryItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
{
|
||||
// TODO: This does not copy the item, but adds it directly. This will duplicate the item's
|
||||
// refnum and other ref data unless the caller handles that.
|
||||
return addItem(item, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
MWWorld::Ptr InventoryItemModel::unstackItem(const ItemStack& item, size_t count)
|
||||
{
|
||||
MWWorld::ContainerStore& store = mActor.getClass().getContainerStore(mActor);
|
||||
@ -99,16 +92,14 @@ namespace MWGui
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack& item, size_t count, ItemModel* otherModel)
|
||||
MWWorld::Ptr InventoryItemModel::moveItem(const ItemStack& item, size_t count, ItemModel* otherModel, bool allowAutoEquip)
|
||||
{
|
||||
// Can't move conjured items: This is a general fix that also takes care of issues with taking conjured items
|
||||
// via the 'Take All' button.
|
||||
if (item.mFlags & ItemStack::Flag_Bound)
|
||||
return MWWorld::Ptr();
|
||||
|
||||
MWWorld::Ptr ret = otherModel->copyItem(item, count);
|
||||
removeItem(item, count);
|
||||
return ret;
|
||||
return ItemModel::moveItem(item, count, otherModel, allowAutoEquip);
|
||||
}
|
||||
|
||||
void InventoryItemModel::update()
|
||||
|
@ -18,12 +18,11 @@ namespace MWGui
|
||||
bool onTakeItem(const MWWorld::Ptr& item, int count) override;
|
||||
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
MWWorld::Ptr unstackItem(const ItemStack& item, size_t count) override;
|
||||
void removeItem(const ItemStack& item, size_t count) override;
|
||||
|
||||
/// Move items from this model to \a otherModel.
|
||||
MWWorld::Ptr moveItem(const ItemStack& item, size_t count, ItemModel* otherModel) override;
|
||||
MWWorld::Ptr moveItem(const ItemStack& item, size_t count, ItemModel* otherModel, bool allowAutoEquip = true) override;
|
||||
|
||||
void update() override;
|
||||
|
||||
|
@ -55,9 +55,9 @@ namespace MWGui
|
||||
|
||||
ItemModel::ItemModel() {}
|
||||
|
||||
MWWorld::Ptr ItemModel::moveItem(const ItemStack& item, size_t count, ItemModel* otherModel)
|
||||
MWWorld::Ptr ItemModel::moveItem(const ItemStack& item, size_t count, ItemModel* otherModel, bool allowAutoEquip)
|
||||
{
|
||||
MWWorld::Ptr ret = otherModel->addItem(item, count);
|
||||
MWWorld::Ptr ret = otherModel->addItem(item, count, allowAutoEquip);
|
||||
// Unstacking here ensures that new a refnum is assigned to the leftover stack if there is a leftover.
|
||||
// Otherwise we end up with duplicated instances.
|
||||
unstackItem(item, count);
|
||||
@ -65,11 +65,6 @@ namespace MWGui
|
||||
return ret;
|
||||
}
|
||||
|
||||
MWWorld::Ptr ItemModel::addItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
{
|
||||
return copyItem(item, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
MWWorld::Ptr ItemModel::unstackItem(const ItemStack& item, size_t count)
|
||||
{
|
||||
// By default does nothing
|
||||
@ -96,11 +91,6 @@ namespace MWGui
|
||||
return mSourceModel->allowedToUseItems();
|
||||
}
|
||||
|
||||
MWWorld::Ptr ProxyItemModel::copyItem(const ItemStack& item, size_t count, bool allowAutoEquip)
|
||||
{
|
||||
return mSourceModel->copyItem(item, count, allowAutoEquip);
|
||||
}
|
||||
|
||||
void ProxyItemModel::removeItem(const ItemStack& item, size_t count)
|
||||
{
|
||||
mSourceModel->removeItem(item, count);
|
||||
|
@ -63,14 +63,13 @@ namespace MWGui
|
||||
|
||||
/// Move items from this model to \a otherModel.
|
||||
/// @note Derived implementations may return an empty Ptr if the move was unsuccessful.
|
||||
virtual MWWorld::Ptr moveItem(const ItemStack& item, size_t count, ItemModel* otherModel);
|
||||
virtual MWWorld::Ptr moveItem(const ItemStack& item, size_t count, ItemModel* otherModel, bool allowAutoEquip = true);
|
||||
|
||||
/// Unstacks items from this model and returns a ptr to the new remainder stack.
|
||||
/// @note Returns en empty ptr if there is no remainder or the item model does not support unstacking.
|
||||
virtual MWWorld::Ptr unstackItem(const ItemStack& item, size_t count);
|
||||
|
||||
virtual MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true);
|
||||
virtual MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) = 0;
|
||||
virtual MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) = 0;
|
||||
virtual void removeItem(const ItemStack& item, size_t count) = 0;
|
||||
|
||||
/// Is the player allowed to use items from this item model? (default true)
|
||||
@ -102,7 +101,6 @@ namespace MWGui
|
||||
|
||||
MWWorld::Ptr unstackItem(const ItemStack& item, size_t count) override;
|
||||
MWWorld::Ptr addItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
MWWorld::Ptr copyItem(const ItemStack& item, size_t count, bool allowAutoEquip = true) override;
|
||||
void removeItem(const ItemStack& item, size_t count) override;
|
||||
ModelIndex getIndex(const ItemStack& item) override;
|
||||
|
||||
|
@ -139,11 +139,8 @@ namespace MWGui
|
||||
if (i == sourceModel->getItemCount())
|
||||
throw std::runtime_error("The borrowed item disappeared");
|
||||
|
||||
const ItemStack& item = sourceModel->getItem(i);
|
||||
// copy the borrowed items to our model
|
||||
copyItem(item, itemStack.mCount, !Settings::game().mPreventMerchantEquipping);
|
||||
// then remove them from the source model
|
||||
sourceModel->removeItem(item, itemStack.mCount);
|
||||
sourceModel->moveItem(
|
||||
sourceModel->getItem(i), itemStack.mCount, this, !Settings::game().mPreventMerchantEquipping);
|
||||
}
|
||||
mBorrowedToUs.clear();
|
||||
mBorrowedFromUs.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user