diff options
author | STRWarrior <niels.breuker@hotmail.nl> | 2014-10-15 18:11:28 +0200 |
---|---|---|
committer | STRWarrior <niels.breuker@hotmail.nl> | 2014-10-15 18:11:28 +0200 |
commit | 4038e1cb42e84f210826f22c6a55b13c440cf9fb (patch) | |
tree | ffe50a86576aa60354250a1496bde076a31be3f0 | |
parent | The code now prevents conflicting enchantments. (diff) | |
download | cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar.gz cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar.bz2 cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar.lz cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar.xz cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.tar.zst cuberite-4038e1cb42e84f210826f22c6a55b13c440cf9fb.zip |
-rw-r--r-- | src/Enchantments.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Enchantments.cpp b/src/Enchantments.cpp index 10d23a8fb..80a9810b6 100644 --- a/src/Enchantments.cpp +++ b/src/Enchantments.cpp @@ -1024,20 +1024,20 @@ cEnchantments cEnchantments::GetRandomEnchantmentFromVector(cWeightedEnchantment cEnchantments cEnchantments::GenerateEnchantmentFromVector(cWeightedEnchantments & a_Enchantments, int a_Seed) { 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; } cNoise Noise(a_Seed); int RandomNumber = Noise.IntNoise1DInt(AllWeights) / 7 % AllWeights; - 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; } } |