Add some const qualifiers to functions (#4874)
* add some const qualifiers to functions * added changes suggested by @tigerw Co-authored-by: 12xx12 <12xx12100@gmail.com>
This commit is contained in:
parent
a90dedffeb
commit
53549a1a4c
@ -1170,20 +1170,20 @@ void cEnchantments::CheckEnchantmentConflictsFromVector(
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cEnchantments cEnchantments::GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments)
|
cEnchantments cEnchantments::GetRandomEnchantmentFromVector(const cWeightedEnchantments & a_Enchantments)
|
||||||
{
|
{
|
||||||
int AllWeights = 0;
|
int AllWeights = 0;
|
||||||
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
for (const auto & Enchantment: a_Enchantments)
|
||||||
{
|
{
|
||||||
AllWeights += (*it).m_Weight;
|
AllWeights += Enchantment.m_Weight;
|
||||||
}
|
}
|
||||||
int RandomNumber = GetRandomProvider().RandInt(AllWeights - 1);
|
int RandomNumber = GetRandomProvider().RandInt(AllWeights - 1);
|
||||||
for (cWeightedEnchantments::iterator it = a_Enchantments.begin(); it != a_Enchantments.end(); ++it)
|
for (const auto & Enchantment: a_Enchantments)
|
||||||
{
|
{
|
||||||
RandomNumber -= (*it).m_Weight;
|
RandomNumber -= Enchantment.m_Weight;
|
||||||
if (RandomNumber < 0)
|
if (RandomNumber < 0)
|
||||||
{
|
{
|
||||||
return (*it).m_Enchantments;
|
return Enchantment.m_Enchantments;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_FirstEnchantment);
|
static void CheckEnchantmentConflictsFromVector(cWeightedEnchantments & a_Enchantments, const cEnchantments & a_FirstEnchantment);
|
||||||
|
|
||||||
/** Gets random enchantment from Vector and returns it */
|
/** Gets random enchantment from Vector and returns it */
|
||||||
static cEnchantments GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments);
|
static cEnchantments GetRandomEnchantmentFromVector(const cWeightedEnchantments & a_Enchantments);
|
||||||
|
|
||||||
/** Selects one enchantment from a Vector using cNoise. Mostly used for generators.
|
/** Selects one enchantment from a Vector using cNoise. Mostly used for generators.
|
||||||
Uses the enchantments' weights for the random distribution.
|
Uses the enchantments' weights for the random distribution.
|
||||||
|
@ -470,7 +470,7 @@ void cPawn::StopEveryoneFromTargetingMe()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::map<cEntityEffect::eType, cEntityEffect *> cPawn::GetEntityEffects()
|
std::map<cEntityEffect::eType, cEntityEffect *> cPawn::GetEntityEffects() const
|
||||||
{
|
{
|
||||||
std::map<cEntityEffect::eType, cEntityEffect *> Effects;
|
std::map<cEntityEffect::eType, cEntityEffect *> Effects;
|
||||||
for (auto & Effect : m_EntityEffects)
|
for (auto & Effect : m_EntityEffects)
|
||||||
@ -484,7 +484,7 @@ std::map<cEntityEffect::eType, cEntityEffect *> cPawn::GetEntityEffects()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cEntityEffect * cPawn::GetEntityEffect(cEntityEffect::eType a_EffectType)
|
cEntityEffect * cPawn::GetEntityEffect(cEntityEffect::eType a_EffectType) const
|
||||||
{
|
{
|
||||||
auto itr = m_EntityEffects.find(a_EffectType);
|
auto itr = m_EntityEffects.find(a_EffectType);
|
||||||
return (itr != m_EntityEffects.end()) ? itr->second.get() : nullptr;
|
return (itr != m_EntityEffects.end()) ? itr->second.get() : nullptr;
|
||||||
|
@ -66,10 +66,10 @@ public:
|
|||||||
void TargetingMe(cMonster * a_Monster);
|
void TargetingMe(cMonster * a_Monster);
|
||||||
|
|
||||||
/** Returns all entity effects */
|
/** Returns all entity effects */
|
||||||
std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects();
|
std::map<cEntityEffect::eType, cEntityEffect *> GetEntityEffects() const;
|
||||||
|
|
||||||
/** Returns the entity effect, if it is currently applied or nullptr if not. */
|
/** Returns the entity effect, if it is currently applied or nullptr if not. */
|
||||||
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType);
|
cEntityEffect * GetEntityEffect(cEntityEffect::eType a_EffectType) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
|
typedef std::map<cEntityEffect::eType, std::unique_ptr<cEntityEffect>> tEffectMap;
|
||||||
|
Loading…
Reference in New Issue
Block a user