aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/WeighedRandom.cpp
diff options
context:
space:
mode:
authorvoid_17 <61356189+void2012@users.noreply.github.com>2026-03-06 02:11:18 +0700
committerGitHub <noreply@github.com>2026-03-06 02:11:18 +0700
commit55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b (patch)
tree953c537a5c66e328e9f4ab29626cf738112d53c0 /Minecraft.World/WeighedRandom.cpp
parent7d6658fe5b3095f35093701b5ab669ffc291e875 (diff)
Remove AUTO_VAR macro and _toString function (#592)
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;