MeasureCalc: Allow for LowBound to equal HighBound. If LowBound is greater then HighBound, set HighBound equal to LowBound (and show error).

This commit is contained in:
Brian Ferguson 2013-08-19 14:41:45 -06:00
parent b0c4f83424
commit dfc804d50e

View File

@ -104,18 +104,12 @@ void MeasureCalc::ReadOptions(ConfigParser& parser, const WCHAR* section)
oldUpdateRandom != m_UpdateRandom || oldUpdateRandom != m_UpdateRandom ||
oldUniqueRandom != m_UniqueRandom) oldUniqueRandom != m_UniqueRandom)
{ {
// Reset bounds if |m_LowBound| is greater than or equal to |m_HighBound| // Reset bounds if |m_LowBound| is greater than |m_HighBound|
if (m_LowBound >= m_HighBound) if (m_LowBound > m_HighBound)
{ {
// Only report an error after the first update cycle LogErrorF(this, L"\"LowBound\" (%i) must be less then or equal to \"HighBound\" (%i)", m_LowBound, m_HighBound);
// For cases where "HighBound=[SomeMeasure]", and [SomeMeasure] would initially equal 0
if (m_Initialized) m_HighBound = m_LowBound;
{
LogErrorF(this, L"\"LowBound\" (%i) must be less then \"HighBound\" (%i)", m_LowBound, m_HighBound);
}
m_LowBound = DEFAULT_LOWER_BOUND;
m_HighBound = DEFAULT_UPPER_BOUND;
} }
// Reset the list if the bounds are changed // Reset the list if the bounds are changed
@ -208,7 +202,11 @@ int MeasureCalc::GetRandom()
{ {
int value = 0; int value = 0;
if (m_UniqueRandom) if (m_LowBound == m_HighBound)
{
value = m_LowBound;
}
else if (m_UniqueRandom)
{ {
if (m_UniqueNumbers.empty()) if (m_UniqueNumbers.empty())
{ {