diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index 6db6abc6..e2729cef 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -25,6 +25,7 @@ using namespace std; hqStrMap* CMeasureCalc::c_VarMap = NULL; +bool CMeasureCalc::c_RandSeeded = false; /* ** CMeasureCalc @@ -34,10 +35,15 @@ hqStrMap* CMeasureCalc::c_VarMap = NULL; */ CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow) : CMeasure(meterWindow) { - m_Parser = MathParser_Create(NULL); - srand((unsigned)time(0)); - rand(); + if(!c_RandSeeded) + { + c_RandSeeded = true; + srand((unsigned)time(0)); + } + m_Parser = MathParser_Create(NULL); + + rand(); } /* @@ -147,6 +153,7 @@ void CMeasureCalc::RandomFormulaReplace() while(loc > -1) { int range = (m_HighBound - m_LowBound); + srand((unsigned) rand()); int randNumber = m_LowBound + (range * rand()/(RAND_MAX + 1.0)); std::wstring randomNumberString= (L""); diff --git a/Library/MeasureCalc.h b/Library/MeasureCalc.h index aac74ac3..4735bfb1 100644 --- a/Library/MeasureCalc.h +++ b/Library/MeasureCalc.h @@ -40,6 +40,7 @@ private: hqMathParser* m_Parser; static hqStrMap* c_VarMap; + static bool c_RandSeeded; int m_UpdateRandom; int m_LowBound;