1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 16:29:55 +00:00

Add a ton of const refs

This commit is contained in:
jvoisin 2021-06-23 23:13:59 +02:00
parent df3a47187b
commit 1123dc46ee
38 changed files with 45 additions and 45 deletions

View file

@ -88,7 +88,7 @@ namespace MWBase
virtual void setPlayerClass (const ESM::Class& class_) = 0;
///< Set player class to custom class.
virtual void restoreDynamicStats(MWWorld::Ptr actor, double hours, bool sleep) = 0;
virtual void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep) = 0;
virtual void rest(double hours, bool sleep) = 0;
///< If the player is sleeping or waiting, this should be called every hour.

View file

@ -488,7 +488,7 @@ namespace MWGui
mHistoryContents.clear();
}
bool DialogueWindow::setKeywords(std::list<std::string> keyWords)
bool DialogueWindow::setKeywords(const std::list<std::string>& keyWords)
{
if (mKeywords == keyWords && isCompanion() == mIsCompanion)
return false;

View file

@ -118,7 +118,7 @@ namespace MWGui
void setPtr(const MWWorld::Ptr& actor) override;
/// @return true if stale keywords were updated successfully
bool setKeywords(std::list<std::string> keyWord);
bool setKeywords(const std::list<std::string>& keyWord);
void addResponse (const std::string& title, const std::string& text, bool needMargin = true);

View file

@ -140,7 +140,7 @@ namespace MWMechanics
return mSpells;
}
void ActiveSpells::addSpell(const std::string &id, bool stack, std::vector<ActiveEffect> effects,
void ActiveSpells::addSpell(const std::string &id, bool stack, const std::vector<ActiveEffect>& effects,
const std::string &displayName, int casterActorId)
{
TContainer::iterator it(mSpells.find(id));

View file

@ -74,7 +74,7 @@ namespace MWMechanics
/// \param effects
/// \param displayName Name for display in magic menu.
///
void addSpell (const std::string& id, bool stack, std::vector<ActiveEffect> effects,
void addSpell (const std::string& id, bool stack, const std::vector<ActiveEffect>& effects,
const std::string& displayName, int casterActorId);
/// Removes the active effects from this spell/potion/.. with \a id

View file

@ -21,7 +21,7 @@ namespace MWMechanics
/// Call when \a actor has got in contact with \a carrier (e.g. hit by him, or loots him)
/// @param actor The actor that will potentially catch diseases. Currently only the player can catch diseases.
/// @param carrier The disease carrier.
inline void diseaseContact (MWWorld::Ptr actor, MWWorld::Ptr carrier)
inline void diseaseContact (const MWWorld::Ptr& actor, const MWWorld::Ptr& carrier)
{
if (!carrier.getClass().isActor() || actor != getPlayer())
return;

View file

@ -402,7 +402,7 @@ namespace MWMechanics
mActors.rest(hours, sleep);
}
void MechanicsManager::restoreDynamicStats(MWWorld::Ptr actor, double hours, bool sleep)
void MechanicsManager::restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep)
{
mActors.restoreDynamicStats(actor, hours, sleep);
}

View file

@ -75,7 +75,7 @@ namespace MWMechanics
void setPlayerClass (const ESM::Class& class_) override;
///< Set player class to custom class.
void restoreDynamicStats(MWWorld::Ptr actor, double hours, bool sleep) override;
void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep) override;
void rest(double hours, bool sleep) override;
///< If the player is sleeping or waiting, this should be called every hour.

View file

@ -167,7 +167,7 @@ namespace MWMechanics
// Caller needs to be careful for very short distances (i.e. less than 1)
// or when accumuating the results i.e. (a + b)^2 != a^2 + b^2
//
static float distanceSquared(ESM::Pathgrid::Point point, const osg::Vec3f& pos)
static float distanceSquared(const ESM::Pathgrid::Point& point, const osg::Vec3f& pos)
{
return (MWMechanics::PathFinder::makeOsgVec3(point) - pos).length2();
}

View file

@ -53,7 +53,7 @@ namespace MWMechanics
}
}
bool Pickpocket::pick(MWWorld::Ptr item, int count)
bool Pickpocket::pick(const MWWorld::Ptr& item, int count)
{
float stackValue = static_cast<float>(item.getClass().getValue(item) * count);
float fPickPocketMod = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()

View file

@ -13,7 +13,7 @@ namespace MWMechanics
/// Steal some items
/// @return Was the thief detected?
bool pick (MWWorld::Ptr item, int count);
bool pick (const MWWorld::Ptr& item, int count);
/// End the pickpocketing process
/// @return Was the thief detected?
bool finish ();

View file

@ -4,7 +4,7 @@
namespace MWMechanics
{
MWWorld::ContainerStoreIterator getActiveWeapon(MWWorld::Ptr actor, int *weaptype)
MWWorld::ContainerStoreIterator getActiveWeapon(const MWWorld::Ptr& actor, int *weaptype)
{
MWWorld::InventoryStore &inv = actor.getClass().getInventoryStore(actor);
CreatureStats &stats = actor.getClass().getCreatureStats(actor);

View file

@ -261,7 +261,7 @@ namespace MWMechanics
}
};
MWWorld::ContainerStoreIterator getActiveWeapon(MWWorld::Ptr actor, int *weaptype);
MWWorld::ContainerStoreIterator getActiveWeapon(const MWWorld::Ptr& actor, int *weaptype);
const ESM::WeaponType* getWeaponType(const int weaponType);
}

