Do not redundantly take and set count in moveToCell(). moveToCell() should always be moving the full stack.

This commit is contained in:
Mads Buvik Sandvei 2023-07-25 14:18:29 +02:00
parent 8867e76fd7
commit 1162323e96
5 changed files with 9 additions and 11 deletions

View file

@ -219,7 +219,6 @@ namespace MWClass
newPtr = createGold(cell, getValue(ptr) * ptr.getRefData().getCount()); newPtr = createGold(cell, getValue(ptr) * ptr.getRefData().getCount());
newPtr.getRefData() = ptr.getRefData(); newPtr.getRefData() = ptr.getRefData();
newPtr.getCellRef().setRefNum(ptr.getCellRef().getRefNum()); newPtr.getCellRef().setRefNum(ptr.getCellRef().getRefNum());
newPtr.getCellRef().setGoldValue(ptr.getCellRef().getGoldValue());
newPtr.getRefData().setCount(1); newPtr.getRefData().setCount(1);
} }
else else

View file

@ -391,12 +391,11 @@ namespace MWWorld
return newPtr; return newPtr;
} }
Ptr Class::moveToCell(const Ptr& ptr, CellStore& cell, const ESM::Position& pos, int count) const Ptr Class::moveToCell(const Ptr& ptr, CellStore& cell, const ESM::Position& pos) const
{ {
Ptr newPtr = moveToCell(ptr, cell); Ptr newPtr = moveToCell(ptr, cell);
newPtr.getRefData().setPosition(pos); newPtr.getRefData().setPosition(pos);
newPtr.getCellRef().setPosition(pos); newPtr.getCellRef().setPosition(pos);
newPtr.getRefData().setCount(count);
return newPtr; return newPtr;
} }

View file

@ -317,7 +317,7 @@ namespace MWWorld
// The original is expected to be removed after calling this function, // The original is expected to be removed after calling this function,
// but this function itself doesn't remove the original. // but this function itself doesn't remove the original.
virtual Ptr moveToCell(const Ptr& ptr, CellStore& cell) const; virtual Ptr moveToCell(const Ptr& ptr, CellStore& cell) const;
Ptr moveToCell(const Ptr& ptr, CellStore& cell, const ESM::Position& pos, int count) const; Ptr moveToCell(const Ptr& ptr, CellStore& cell, const ESM::Position& pos) const;
Ptr copyToCell(const ConstPtr& ptr, CellStore& cell, const ESM::Position& pos, int count) const; Ptr copyToCell(const ConstPtr& ptr, CellStore& cell, const ESM::Position& pos, int count) const;

View file

@ -2024,8 +2024,8 @@ namespace MWWorld
pos.rot[1] = 0; pos.rot[1] = 0;
// copy the object and set its count // copy the object and set its count
Ptr dropped = copy ? copyObjectToCell(object, cell, pos, amount, true) Ptr dropped
: moveObjectToCell(object, cell, pos, amount, true); = copy ? copyObjectToCell(object, cell, pos, amount, true) : moveObjectToCell(object, cell, pos, true);
// only the player place items in the world, so no need to check actor // only the player place items in the world, so no need to check actor
PCDropped(dropped); PCDropped(dropped);
@ -2070,7 +2070,7 @@ namespace MWWorld
return dropped; return dropped;
} }
Ptr World::moveObjectToCell(const Ptr& object, CellStore* cell, ESM::Position pos, int count, bool adjustPos) Ptr World::moveObjectToCell(const Ptr& object, CellStore* cell, ESM::Position pos, bool adjustPos)
{ {
if (!cell) if (!cell)
throw std::runtime_error("moveObjectToCell(): cannot move object to null cell"); throw std::runtime_error("moveObjectToCell(): cannot move object to null cell");
@ -2081,7 +2081,7 @@ namespace MWWorld
cell = &mWorldModel.getExterior(index); cell = &mWorldModel.getExterior(index);
} }
MWWorld::Ptr dropped = object.getClass().moveToCell(object, *cell, pos, count); MWWorld::Ptr dropped = object.getClass().moveToCell(object, *cell, pos);
initObjectInCell(dropped, *cell, adjustPos); initObjectInCell(dropped, *cell, adjustPos);
@ -2146,8 +2146,8 @@ namespace MWWorld
pos.pos[2] = result.mHitPointWorld.z(); pos.pos[2] = result.mHitPointWorld.z();
// copy the object and set its count // copy the object and set its count
Ptr dropped = copy ? copyObjectToCell(object, cell, pos, amount, true) Ptr dropped
: moveObjectToCell(object, cell, pos, amount, true); = copy ? copyObjectToCell(object, cell, pos, amount, true) : moveObjectToCell(object, cell, pos, true);
if (actor == mPlayer->getPlayer()) // Only call if dropped by player if (actor == mPlayer->getPlayer()) // Only call if dropped by player
PCDropped(dropped); PCDropped(dropped);

View file

@ -144,7 +144,7 @@ namespace MWWorld
void updateWeather(float duration, bool paused = false); void updateWeather(float duration, bool paused = false);
void initObjectInCell(const Ptr& ptr, CellStore& cell, bool adjustPos); void initObjectInCell(const Ptr& ptr, CellStore& cell, bool adjustPos);
Ptr moveObjectToCell(const Ptr& ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos); Ptr moveObjectToCell(const Ptr& ptr, CellStore* cell, ESM::Position pos, bool adjustPos);
Ptr copyObjectToCell(const ConstPtr& ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos); Ptr copyObjectToCell(const ConstPtr& ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos);
void updateSoundListener(); void updateSoundListener();