summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-16 10:17:57 +0200
committerMattes D <github@xoft.cz>2014-10-16 10:17:57 +0200
commitfdd20e2a99d8cc3e9a06c527200502d16ea4bcf6 (patch)
treee10bd99420787713a71ae467d74d2aa893c9aa29 /src
parentMerge pull request #1536 from mc-server/MineshaftBooks (diff)
parentFixed possible crash (diff)
downloadcuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar.gz
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar.bz2
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar.lz
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar.xz
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.tar.zst
cuberite-fdd20e2a99d8cc3e9a06c527200502d16ea4bcf6.zip
Diffstat (limited to '')
-rw-r--r--src/ItemGrid.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ItemGrid.cpp b/src/ItemGrid.cpp
index 6a3d08679..7ebc419cb 100644
--- a/src/ItemGrid.cpp
+++ b/src/ItemGrid.cpp
@@ -658,7 +658,14 @@ void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, s
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));
+ if ((a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount) > 0)
+ {
+ CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
+ }
+ else
+ {
+ CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount;
+ }
Rnd >>= 8;
break;
}