summaryrefslogtreecommitdiffstats
path: root/src/Enchantments.cpp
diff options
context:
space:
mode:
author12xx12 <44411062+12xx12@users.noreply.github.com>2020-09-17 00:01:20 +0200
committerGitHub <noreply@github.com>2020-09-17 00:01:20 +0200
commit53549a1a4ce320c1e3f449165c290c74d3de54d4 (patch)
tree5f7d6cda28281d381bbecf7cb0f3b820057000b4 /src/Enchantments.cpp
parentFixed doors not breakable by piston (#4869) (diff)
downloadcuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar.gz
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar.bz2
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar.lz
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar.xz
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.tar.zst
cuberite-53549a1a4ce320c1e3f449165c290c74d3de54d4.zip
Diffstat (limited to 'src/Enchantments.cpp')
-rw-r--r--src/Enchantments.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp
index 52ebc5e3e..8eda97eba 100644
--- a/src/Enchantments.cpp
+++ b/src/Enchantments.cpp
@@ -1170,20 +1170,20 @@ void cEnchantments::CheckEnchantmentConflictsFromVector(
-cEnchantments cEnchantments::GetRandomEnchantmentFromVector(cWeightedEnchantments & a_Enchantments)
+cEnchantments cEnchantments::GetRandomEnchantmentFromVector(const cWeightedEnchantments & a_Enchantments)
{
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);
- 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)
{
- return (*it).m_Enchantments;
+ return Enchantment.m_Enchantments;
}
}