Pass parameters by const reference

0.6.1
Allofich 8 years ago
parent 2e5fd74db0
commit ff3e307059

@ -78,7 +78,7 @@ class CheckActorCommanded : public MWMechanics::EffectSourceVisitor
MWWorld::Ptr mActor; MWWorld::Ptr mActor;
public: public:
bool mCommanded; bool mCommanded;
CheckActorCommanded(MWWorld::Ptr actor) CheckActorCommanded(const MWWorld::Ptr& actor)
: mActor(actor) : mActor(actor)
, mCommanded(false){} , mCommanded(false){}
@ -149,7 +149,7 @@ namespace MWMechanics
MWWorld::Ptr mActor; MWWorld::Ptr mActor;
bool mTrapped; bool mTrapped;
public: public:
SoulTrap(MWWorld::Ptr trappedCreature) SoulTrap(const MWWorld::Ptr& trappedCreature)
: mCreature(trappedCreature) : mCreature(trappedCreature)
, mTrapped(false) , mTrapped(false)
{ {

@ -893,7 +893,7 @@ namespace MWMechanics
storage.mAllowedNodes.push_back(PathFinder::MakePathgridPoint(vectorStart + delta)); storage.mAllowedNodes.push_back(PathFinder::MakePathgridPoint(vectorStart + delta));
} }
void AiWander::SetCurrentNodeToClosestAllowedNode(osg::Vec3f npcPos, AiWanderStorage& storage) void AiWander::SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage)
{ {
float distanceToClosestNode = std::numeric_limits<float>::max(); float distanceToClosestNode = std::numeric_limits<float>::max();
unsigned int index = 0; unsigned int index = 0;

@ -122,7 +122,7 @@ namespace MWMechanics
/// convert point from local (i.e. cell) to world coordinates /// convert point from local (i.e. cell) to world coordinates
void ToWorldCoordinates(ESM::Pathgrid::Point& point, const ESM::Cell * cell); void ToWorldCoordinates(ESM::Pathgrid::Point& point, const ESM::Cell * cell);
void SetCurrentNodeToClosestAllowedNode(osg::Vec3f npcPos, AiWanderStorage& storage); void SetCurrentNodeToClosestAllowedNode(const osg::Vec3f& npcPos, AiWanderStorage& storage);
void AddNonPathGridAllowedPoints(osg::Vec3f npcPos, const ESM::Pathgrid * pathGrid, int pointIndex, AiWanderStorage& storage); void AddNonPathGridAllowedPoints(osg::Vec3f npcPos, const ESM::Pathgrid * pathGrid, int pointIndex, AiWanderStorage& storage);

@ -2242,7 +2242,7 @@ void CharacterController::setAttackingOrSpell(bool attackingOrSpell)
mAttackingOrSpell = attackingOrSpell; mAttackingOrSpell = attackingOrSpell;
} }
void CharacterController::setAIAttackType(std::string attackType) void CharacterController::setAIAttackType(const std::string& attackType)
{ {
mAttackType = attackType; mAttackType = attackType;
} }

@ -268,7 +268,7 @@ public:
bool isSneaking() const; bool isSneaking() const;
void setAttackingOrSpell(bool attackingOrSpell); void setAttackingOrSpell(bool attackingOrSpell);
void setAIAttackType(std::string attackType); // set and used by AiCombat void setAIAttackType(const std::string& attackType);
static void setAttackTypeRandomly(std::string& attackType); static void setAttackTypeRandomly(std::string& attackType);
bool readyToPrepareAttack() const; bool readyToPrepareAttack() const;

