Accept a ConstPtr in placeObject

This commit is contained in:
scrawl 2015-12-18 17:42:59 +01:00
parent 6c505ca06f
commit c9ca5bc946
3 changed files with 13 additions and 17 deletions

View file

@ -271,7 +271,7 @@ namespace MWBase
virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0; virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
virtual MWWorld::Ptr safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos) = 0; virtual MWWorld::Ptr safePlaceObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) = 0;
///< place an object in a "safe" location (ie not in the void, etc). ///< place an object in a "safe" location (ie not in the void, etc).
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
@ -347,14 +347,14 @@ namespace MWBase
virtual void update (float duration, bool paused) = 0; virtual void update (float duration, bool paused) = 0;
virtual MWWorld::Ptr placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0; virtual MWWorld::Ptr placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount) = 0;
///< copy and place an object into the gameworld at the specified cursor position ///< copy and place an object into the gameworld at the specified cursor position
/// @param object /// @param object
/// @param cursor X (relative 0-1) /// @param cursor X (relative 0-1)
/// @param cursor Y (relative 0-1) /// @param cursor Y (relative 0-1)
/// @param number of objects to place /// @param number of objects to place
virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0; virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::ConstPtr& object, int amount) = 0;
///< copy and place an object into the gameworld at the given actor's position ///< copy and place an object into the gameworld at the given actor's position
/// @param actor giving the dropped object position /// @param actor giving the dropped object position
/// @param object /// @param object

View file

@ -1319,7 +1319,7 @@ namespace MWWorld
rotateObjectImp(ptr, osg::Vec3f(x, y, z), adjust); rotateObjectImp(ptr, osg::Vec3f(x, y, z), adjust);
} }
MWWorld::Ptr World::safePlaceObject(const MWWorld::Ptr& 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,false);
} }
@ -1797,7 +1797,7 @@ namespace MWWorld
item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1); item.getRefData().getLocals().setVarByInt(script, "onpcdrop", 1);
} }
MWWorld::Ptr World::placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) MWWorld::Ptr World::placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount)
{ {
const float maxDist = 200.f; const float maxDist = 200.f;
@ -1817,10 +1817,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
int origCount = object.getRefData().getCount();
object.getRefData().setCount(amount);
Ptr dropped = copyObjectToCell(object, cell, pos, true); Ptr dropped = copyObjectToCell(object, cell, pos, true);
object.getRefData().setCount(origCount); 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);
@ -1846,7 +1844,7 @@ namespace MWWorld
} }
Ptr World::copyObjectToCell(const Ptr &object, CellStore* cell, ESM::Position pos, bool adjustPos) Ptr World::copyObjectToCell(const ConstPtr &object, CellStore* cell, ESM::Position pos, bool adjustPos)
{ {
if (cell->isExterior()) if (cell->isExterior())
{ {
@ -1899,7 +1897,7 @@ namespace MWWorld
return dropped; return dropped;
} }
MWWorld::Ptr World::dropObjectOnGround (const Ptr& actor, const Ptr& object, int amount) MWWorld::Ptr World::dropObjectOnGround (const Ptr& actor, const ConstPtr& object, int amount)
{ {
MWWorld::CellStore* cell = actor.getCell(); MWWorld::CellStore* cell = actor.getCell();
@ -1920,10 +1918,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
int origCount = object.getRefData().getCount();
object.getRefData().setCount(amount);
Ptr dropped = copyObjectToCell(object, cell, pos); Ptr dropped = copyObjectToCell(object, cell, pos);
object.getRefData().setCount(origCount); 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);

View file

@ -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 Ptr &ptr, CellStore* cell, ESM::Position pos, bool adjustPos=true); Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, bool adjustPos=true);
void updateSoundListener(); void updateSoundListener();
void updateWindowManager (); void updateWindowManager ();
@ -365,7 +365,7 @@ namespace MWWorld
/// \param adjust indicates rotation should be set or adjusted /// \param adjust indicates rotation should be set or adjusted
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false); virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
virtual MWWorld::Ptr safePlaceObject(const MWWorld::Ptr& ptr, MWWorld::CellStore* cell, ESM::Position pos); virtual MWWorld::Ptr safePlaceObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos);
///< place an object in a "safe" location (ie not in the void, etc). Makes a copy of the Ptr. ///< place an object in a "safe" location (ie not in the void, etc). Makes a copy of the Ptr.
virtual float getMaxActivationDistance(); virtual float getMaxActivationDistance();
@ -443,14 +443,14 @@ namespace MWWorld
virtual void update (float duration, bool paused); virtual void update (float duration, bool paused);
virtual MWWorld::Ptr placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount); virtual MWWorld::Ptr placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount);
///< copy and place an object into the gameworld at the specified cursor position ///< copy and place an object into the gameworld at the specified cursor position
/// @param object /// @param object
/// @param cursor X (relative 0-1) /// @param cursor X (relative 0-1)
/// @param cursor Y (relative 0-1) /// @param cursor Y (relative 0-1)
/// @param number of objects to place /// @param number of objects to place
virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount); virtual MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::ConstPtr& object, int amount);
///< copy and place an object into the gameworld at the given actor's position ///< copy and place an object into the gameworld at the given actor's position
/// @param actor giving the dropped object position /// @param actor giving the dropped object position
/// @param object /// @param object