View file

@ -261,7 +261,7 @@ namespace MWPhysics
return 0.f;
}
RayCastingResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore, std::vector<MWWorld::Ptr> targets, int mask, int group) const
RayCastingResult PhysicsSystem::castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore, const std::vector<MWWorld::Ptr>& targets, int mask, int group) const
{
if (from == to)
{
@ -290,7 +290,7 @@ namespace MWPhysics
if (!targets.empty())
{
for (MWWorld::Ptr& target : targets)
for (const MWWorld::Ptr& target : targets)
{
const Actor* actor = getActor(target);
if (actor)

View file

@ -175,7 +175,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.
RayCastingResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(),
std::vector<MWWorld::Ptr> targets = std::vector<MWWorld::Ptr>(),
const std::vector<MWWorld::Ptr>& targets = std::vector<MWWorld::Ptr>(),
int mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const override;
RayCastingResult castSphere(const osg::Vec3f& from, const osg::Vec3f& to, float radius) const override;

View file

@ -78,7 +78,7 @@ bool Projectile::canTraverseWater() const
return mCanCrossWaterSurface;
}
void Projectile::hit(MWWorld::Ptr target, btVector3 pos, btVector3 normal)
void Projectile::hit(const MWWorld::Ptr& target, btVector3 pos, btVector3 normal)
{
if (!mActive.load(std::memory_order_acquire))
return;
@ -95,7 +95,7 @@ MWWorld::Ptr Projectile::getCaster() const
return mCaster;
}
void Projectile::setCaster(MWWorld::Ptr caster)
void Projectile::setCaster(const MWWorld::Ptr& caster)
{
std::scoped_lock lock(mMutex);
mCaster = caster;

View file

@ -58,11 +58,11 @@ namespace MWPhysics
}
MWWorld::Ptr getCaster() const;
void setCaster(MWWorld::Ptr caster);
void setCaster(const MWWorld::Ptr& caster);
bool canTraverseWater() const;
void hit(MWWorld::Ptr target, btVector3 pos, btVector3 normal);
void hit(const MWWorld::Ptr& target, btVector3 pos, btVector3 normal);
void setValidTargets(const std::vector<MWWorld::Ptr>& targets);
bool isValidTarget(const MWWorld::Ptr& target) const;

View file

@ -28,7 +28,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.
virtual RayCastingResult castRay(const osg::Vec3f &from, const osg::Vec3f &to, const MWWorld::ConstPtr& ignore = MWWorld::ConstPtr(),
std::vector<MWWorld::Ptr> targets = std::vector<MWWorld::Ptr>(),
const std::vector<MWWorld::Ptr>& targets = std::vector<MWWorld::Ptr>(),
int mask = CollisionType_World|CollisionType_HeightMap|CollisionType_Actor|CollisionType_Door, int group=0xff) const = 0;
virtual RayCastingResult castSphere(const osg::Vec3f& from, const osg::Vec3f& to, float radius) const = 0;

View file

@ -415,7 +415,7 @@ namespace MWScript
return MWBase::Environment::get().getWorld()->getCellName();
}
void InterpreterContext::executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor)
void InterpreterContext::executeActivation(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor)
{
std::shared_ptr<MWWorld::Action> action = (ptr.getClass().activate(ptr, actor));
action->execute (actor);

View file

@ -111,7 +111,7 @@ namespace MWScript
std::string getCurrentCellName() const override;
void executeActivation(MWWorld::Ptr ptr, MWWorld::Ptr actor);
void executeActivation(const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor);
///< Execute the activation action for this ptr. If ptr is mActivated, mark activation as handled.
int getMemberShort (const std::string& id, const std::string& name, bool global) const override;

View file

@ -31,7 +31,7 @@
namespace
{
std::string getDialogueActorFaction(MWWorld::ConstPtr actor)
std::string getDialogueActorFaction(const MWWorld::ConstPtr& actor)
{
std::string factionId = actor.getClass().getPrimaryFaction(actor);
if (factionId.empty())

View file

@ -1162,7 +1162,7 @@ namespace MWWorld
update(mBooks.mList);
}
void MWWorld::CellStore::checkItem(Ptr ptr)
void MWWorld::CellStore::checkItem(const Ptr& ptr)
{
if (ptr.getClass().getEnchantment(ptr).empty())
return;

View file

@ -127,7 +127,7 @@ namespace MWWorld
void updateRechargingItems();
void rechargeItems(float duration);
void checkItem(Ptr ptr);
void checkItem(const Ptr& ptr);
// helper function for forEachInternal
template<class Visitor, class List>

View file

@ -13,7 +13,7 @@ namespace MWWorld
{
std::vector<MWWorld::Ptr> mObjects;
bool operator() (MWWorld::Ptr ptr)
bool operator() (const MWWorld::Ptr& ptr)
{
if (ptr.getRefData().getBaseNode())
{

View file

@ -325,7 +325,7 @@ namespace MWWorld
mMagicBolts.push_back(state);
}
void ProjectileManager::launchProjectile(Ptr actor, ConstPtr projectile, const osg::Vec3f &pos, const osg::Quat &orient, Ptr bow, float speed, float attackStrength)
void ProjectileManager::launchProjectile(const Ptr& actor, const ConstPtr& projectile, const osg::Vec3f &pos, const osg::Quat &orient, const Ptr& bow, float speed, float attackStrength)
{
ProjectileState state;
state.mActorId = actor.getClass().getCreatureStats(actor).getActorId();

View file

@ -51,8 +51,8 @@ namespace MWWorld
/// If caster is an actor, the actor's facing orientation is used. Otherwise fallbackDirection is used.
void launchMagicBolt (const std::string &spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection);
void launchProjectile (MWWorld::Ptr actor, MWWorld::ConstPtr projectile,
const osg::Vec3f& pos, const osg::Quat& orient, MWWorld::Ptr bow, float speed, float attackStrength);
void launchProjectile (const MWWorld::Ptr& actor, const MWWorld::ConstPtr& projectile,
const osg::Vec3f& pos, const osg::Quat& orient, const MWWorld::Ptr& bow, float speed, float attackStrength);
void updateCasters();

View file

@ -753,7 +753,7 @@ namespace MWWorld
FindContainerVisitor(const ConstPtr& containedPtr) : mContainedPtr(containedPtr) {}
bool operator() (Ptr ptr)
bool operator() (const Ptr& ptr)
{
if (mContainedPtr.getContainerStore() == &ptr.getClass().getContainerStore(ptr))
{
@ -3836,7 +3836,7 @@ namespace MWWorld
struct ResetActorsVisitor
{
bool operator() (Ptr ptr)
bool operator() (const Ptr& ptr)
{
if (ptr.getClass().isActor() && ptr.getCellRef().hasContentFile())
{

View file

@ -406,7 +406,7 @@ Files::IStreamPtr CompressedBSAFile::getFile(const FileRecord& fileRecord)
return std::shared_ptr<std::istream>(memoryStreamPtr, (std::istream*)memoryStreamPtr.get());
}
BsaVersion CompressedBSAFile::detectVersion(std::string filePath)
BsaVersion CompressedBSAFile::detectVersion(const std::string& filePath)
{
namespace bfs = boost::filesystem;
bfs::ifstream input(bfs::path(filePath), std::ios_base::binary);

View file

@ -87,7 +87,7 @@ namespace Bsa
virtual ~CompressedBSAFile();
//checks version of BSA from file header
static BsaVersion detectVersion(std::string filePath);
static BsaVersion detectVersion(const std::string& filePath);
/// Read header information from the input source
void readHeader() override;

View file

@ -133,7 +133,7 @@ namespace DetourNavigator
addChangedTile(tile, ChangeType::update);
}
void NavMeshManager::update(osg::Vec3f playerPosition, const osg::Vec3f& agentHalfExtents)
void NavMeshManager::update(const osg::Vec3f& playerPosition, const osg::Vec3f& agentHalfExtents)
{
const auto playerTile = getTilePosition(mSettings, toNavMeshCoordinates(mSettings, playerPosition));
auto& lastRevision = mLastRecastMeshManagerRevision[agentHalfExtents];

View file

@ -43,7 +43,7 @@ namespace DetourNavigator
void removeOffMeshConnections(const ObjectId id);
void update(osg::Vec3f playerPosition, const osg::Vec3f& agentHalfExtents);
void update(const osg::Vec3f& playerPosition, const osg::Vec3f& agentHalfExtents);
void wait(Loading::Listener& listener, WaitConditionType waitConditionType);

View file

@ -279,7 +279,7 @@ public:
// TODO: use the std::string_view once we will use the C++17.
// It should allow us to avoid data copying while we still will support both string and literal arguments.
static inline void replaceAll(std::string& data, std::string toSearch, std::string replaceStr)
static inline void replaceAll(std::string& data, const std::string& toSearch, const std::string& replaceStr)
{
size_t pos = data.find(toSearch);

View file

@ -1996,7 +1996,7 @@ struct ConvexHull
}
};
Vertices findInternalEdges(osg::Vec3d mainVertex, Vertices connectedVertices)
Vertices findInternalEdges(const osg::Vec3d& mainVertex, const Vertices& connectedVertices)
{
Vertices internalEdgeVertices;
for (const auto& vertex : connectedVertices)

View file

@ -153,7 +153,7 @@ namespace SceneUtil
return osg::Vec3f();
}
void OsgAnimationController::update(float time, std::string animationName)
void OsgAnimationController::update(float time, const std::string& animationName)
{
for (const auto& mergedAnimationTrack : mMergedAnimationTracks)
{
@ -190,7 +190,7 @@ namespace SceneUtil
traverse(node, nv);
}
void OsgAnimationController::setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations)
void OsgAnimationController::setEmulatedAnimations(const std::vector<EmulatedAnimation>& emulatedAnimations)
{
mEmulatedAnimations = emulatedAnimations;
}

View file

@ -58,13 +58,13 @@ namespace SceneUtil
osg::Vec3f getTranslation(float time) const override;
/// @brief Calls animation track update()
void update(float time, std::string animationName);
void update(float time, const std::string& animationName);
/// @brief Called every frame for osgAnimation
void operator() (osg::Node*, osg::NodeVisitor*) override;
/// @brief Sets details of the animations
void setEmulatedAnimations(std::vector<EmulatedAnimation> emulatedAnimations);
void setEmulatedAnimations(const std::vector<EmulatedAnimation>& emulatedAnimations);
/// @brief Adds an animation track to a model
void addMergedAnimationTrack(osg::ref_ptr<Resource::Animation> animationTrack);

View file

@ -218,7 +218,7 @@ bool hasUserDescription(const osg::Node* node, const std::string pattern)
return false;
}
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, osg::Vec4f glowColor, float glowDuration)
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, const osg::Vec4f& glowColor, float glowDuration)
{
std::vector<osg::ref_ptr<osg::Texture2D> > textures;
for (int i=0; i<32; ++i)

View file

@ -60,7 +60,7 @@ namespace SceneUtil
bool hasUserDescription(const osg::Node* node, const std::string pattern);
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, osg::Vec4f glowColor, float glowDuration=-1);
osg::ref_ptr<GlowUpdater> addEnchantedGlow(osg::ref_ptr<osg::Node> node, Resource::ResourceSystem* resourceSystem, const osg::Vec4f& glowColor, float glowDuration=-1);
// Alpha-to-coverage requires a multisampled framebuffer, so we need to set that up for RTTs
bool attachAlphaToCoverageFriendlyFramebufferToCamera(osg::Camera* camera, osg::Camera::BufferComponent buffer, osg::Texture* texture, unsigned int level = 0, unsigned int face = 0, bool mipMapGeneration = false);

View file

@ -75,7 +75,7 @@ namespace Shader
// Recursively replaces include statements with the actual source of the included files.
// Adjusts #line statements accordingly and detects cyclic includes.
// includingFiles is the set of files that include this file directly or indirectly, and is intentionally not a reference to allow automatic cleanup.
static bool parseIncludes(boost::filesystem::path shaderPath, std::string& source, const std::string& fileName, int& fileNumber, std::set<boost::filesystem::path> includingFiles)
static bool parseIncludes(const boost::filesystem::path& shaderPath, std::string& source, const std::string& fileName, int& fileNumber, std::set<boost::filesystem::path> includingFiles)
{
// An include is cyclic if it is being included by itself
if (includingFiles.insert(shaderPath/fileName).second == false)