summaryrefslogtreecommitdiffstats
path: root/src/ProbabDistrib.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-05-14 17:23:23 +0200
committerMattes D <github@xoft.cz>2015-05-14 17:23:23 +0200
commitc3804f08c8004cbae4f332489d22a7684925b77a (patch)
treebee2ffbfcc3273d6c56bb1dc4ff6681cc1248c03 /src/ProbabDistrib.cpp
parentMerge pull request #2010 from TwiddleStick/patch-2 (diff)
parentFixed possible crash in cProbabDistrib (diff)
downloadcuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar.gz
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar.bz2
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar.lz
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar.xz
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.tar.zst
cuberite-c3804f08c8004cbae4f332489d22a7684925b77a.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;
}