@ -21,7 +21,7 @@ namespace MWMechanics
, mSelfEnchanting(false) , mSelfEnchanting(false)
{} {}
void Enchanting::setOldItem(MWWorld::Ptr oldItem) void Enchanting::setOldItem(const MWWorld::Ptr& oldItem)
{ {
mOldItemPtr=oldItem; mOldItemPtr=oldItem;
if(!itemEmpty()) if(!itemEmpty())
@ -39,7 +39,7 @@ namespace MWMechanics
mNewItemName=s; mNewItemName=s;
} }
void Enchanting::setEffect(ESM::EffectList effectList) void Enchanting::setEffect(const ESM::EffectList& effectList)
{ {
mEffectList=effectList; mEffectList=effectList;
} }
@ -49,7 +49,7 @@ namespace MWMechanics
return mCastStyle; return mCastStyle;
} }
void Enchanting::setSoulGem(MWWorld::Ptr soulGem) void Enchanting::setSoulGem(const MWWorld::Ptr& soulGem)
{ {
mSoulGemPtr=soulGem; mSoulGemPtr=soulGem;
} }
@ -269,7 +269,7 @@ namespace MWMechanics
mSelfEnchanting = selfEnchanting; mSelfEnchanting = selfEnchanting;
} }
void Enchanting::setEnchanter(MWWorld::Ptr enchanter) void Enchanting::setEnchanter(const MWWorld::Ptr& enchanter)
{ {
mEnchanter = enchanter; mEnchanter = enchanter;
} }

@ -29,14 +29,14 @@ namespace MWMechanics
public: public:
Enchanting(); Enchanting();
void setEnchanter(MWWorld::Ptr enchanter); void setEnchanter(const MWWorld::Ptr& enchanter);
void setSelfEnchanting(bool selfEnchanting); void setSelfEnchanting(bool selfEnchanting);
void setOldItem(MWWorld::Ptr oldItem); void setOldItem(const MWWorld::Ptr& oldItem);
MWWorld::Ptr getOldItem() { return mOldItemPtr; } MWWorld::Ptr getOldItem() { return mOldItemPtr; }
MWWorld::Ptr getGem() { return mSoulGemPtr; } MWWorld::Ptr getGem() { return mSoulGemPtr; }
void setNewItemName(const std::string& s); void setNewItemName(const std::string& s);
void setEffect(ESM::EffectList effectList); void setEffect(const ESM::EffectList& effectList);
void setSoulGem(MWWorld::Ptr soulGem); void setSoulGem(const MWWorld::Ptr& soulGem);
bool create(); //Return true if created, false if failed. bool create(); //Return true if created, false if failed.
void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object) void nextCastStyle(); //Set enchant type to next possible type (for mOldItemPtr object)
int getCastStyle() const; int getCastStyle() const;

