summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2014-10-16 11:17:39 +0200
committerSTRWarrior <niels.breuker@hotmail.nl>2014-10-16 11:17:39 +0200
commit07b5ce0c54422d511b5030728b4d09e40338a866 (patch)
treecf4cfbc4b42f0a75c2f5632bf2400ea5edb67561
parentReversed wrong fix for #1517. (diff)
downloadcuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar.gz
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar.bz2
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar.lz
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar.xz
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.tar.zst
cuberite-07b5ce0c54422d511b5030728b4d09e40338a866.zip
-rw-r--r--src/ItemGrid.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 6a3d08679..0bd44bb0d 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -654,11 +654,18 @@ void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, s
for (size_t j = 0; j < a_CountLootProbabs; j++)
{
- LootRnd -= a_LootProbabs[i].m_Weight;
+ LootRnd -= a_LootProbabs[j].m_Weight;
if (LootRnd < 0)
{
- CurrentLoot = a_LootProbabs[i].m_Item;
- CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
+ CurrentLoot = a_LootProbabs[j].m_Item;
+ if ((a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount) > 0)
+ {
+ CurrentLoot.m_ItemCount = a_LootProbabs[j].m_MinAmount + (Rnd % (a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount));
+ }
+ else
+ {
+ CurrentLoot.m_ItemCount = a_LootProbabs[j].m_MinAmount;
+ }
Rnd >>= 8;
break;
}