diff options
| author | qwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com> | 2026-03-05 17:17:45 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-05 17:17:45 -0600 |
| commit | 0666959d312dc74903f55d1071488a90239330f1 (patch) | |
| tree | 5c6886f7ec65a7828bc6e34a469514e418bcf78b /Minecraft.World/WeighedRandom.cpp | |
| parent | 9370cbc7d878df1615d8ce76bc459e8b414d0f19 (diff) | |
| parent | eed770b121aa4ce38f002db042d0137c24c6d344 (diff) | |
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.World/WeighedRandom.cpp')
| -rw-r--r-- | Minecraft.World/WeighedRandom.cpp | 10 |
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; |
