mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 21:19:55 +00:00
Add count argument to copyObjectToCell
Fixes the gold bug introduced in c9ca5bc946
This commit is contained in:
parent
41c8ec56e0
commit
e5d9ee30f4
7 changed files with 20 additions and 18 deletions
|
@ -175,7 +175,7 @@ namespace MWClass
|
||||||
return info;
|
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;
|
MWWorld::Ptr newPtr;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ namespace MWClass
|
||||||
MWBase::Environment::get().getWorld()->getStore();
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
if (isGold(ptr)) {
|
if (isGold(ptr)) {
|
||||||
int goldAmount = getValue(ptr) * ptr.getRefData().getCount();
|
int goldAmount = getValue(ptr) * count;
|
||||||
|
|
||||||
std::string base = "Gold_001";
|
std::string base = "Gold_001";
|
||||||
if (goldAmount >= 100)
|
if (goldAmount >= 100)
|
||||||
|
@ -208,7 +208,10 @@ namespace MWClass
|
||||||
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
const MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
|
||||||
ptr.get<ESM::Miscellaneous>();
|
ptr.get<ESM::Miscellaneous>();
|
||||||
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
|
newPtr = MWWorld::Ptr(cell.insert(ref), &cell);
|
||||||
|
newPtr.getRefData().setCount(count);
|
||||||
}
|
}
|
||||||
|
newPtr.getCellRef().unsetRefNum();
|
||||||
|
|
||||||
return newPtr;
|
return newPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ namespace MWClass
|
||||||
{
|
{
|
||||||
class Miscellaneous : public MWWorld::Class
|
class Miscellaneous : public MWWorld::Class
|
||||||
{
|
{
|
||||||
virtual MWWorld::Ptr copyToCellImpl(const MWWorld::ConstPtr &ptr, MWWorld::CellStore &cell) const;
|
|
||||||
|
|
||||||
public:
|
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;
|
virtual void insertObjectRendering (const MWWorld::Ptr& ptr, const std::string& model, MWRender::RenderingInterface& renderingInterface) const;
|
||||||
///< Add reference into a cell for rendering
|
///< 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.
|
// on a save/load, so do a simple copy & delete for these objects.
|
||||||
if (!object.getCellRef().getRefNum().hasContentFile())
|
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().setCount(0);
|
||||||
object.getRefData().setBaseNode(NULL);
|
object.getRefData().setBaseNode(NULL);
|
||||||
return copied;
|
return copied;
|
||||||
|
|
|
@ -334,17 +334,18 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr
|
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);
|
Ptr newPtr = copyToCellImpl(ptr, cell);
|
||||||
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
|
newPtr.getCellRef().unsetRefNum(); // This RefNum is only valid within the original cell of the reference
|
||||||
|
newPtr.getRefData().setCount(count);
|
||||||
return newPtr;
|
return newPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr
|
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);
|
newPtr.getRefData().setPosition(pos);
|
||||||
|
|
||||||
return newPtr;
|
return newPtr;
|
||||||
|
|
|
@ -280,9 +280,9 @@ namespace MWWorld
|
||||||
/// Get a blood texture suitable for \a ptr (see Blood Texture 0-2 in Morrowind.ini)
|
/// 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 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 {
|
virtual bool isActor() const {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1321,7 +1321,7 @@ namespace MWWorld
|
||||||
|
|
||||||
MWWorld::Ptr World::safePlaceObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos)
|
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
|
void World::indexToPosition (int cellX, int cellY, float &x, float &y, bool centre) const
|
||||||
|
@ -1817,8 +1817,7 @@ 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 = copyObjectToCell(object, cell, pos, true);
|
Ptr dropped = copyObjectToCell(object, cell, pos, amount, true);
|
||||||
dropped.getRefData().setCount(amount);
|
|
||||||
|
|
||||||
// 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);
|
||||||
|
@ -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())
|
if (cell->isExterior())
|
||||||
{
|
{
|
||||||
|
@ -1854,7 +1853,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
MWWorld::Ptr dropped =
|
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
|
// Reset some position values that could be uninitialized if this item came from a container
|
||||||
dropped.getCellRef().setPosition(pos);
|
dropped.getCellRef().setPosition(pos);
|
||||||
|
@ -1918,8 +1917,7 @@ 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 = copyObjectToCell(object, cell, pos);
|
Ptr dropped = copyObjectToCell(object, cell, pos, amount, true);
|
||||||
dropped.getRefData().setCount(amount);
|
|
||||||
|
|
||||||
if(actor == mPlayer->getPlayer()) // Only call if dropped by player
|
if(actor == mPlayer->getPlayer()) // Only call if dropped by player
|
||||||
PCDropped(dropped);
|
PCDropped(dropped);
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace MWWorld
|
||||||
Ptr moveObjectImp (const Ptr& ptr, float x, float y, float z);
|
Ptr moveObjectImp (const Ptr& ptr, float x, float y, float z);
|
||||||
///< @return an updated Ptr in case the Ptr's cell changes
|
///< @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 updateSoundListener();
|
||||||
void updateWindowManager ();
|
void updateWindowManager ();
|
||||||
|
|
Loading…
Reference in a new issue