diff options
author | Mattes D <github@xoft.cz> | 2015-05-14 17:23:23 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2015-05-14 17:23:23 +0200 |
commit | c3804f08c8004cbae4f332489d22a7684925b77a (patch) | |
tree | bee2ffbfcc3273d6c56bb1dc4ff6681cc1248c03 /src/ProbabDistrib.cpp | |
parent | Merge pull request #2010 from TwiddleStick/patch-2 (diff) | |
parent | Fixed possible crash in cProbabDistrib (diff) | |
download | cuberite-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 '')
-rw-r--r-- | src/ProbabDistrib.cpp | 1 |
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; } |