aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/WeighedRandom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/WeighedRandom.cpp')
-rw-r--r--Minecraft.World/WeighedRandom.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Minecraft.World/WeighedRandom.cpp b/Minecraft.World/WeighedRandom.cpp
index 8839b0c5..0c27bf32 100644
--- a/Minecraft.World/WeighedRandom.cpp
+++ b/Minecraft.World/WeighedRandom.cpp
@@ -4,9 +4,9 @@
int WeighedRandom::getTotalWeight(vector<WeighedRandomItem *> *items)
{
int totalWeight = 0;
- for( AUTO_VAR(it, items->begin()); it != items->end(); it++ )
+ for( const auto& item : *items)
{
- totalWeight += (*it)->randomWeight;
+ totalWeight += item->randomWeight;
}
return totalWeight;
}
@@ -20,12 +20,12 @@ WeighedRandomItem *WeighedRandom::getRandomItem(Random *random, vector<WeighedRa
int selection = random->nextInt(totalWeight);
- for( AUTO_VAR(it, items->begin()); it != items->end(); it++ )
+ for(const auto& item : *items)
{
- selection -= (*it)->randomWeight;
+ selection -= item->randomWeight;
if (selection < 0)
{
- return *it;
+ return item;
}
}
return NULL;