mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 09:39:43 +00:00
Unset RefNums after copying containers (otherwise copies will have the same RefNums, but they should be unique)
This commit is contained in:
parent
5983f22290
commit
e7120f189b
3 changed files with 22 additions and 2 deletions
|
@ -192,6 +192,12 @@ int MWWorld::ContainerStore::count(const ESM::RefId& id) const
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MWWorld::ContainerStore::clearRefNums()
|
||||||
|
{
|
||||||
|
for (const auto& iter : *this)
|
||||||
|
iter.getCellRef().unsetRefNum();
|
||||||
|
}
|
||||||
|
|
||||||
MWWorld::ContainerStoreListener* MWWorld::ContainerStore::getContListener() const
|
MWWorld::ContainerStoreListener* MWWorld::ContainerStore::getContListener() const
|
||||||
{
|
{
|
||||||
return mListener;
|
return mListener;
|
||||||
|
|
|
@ -102,6 +102,10 @@ namespace MWWorld
|
||||||
protected:
|
protected:
|
||||||
ContainerStoreListener* mListener;
|
ContainerStoreListener* mListener;
|
||||||
|
|
||||||
|
// Used in clone() to unset refnums of copies.
|
||||||
|
// (RefNum should be unique, copy can not have the same RefNum).
|
||||||
|
void clearRefNums();
|
||||||
|
|
||||||
// (item, max charge)
|
// (item, max charge)
|
||||||
typedef std::vector<std::pair<ContainerStoreIterator, float>> TRechargingItems;
|
typedef std::vector<std::pair<ContainerStoreIterator, float>> TRechargingItems;
|
||||||
TRechargingItems mRechargingItems;
|
TRechargingItems mRechargingItems;
|
||||||
|
@ -165,7 +169,12 @@ namespace MWWorld
|
||||||
|
|
||||||
virtual ~ContainerStore();
|
virtual ~ContainerStore();
|
||||||
|
|
||||||
virtual std::unique_ptr<ContainerStore> clone() { return std::make_unique<ContainerStore>(*this); }
|
virtual std::unique_ptr<ContainerStore> clone()
|
||||||
|
{
|
||||||
|
auto res = std::make_unique<ContainerStore>(*this);
|
||||||
|
res->clearRefNums();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
ConstContainerStoreIterator cbegin(int mask = Type_All) const;
|
ConstContainerStoreIterator cbegin(int mask = Type_All) const;
|
||||||
ConstContainerStoreIterator cend() const;
|
ConstContainerStoreIterator cend() const;
|
||||||
|
|
|
@ -97,7 +97,12 @@ namespace MWWorld
|
||||||
const MWWorld::Ptr& getActor() const { return mActor; }
|
const MWWorld::Ptr& getActor() const { return mActor; }
|
||||||
void setActor(const MWWorld::Ptr& actor) { mActor = actor; }
|
void setActor(const MWWorld::Ptr& actor) { mActor = actor; }
|
||||||
|
|
||||||
std::unique_ptr<ContainerStore> clone() override { return std::make_unique<InventoryStore>(*this); }
|
std::unique_ptr<ContainerStore> clone() override
|
||||||
|
{
|
||||||
|
auto res = std::make_unique<InventoryStore>(*this);
|
||||||
|
res->clearRefNums();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
ContainerStoreIterator add(
|
ContainerStoreIterator add(
|
||||||
const Ptr& itemPtr, int count, bool allowAutoEquip = true, bool resolve = true) override;
|
const Ptr& itemPtr, int count, bool allowAutoEquip = true, bool resolve = true) override;
|
||||||
|
|
Loading…
Reference in a new issue