Fixed: MattKing's change to RANDOM to fix issue where it was only random once.

This commit is contained in:
jsmorley 2010-02-28 14:19:35 +00:00
parent ed07f986fc
commit 2dbf79c6e6
2 changed files with 11 additions and 3 deletions

View File

@ -25,6 +25,7 @@
using namespace std; using namespace std;
hqStrMap* CMeasureCalc::c_VarMap = NULL; hqStrMap* CMeasureCalc::c_VarMap = NULL;
bool CMeasureCalc::c_RandSeeded = false;
/* /*
** CMeasureCalc ** CMeasureCalc
@ -34,10 +35,15 @@ hqStrMap* CMeasureCalc::c_VarMap = NULL;
*/ */
CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow) : CMeasure(meterWindow) CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow) : CMeasure(meterWindow)
{ {
m_Parser = MathParser_Create(NULL); if(!c_RandSeeded)
srand((unsigned)time(0)); {
rand(); c_RandSeeded = true;
srand((unsigned)time(0));
}
m_Parser = MathParser_Create(NULL);
rand();
} }
/* /*
@ -147,6 +153,7 @@ void CMeasureCalc::RandomFormulaReplace()
while(loc > -1) while(loc > -1)
{ {
int range = (m_HighBound - m_LowBound); int range = (m_HighBound - m_LowBound);
srand((unsigned) rand());
int randNumber = m_LowBound + (range * rand()/(RAND_MAX + 1.0)); int randNumber = m_LowBound + (range * rand()/(RAND_MAX + 1.0));
std::wstring randomNumberString= (L""); std::wstring randomNumberString= (L"");

View File

@ -40,6 +40,7 @@ private:
hqMathParser* m_Parser; hqMathParser* m_Parser;
static hqStrMap* c_VarMap; static hqStrMap* c_VarMap;
static bool c_RandSeeded;
int m_UpdateRandom; int m_UpdateRandom;
int m_LowBound; int m_LowBound;