Fixed possible crash in cProbabDistrib
It could divide through 0 which causes a crash
This commit is contained in:
parent
bd73dcedd4
commit
67b6b71a5b
@ -133,6 +133,7 @@ int cProbabDistrib::MapValue(int a_OrigValue) const
|
|||||||
|
|
||||||
// Linearly interpolate between Lo and Hi:
|
// 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;
|
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;
|
return m_Cumulative[Lo].m_Value + (a_OrigValue - m_Cumulative[Lo].m_Probability) * ValueDif / ProbDif;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user