summaryrefslogtreecommitdiffstats
path: root/src/ProbabDistrib.cpp
diff options
context:
space:
mode:
authorSTRWarrior <niels.breuker@hotmail.nl>2015-05-14 16:49:13 +0200
committerSTRWarrior <niels.breuker@hotmail.nl>2015-05-14 16:49:13 +0200
commit67b6b71a5b82e18d4d08bd80f311afc18187bd8a (patch)
treedfad16aabbf07d9a6c1fba46996fd20ae21b563d /src/ProbabDistrib.cpp
parentMerge pull request #1946 from SafwatHalaby/lean (diff)
downloadcuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar.gz
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar.bz2
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar.lz
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar.xz
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.tar.zst
cuberite-67b6b71a5b82e18d4d08bd80f311afc18187bd8a.zip
Diffstat (limited to 'src/ProbabDistrib.cpp')
-rw-r--r--src/ProbabDistrib.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/ProbabDistrib.cpp b/src/ProbabDistrib.cpp
index c34c75982..ec3a4d85f 100644
--- a/src/ProbabDistrib.cpp
+++ b/src/ProbabDistrib.cpp
@@ -133,6 +133,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const
// Linearly interpolate between Lo and Hi:
int ProbDif = m_Cumulative[Hi].m_Probability - m_Cumulative[Lo].m_Probability;
+ ProbDif = (ProbDif != 0) ? ProbDif : 1;
int ValueDif = m_Cumulative[Hi].m_Value - m_Cumulative[Lo].m_Value;
return m_Cumulative[Lo].m_Value + (a_OrigValue - m_Cumulative[Lo].m_Probability) * ValueDif / ProbDif;
}