@ -15,7 +15,7 @@ namespace
// Chooses a reachable end pathgrid point. start is assumed reachable. // Chooses a reachable end pathgrid point. start is assumed reachable.
std::pair<int, bool> getClosestReachablePoint(const ESM::Pathgrid* grid, std::pair<int, bool> getClosestReachablePoint(const ESM::Pathgrid* grid,
const MWWorld::CellStore *cell, const MWWorld::CellStore *cell,
const osg::Vec3f pos, int start) const osg::Vec3f& pos, int start)
{ {
assert(grid && !grid->mPoints.empty()); assert(grid && !grid->mPoints.empty());

@ -794,7 +794,7 @@ namespace MWPhysics
btVector3 mContactPoint; btVector3 mContactPoint;
btScalar mLeastDistSqr; btScalar mLeastDistSqr;
DeepestNotMeContactTestResultCallback(const btCollisionObject* me, const std::vector<const btCollisionObject*> targets, const btVector3 &origin) DeepestNotMeContactTestResultCallback(const btCollisionObject* me, const std::vector<const btCollisionObject*>& targets, const btVector3 &origin)
: mMe(me), mTargets(targets), mOrigin(origin), mObject(NULL), mContactPoint(0,0,0), : mMe(me), mTargets(targets), mOrigin(origin), mObject(NULL), mContactPoint(0,0,0),
mLeastDistSqr(std::numeric_limits<float>::max()) mLeastDistSqr(std::numeric_limits<float>::max())
{ } { }
@ -912,7 +912,7 @@ namespace MWPhysics
class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback class ClosestNotMeRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{ {
public: public:
ClosestNotMeRayResultCallback(const btCollisionObject* me, const std::vector<const btCollisionObject*> targets, const btVector3& from, const btVector3& to) ClosestNotMeRayResultCallback(const btCollisionObject* me, const std::vector<const btCollisionObject*>& targets, const btVector3& from, const btVector3& to)
: btCollisionWorld::ClosestRayResultCallback(from, to) : btCollisionWorld::ClosestRayResultCallback(from, to)
, mMe(me), mTargets(targets) , mMe(me), mTargets(targets)
{ {
@ -938,7 +938,7 @@ namespace MWPhysics
const std::vector<const btCollisionObject*> mTargets; const std::vector<const btCollisionObject*> mTargets;
}; };
PhysicsSystem::RayResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, MWWorld::ConstPtr ignore, std::vector<MWWorld::Ptr> targets, int mask, int group) const PhysicsSystem::RayResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore, std::vector<MWWorld::Ptr> targets, int mask, int group) const
{ {
btVector3 btFrom = toBullet(from); btVector3 btFrom = toBullet(from);
btVector3 btTo = toBullet(to); btVector3 btTo = toBullet(to);

@ -114,7 +114,7 @@ namespace MWPhysics
}; };
/// @param me Optional, a Ptr to ignore in the list of results. targets are actors to filter for, ignoring all other actors. /// @param me Optional, a Ptr to ignore in the list of results. targets are actors to filter for, ignoring all other actors.
RayResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, MWWorld::ConstPtr ignore = MWWorld::ConstPtr(), RayResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(),
std::vector<MWWorld::Ptr> targets = std::vector<MWWorld::Ptr>(), std::vector<MWWorld::Ptr> targets = std::vector<MWWorld::Ptr>(),
int mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const; int mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const;

@ -282,7 +282,7 @@ namespace MWRender
class GlowUpdater : public SceneUtil::StateSetUpdater class GlowUpdater : public SceneUtil::StateSetUpdater
{ {
public: public:
GlowUpdater(int texUnit, osg::Vec4f color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures, GlowUpdater(int texUnit, const osg::Vec4f& color, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures,
osg::Node* node, float duration, Resource::ResourceSystem* resourcesystem) osg::Node* node, float duration, Resource::ResourceSystem* resourcesystem)
: mTexUnit(texUnit) : mTexUnit(texUnit)
, mColor(color) , mColor(color)
@ -383,7 +383,7 @@ namespace MWRender
return mDone; return mDone;
} }
void setColor(osg::Vec4f color) void setColor(const osg::Vec4f& color)
{ {
mColor = color; mColor = color;
mColorChanged = true; mColorChanged = true;
@ -1362,7 +1362,7 @@ namespace MWRender
useQuadratic, quadraticValue, quadraticRadiusMult, useLinear, linearRadiusMult, linearValue); useQuadratic, quadraticValue, quadraticRadiusMult, useLinear, linearRadiusMult, linearValue);
} }
void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, std::string texture) void Animation::addEffect (const std::string& model, int effectId, bool loop, const std::string& bonename, const std::string& texture)
{ {
if (!mObjectRoot.get()) if (!mObjectRoot.get())
return; return;

@ -362,7 +362,7 @@ public:
* @param texture override the texture specified in the model's materials - if empty, do not override * @param texture override the texture specified in the model's materials - if empty, do not override
* @note Will not add an effect twice. * @note Will not add an effect twice.
*/ */
void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", std::string texture = ""); void addEffect (const std::string& model, int effectId, bool loop = false, const std::string& bonename = "", const std::string& texture = "");
void removeEffect (int effectId); void removeEffect (int effectId);
void getLoopingEffects (std::vector<int>& out) const; void getLoopingEffects (std::vector<int>& out) const;

@ -105,7 +105,7 @@ namespace MWRender
}; };
CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, CharacterPreview::CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem,
MWWorld::Ptr character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt) const MWWorld::Ptr& character, int sizeX, int sizeY, const osg::Vec3f& position, const osg::Vec3f& lookAt)
: mParent(parent) : mParent(parent)
, mResourceSystem(resourceSystem) , mResourceSystem(resourceSystem)
, mPosition(position) , mPosition(position)
@ -244,7 +244,7 @@ namespace MWRender
// -------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------
InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character) InventoryPreview::InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character)
: CharacterPreview(parent, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71)) : CharacterPreview(parent, resourceSystem, character, 512, 1024, osg::Vec3f(0, 700, 71), osg::Vec3f(0,0,71))
{ {
} }

