diff --git a/src/ship/GunManager.cpp b/src/ship/GunManager.cpp index b00d966613..033fa0c392 100644 --- a/src/ship/GunManager.cpp +++ b/src/ship/GunManager.cpp @@ -118,7 +118,7 @@ void GunManager::LoadFromJson(const Json &jsonObj, Space *space) } } -bool GunManager::AddWeaponMount(StringName id, StringName tagName, vector2f gimbalLimit) +bool GunManager::AddWeaponMount(const StringName &id, const StringName &tagName, vector2f gimbalLimit) { WeaponMount mount = {}; @@ -133,7 +133,7 @@ bool GunManager::AddWeaponMount(StringName id, StringName tagName, vector2f gimb return result.second; } -bool GunManager::RemoveWeaponMount(StringName id) +bool GunManager::RemoveWeaponMount(const StringName &id) { auto iter = m_mounts.find(id); if (iter == m_mounts.end()) @@ -146,7 +146,7 @@ bool GunManager::RemoveWeaponMount(StringName id) return true; } -bool GunManager::MountWeapon(StringName hardpoint, const WeaponData &gunData) +bool GunManager::MountWeapon(const StringName &hardpoint, const WeaponData &gunData) { auto iter = m_mounts.find(hardpoint); if (iter == m_mounts.end()) @@ -173,7 +173,7 @@ bool GunManager::MountWeapon(StringName hardpoint, const WeaponData &gunData) return true; } -void GunManager::UnmountWeapon(StringName hardpoint) +void GunManager::UnmountWeapon(const StringName &hardpoint) { auto iter = std::find_if(m_weapons.begin(), m_weapons.end(), [&](const WeaponState &ws) { return ws.mount->id == hardpoint; @@ -192,7 +192,7 @@ void GunManager::UnmountWeapon(StringName hardpoint) } } -bool GunManager::IsWeaponMounted(StringName hardpoint) const +bool GunManager::IsWeaponMounted(const StringName &hardpoint) const { return std::find_if(m_weapons.begin(), m_weapons.end(), [&](const WeaponState &ws) { return ws.mount->id == hardpoint; @@ -210,7 +210,7 @@ void GunManager::RemoveGroupIndex(WeaponIndexSet &group, uint32_t index) group = (group & keep) | ((group & mask) >> 1); } -uint32_t GunManager::GetWeaponIndexForHardpoint(StringName hardpoint) const +uint32_t GunManager::GetWeaponIndexForHardpoint(const StringName &hardpoint) const { auto iter = std::find_if(m_weapons.begin(), m_weapons.end(), [&](const WeaponState &ws) { return ws.mount->id == hardpoint; diff --git a/src/ship/GunManager.h b/src/ship/GunManager.h index 4be57ef8d5..b660d4940f 100644 --- a/src/ship/GunManager.h +++ b/src/ship/GunManager.h @@ -139,25 +139,25 @@ class GunManager : public LuaWrappable { // Add a weapon mount to this gun manager. // Returns false if a hardpoint already exists on this GunManager with the specified name. - bool AddWeaponMount(StringName id, StringName tagName, vector2f gimbalLimitDegrees); + bool AddWeaponMount(const StringName &id, const StringName &tagName, vector2f gimbalLimitDegrees); // Remove a weapon mount from this gun manager. // The caller should always ensure that the weapon mount is empty before calling this function. // Returns false if the mount does not exist or is not empty. - bool RemoveWeaponMount(StringName id); + bool RemoveWeaponMount(const StringName &id); // Attach a weapon to a specific mount. // Returns false if the hardpoint cannot be found or the weapon could not be mounted. - bool MountWeapon(StringName hardpoint, const WeaponData &data); + bool MountWeapon(const StringName &hardpoint, const WeaponData &data); // Remove the attached weapon from a specific mount - void UnmountWeapon(StringName hardpoint); + void UnmountWeapon(const StringName &hardpoint); // Check if any weapon is attached to a specific mount - bool IsWeaponMounted(StringName hardpoint) const; + bool IsWeaponMounted(const StringName &hardpoint) const; const std::vector &GetWeapons() const { return m_weapons; } uint32_t GetNumWeapons() const { return m_weapons.size(); } const WeaponState *GetWeaponState(uint32_t numWeapon) const { return m_weapons.size() > numWeapon ? &m_weapons[numWeapon] : nullptr; } - uint32_t GetWeaponIndexForHardpoint(StringName hardpoint) const; + uint32_t GetWeaponIndexForHardpoint(const StringName &hardpoint) const; // ==========================================