Add count argument to copyObjectToCell

Fixes the gold bug introduced in c9ca5bc946
openmw-38
scrawl 9 years ago
parent 41c8ec56e0
commit e5d9ee30f4

@ -175,7 +175,7 @@ namespace MWClass
return info;
}
MWWorld::Ptr Miscellaneous::copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const
MWWorld::Ptr Miscellaneous::copyToCell(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell, int count) const
{
MWWorld::Ptr newPtr;
@ -183,7 +183,7 @@ namespace MWClass
MWBase::Environment::get().getWorld()->getStore();
if (isGold(ptr)) {
int goldAmount = getValue(ptr) * ptr.getRefData().getCount();
int goldAmount = getValue(ptr) * count;
std::string base = "Gold_001";
if (goldAmount >= 100)
@ -208,7 +208,10 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
newPtr.getRefData().setCount(count);
}
newPtr.getCellRef().unsetRefNum();
return newPtr;
}

@ -7,10 +7,10 @@ namespace MWClass
{
class Miscellaneous : public MWWorld::Class
{
virtual MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const;
public:
virtual MWWorld::Ptr copyToCell(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell, int count) const;
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
///< Add reference into a cell for rendering

@ -244,7 +244,7 @@ namespace MWWorld
// on a save/load, so do a simple copy & delete for these objects.
if (!object.getCellRef().getRefNum().hasContentFile())
{
MWWorld::Ptr copied = object.getClass().copyToCell(object, *cellToMoveTo);
MWWorld::Ptr copied = object.getClass().copyToCell(object, *cellToMoveTo, object.getRefData().getCount());
object.getRefData().setCount(0);
object.getRefData().setBaseNode(NULL);
return copied;

@ -334,17 +334,18 @@ namespace MWWorld
}
MWWorld::Ptr
Class::copyToCell(const ConstPtr &ptr, CellStore &cell) const
Class::copyToCell(const ConstPtr &ptr, CellStore &cell, int count) const
{
Ptr newPtr = copyToCellImpl(ptr, cell);
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
newPtr.getRefData().setCount(count);
return newPtr;
}
MWWorld::Ptr
Class::copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos) const
Class::copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const
{
Ptr newPtr = copyToCell(ptr, cell);
Ptr newPtr = copyToCell(ptr, cell, count);
newPtr.getRefData().setPosition(pos);
return newPtr;

@ -280,9 +280,9 @@ namespace MWWorld
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
virtual int getBloodTexture (const MWWorld::ConstPtr& ptr) const;
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell) const;
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, int count) const;
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos) const;
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const;
virtual bool isActor() const {
return false;

@ -1321,7 +1321,7 @@ namespace MWWorld
MWWorld::Ptr World::safePlaceObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
{
return copyObjectToCell(ptr,cell,pos,false);
return copyObjectToCell(ptr,cell,pos,ptr.getRefData().getCount(),false);
}
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
@ -1817,8 +1817,7 @@ namespace MWWorld
pos.rot[1] = 0;
// copy the object and set its count
Ptr dropped = copyObjectToCell(object, cell, pos, true);
dropped.getRefData().setCount(amount);
Ptr dropped = copyObjectToCell(object, cell, pos, amount, true);
// only the player place items in the world, so no need to check actor
PCDropped(dropped);
@ -1844,7 +1843,7 @@ namespace MWWorld
}
Ptr World::copyObjectToCell(const ConstPtr &object, CellStore* cell, ESM::Position pos, bool adjustPos)
Ptr World::copyObjectToCell(const ConstPtr &object, CellStore* cell, ESM::Position pos, int count, bool adjustPos)
{
if (cell->isExterior())
{
@ -1854,7 +1853,7 @@ namespace MWWorld
}
MWWorld::Ptr dropped =
object.getClass().copyToCell(object, *cell, pos);
object.getClass().copyToCell(object, *cell, pos, count);
// Reset some position values that could be uninitialized if this item came from a container
dropped.getCellRef().setPosition(pos);
@ -1918,8 +1917,7 @@ namespace MWWorld
pos.pos[2] = result.mHitPointWorld.z();
// copy the object and set its count
Ptr dropped = copyObjectToCell(object, cell, pos);
dropped.getRefData().setCount(amount);
Ptr dropped = copyObjectToCell(object, cell, pos, amount, true);
if(actor == mPlayer->getPlayer()) // Only call if dropped by player
PCDropped(dropped);

@ -123,7 +123,7 @@ namespace MWWorld
Ptr moveObjectImp (const Ptr& ptr, float x, float y, float z);
///< @return an updated Ptr in case the Ptr's cell changes
Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, bool adjustPos=true);
Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos);
void updateSoundListener();
void updateWindowManager ();

Loading…
Cancel
Save