From 2dbf79c6e6419721e6f22ee632d8cd08ce97f35f Mon Sep 17 00:00:00 2001 From: jsmorley Date: Sun, 28 Feb 2010 14:19:35 +0000 Subject: [PATCH] Fixed: MattKing's change to RANDOM to fix issue where it was only random once. --- Library/MeasureCalc.cpp | 13 ++++++++++--- Library/MeasureCalc.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) 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;