summaryrefslogtreecommitdiffstats
path: root/src/ProbabDistrib.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2024-11-02 22:27:47 +0100
committerAlexander Harkness <me@bearbin.net>2024-11-02 22:27:47 +0100
commitcb50ec10591c0e0e4b9915e642bc50d3d8d1fd0a (patch)
treef647b20e1823f1846af88e832cf82a4a02e96e69 /src/ProbabDistrib.cpp
parentImprove clang-format config file, remove automatically enforced code style from contrib guide. (diff)
downloadcuberite-clang-format-codebase.tar
cuberite-clang-format-codebase.tar.gz
cuberite-clang-format-codebase.tar.bz2
cuberite-clang-format-codebase.tar.lz
cuberite-clang-format-codebase.tar.xz
cuberite-clang-format-codebase.tar.zst
cuberite-clang-format-codebase.zip
Diffstat (limited to 'src/ProbabDistrib.cpp')
-rw-r--r--src/ProbabDistrib.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/ProbabDistrib.cpp b/src/ProbabDistrib.cpp
index 07981d031..87bdfd8dc 100644
--- a/src/ProbabDistrib.cpp
+++ b/src/ProbabDistrib.cpp
@@ -11,8 +11,7 @@
cProbabDistrib::cProbabDistrib(int a_MaxValue) :
- m_MaxValue(a_MaxValue),
- m_Sum(-1)
+ m_MaxValue(a_MaxValue), m_Sum(-1)
{
}
@@ -75,11 +74,8 @@ bool cProbabDistrib::SetDefString(const AString & a_DefString)
return false;
}
int Value = atoi(Split[0].c_str());
- int Prob = atoi(Split[1].c_str());
- if (
- ((Value == 0) && (Split[0] != "0")) ||
- ((Prob == 0) && (Split[1] != "0"))
- )
+ int Prob = atoi(Split[1].c_str());
+ if (((Value == 0) && (Split[0] != "0")) || ((Prob == 0) && (Split[1] != "0")))
{
// Number parse error
return false;
@@ -128,12 +124,8 @@ int cProbabDistrib::MapValue(int a_OrigValue) const
ASSERT(Hi - Lo == 1);
// Linearly interpolate between Lo and Hi:
- int ProbDif = m_Cumulative[Hi].m_Probability - m_Cumulative[Lo].m_Probability;
+ 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;
}
-
-
-
-