@ -28,7 +28,7 @@ namespace MWRender
class CharacterPreview class CharacterPreview
{ {
public: public:
CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character, int sizeX, int sizeY, CharacterPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character, int sizeX, int sizeY,
const osg::Vec3f& position, const osg::Vec3f& lookAt); const osg::Vec3f& position, const osg::Vec3f& lookAt);
virtual ~CharacterPreview(); virtual ~CharacterPreview();
@ -73,7 +73,7 @@ namespace MWRender
{ {
public: public:
InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, MWWorld::Ptr character); InventoryPreview(osg::Group* parent, Resource::ResourceSystem* resourceSystem, const MWWorld::Ptr& character);
void updatePtr(const MWWorld::Ptr& ptr); void updatePtr(const MWWorld::Ptr& ptr);

@ -99,7 +99,7 @@ private:
private: private:
void resetBlinkTimer(); void resetBlinkTimer();
public: public:
HeadAnimationTime(MWWorld::Ptr reference); HeadAnimationTime(const MWWorld::Ptr& reference);
void updatePtr(const MWWorld::Ptr& updated); void updatePtr(const MWWorld::Ptr& updated);
@ -128,7 +128,7 @@ public:
{ {
} }
void setOffset(osg::Vec3f offset) void setOffset(const osg::Vec3f& offset)
{ {
mOffset = offset; mOffset = offset;
} }
@ -155,7 +155,7 @@ private:
// -------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------
HeadAnimationTime::HeadAnimationTime(MWWorld::Ptr reference) HeadAnimationTime::HeadAnimationTime(const MWWorld::Ptr& reference)
: mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mEnabled(true), mValue(0) : mReference(reference), mTalkStart(0), mTalkStop(0), mBlinkStart(0), mBlinkStop(0), mEnabled(true), mValue(0)
{ {
resetBlinkTimer(); resetBlinkTimer();

@ -37,7 +37,7 @@ class Animation;
class PtrHolder : public osg::Object class PtrHolder : public osg::Object
{ {
public: public:
PtrHolder(MWWorld::Ptr ptr) PtrHolder(const MWWorld::Ptr& ptr)
: mPtr(ptr) : mPtr(ptr)
{ {
} }

@ -14,7 +14,7 @@ namespace MWRender
class TextureOverrideVisitor : public osg::NodeVisitor class TextureOverrideVisitor : public osg::NodeVisitor
{ {
public: public:
TextureOverrideVisitor(std::string texture, Resource::ResourceSystem* resourcesystem) TextureOverrideVisitor(const std::string& texture, Resource::ResourceSystem* resourcesystem)
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN) : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
, mTexture(texture) , mTexture(texture)
, mResourcesystem(resourcesystem) , mResourcesystem(resourcesystem)

@ -137,7 +137,7 @@ namespace MWScript
InterpreterContext::InterpreterContext ( InterpreterContext::InterpreterContext (
MWScript::Locals *locals, MWWorld::Ptr reference, const std::string& targetId) MWScript::Locals *locals, const MWWorld::Ptr& reference, const std::string& targetId)
: mLocals (locals), mReference (reference), mTargetId (targetId) : mLocals (locals), mReference (reference), mTargetId (targetId)
{ {
// If we run on a reference (local script, dialogue script or console with object // If we run on a reference (local script, dialogue script or console with object

@ -51,7 +51,7 @@ namespace MWScript
public: public:
InterpreterContext (MWScript::Locals *locals, MWWorld::Ptr reference, InterpreterContext (MWScript::Locals *locals, const MWWorld::Ptr& reference,
const std::string& targetId = ""); const std::string& targetId = "");
///< The ownership of \a locals is not transferred. 0-pointer allowed. ///< The ownership of \a locals is not transferred. 0-pointer allowed.

@ -255,7 +255,7 @@ namespace MWWorld
return MWBase::Environment::get().getMechanicsManager()->getEnemiesNearby(getPlayer()).size() != 0; return MWBase::Environment::get().getMechanicsManager()->getEnemiesNearby(getPlayer()).size() != 0;
} }
void Player::markPosition(CellStore *markedCell, ESM::Position markedPosition) void Player::markPosition(CellStore *markedCell, const ESM::Position& markedPosition)
{ {
mMarkedCell = markedCell; mMarkedCell = markedCell;
mMarkedPosition = markedPosition; mMarkedPosition = markedPosition;

@ -61,7 +61,7 @@ namespace MWWorld
void setWerewolfSkillsAttributes(); void setWerewolfSkillsAttributes();
// For mark/recall magic effects // For mark/recall magic effects
void markPosition (CellStore* markedCell, ESM::Position markedPosition); void markPosition (CellStore* markedCell, const ESM::Position& markedPosition);
void getMarkedPosition (CellStore*& markedCell, ESM::Position& markedPosition) const; void getMarkedPosition (CellStore*& markedCell, ESM::Position& markedPosition) const;
/// Interiors can not always be mapped to a world position. However /// Interiors can not always be mapped to a world position. However

@ -2989,7 +2989,7 @@ namespace MWWorld
struct AddDetectedReferenceVisitor struct AddDetectedReferenceVisitor
{ {
AddDetectedReferenceVisitor(std::vector<Ptr>& out, Ptr detector, World::DetectionType type, float squaredDist) AddDetectedReferenceVisitor(std::vector<Ptr>& out, const Ptr& detector, World::DetectionType type, float squaredDist)
: mOut(out), mDetector(detector), mSquaredDist(squaredDist), mType(type) : mOut(out), mDetector(detector), mSquaredDist(squaredDist), mType(type)
{ {
} }

@ -86,7 +86,7 @@ private:
// Prevent using writeHNT with strings. This already happened by accident and results in // Prevent using writeHNT with strings. This already happened by accident and results in
// state being discarded without any error on writing or reading it. :( // state being discarded without any error on writing or reading it. :(
// writeHNString and friends must be used instead. // writeHNString and friends must be used instead.
void writeHNT(const std::string &name, std::string data) void writeHNT(const std::string& name, const std::string& data)
{ {
} }
void writeT(const std::string& data) void writeT(const std::string& data)

@ -218,7 +218,7 @@ UVController::UVController()
{ {
} }
UVController::UVController(const Nif::NiUVData *data, std::set<int> textureUnits) UVController::UVController(const Nif::NiUVData *data, const std::set<int>& textureUnits)
: mUTrans(data->mKeyList[0], 0.f) : mUTrans(data->mKeyList[0], 0.f)
, mVTrans(data->mKeyList[1], 0.f) , mVTrans(data->mKeyList[1], 0.f)
, mUScale(data->mKeyList[2], 1.f) , mUScale(data->mKeyList[2], 1.f)
@ -381,14 +381,14 @@ void MaterialColorController::apply(osg::StateSet *stateset, osg::NodeVisitor *n
} }
} }
FlipController::FlipController(const Nif::NiFlipController *ctrl, std::vector<osg::ref_ptr<osg::Texture2D> > textures) FlipController::FlipController(const Nif::NiFlipController *ctrl, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures)
: mTexSlot(ctrl->mTexSlot) : mTexSlot(ctrl->mTexSlot)
, mDelta(ctrl->mDelta) , mDelta(ctrl->mDelta)
, mTextures(textures) , mTextures(textures)
{ {
} }
FlipController::FlipController(int texSlot, float delta, std::vector<osg::ref_ptr<osg::Texture2D> > textures) FlipController::FlipController(int texSlot, float delta, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures)
: mTexSlot(texSlot) : mTexSlot(texSlot)
, mDelta(delta) , mDelta(delta)
, mTextures(textures) , mTextures(textures)

@ -223,7 +223,7 @@ namespace NifOsg
public: public:
UVController(); UVController();
UVController(const UVController&,const osg::CopyOp&); UVController(const UVController&,const osg::CopyOp&);
UVController(const Nif::NiUVData *data, std::set<int> textureUnits); UVController(const Nif::NiUVData *data, const std::set<int>& textureUnits);
META_Object(NifOsg,UVController) META_Object(NifOsg,UVController)
@ -297,8 +297,8 @@ namespace NifOsg
std::vector<osg::ref_ptr<osg::Texture2D> > mTextures; std::vector<osg::ref_ptr<osg::Texture2D> > mTextures;
public: public:
FlipController(const Nif::NiFlipController* ctrl, std::vector<osg::ref_ptr<osg::Texture2D> > textures); FlipController(const Nif::NiFlipController* ctrl, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures);
FlipController(int texSlot, float delta, std::vector<osg::ref_ptr<osg::Texture2D> > textures); FlipController(int texSlot, float delta, const std::vector<osg::ref_ptr<osg::Texture2D> >& textures);
FlipController(); FlipController();
FlipController(const FlipController& copy, const osg::CopyOp& copyop); FlipController(const FlipController& copy, const osg::CopyOp& copyop);

Loading…
Cancel
Save