mirror of
https://github.com/glest/glest-source.git
synced 2025-08-15 12:54:01 +02:00
- commented out streflop from random # generator
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
||||
// Copyright (C) 2001-2008 Martio Figueroa
|
||||
//
|
||||
// You can redistribute this code and/or modify it under
|
||||
// the terms of the GNU General Public License as published
|
||||
@@ -12,7 +12,7 @@
|
||||
#ifndef _SHARED_UTIL_RANDOM_H_
|
||||
#define _SHARED_UTIL_RANDOM_H_
|
||||
|
||||
#include "math_wrapper.h"
|
||||
//#include "math_wrapper.h"
|
||||
|
||||
namespace Shared { namespace Util {
|
||||
|
||||
@@ -28,9 +28,9 @@ private:
|
||||
|
||||
private:
|
||||
int lastNumber;
|
||||
#ifdef USE_STREFLOP
|
||||
streflop::RandomState randomState;
|
||||
#endif
|
||||
//#ifdef USE_STREFLOP
|
||||
// streflop::RandomState randomState;
|
||||
//#endif
|
||||
|
||||
public:
|
||||
RandomGen();
|
||||
|
@@ -29,7 +29,9 @@ BaseThread::BaseThread() : Thread() {
|
||||
}
|
||||
|
||||
BaseThread::~BaseThread() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
shutdownAndWait();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void BaseThread::signalQuit() {
|
||||
@@ -87,17 +89,20 @@ void BaseThread::setRunningStatus(bool value) {
|
||||
}
|
||||
|
||||
void BaseThread::shutdownAndWait(BaseThread *pThread) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(pThread != NULL && pThread->getRunningStatus() == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
pThread->signalQuit();
|
||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 10; ) {
|
||||
if(pThread->getRunningStatus() == false) {
|
||||
break;
|
||||
}
|
||||
sleep(50);
|
||||
sleep(10);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void BaseThread::shutdownAndWait() {
|
||||
|
@@ -15,21 +15,21 @@ const int RandomGen::b= 150889;
|
||||
|
||||
RandomGen::RandomGen(){
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
lastNumber = streflop::RandomInit(0); // streflop
|
||||
#else
|
||||
//#ifdef USE_STREFLOP
|
||||
// lastNumber = streflop::RandomInit(0); // streflop
|
||||
//#else
|
||||
lastNumber= 0;
|
||||
#endif
|
||||
//#endif
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
|
||||
}
|
||||
|
||||
void RandomGen::init(int seed){
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
lastNumber = streflop::RandomInit(seed); // streflop
|
||||
#else
|
||||
//#ifdef USE_STREFLOP
|
||||
// lastNumber = streflop::RandomInit(seed); // streflop
|
||||
//#else
|
||||
lastNumber= seed % m;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] seed = %d, lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,seed,lastNumber);
|
||||
}
|
||||
@@ -47,12 +47,12 @@ int RandomGen::rand() {
|
||||
int RandomGen::randRange(int min, int max){
|
||||
assert(min<=max);
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
int res = streflop::Random<true, false, float>(min, max); // streflop
|
||||
#else
|
||||
//#ifdef USE_STREFLOP
|
||||
// int res = streflop::Random<true, false, float>(min, max); // streflop
|
||||
//#else
|
||||
int diff= max-min;
|
||||
int res= min + static_cast<int>((static_cast<float>(diff+1)*RandomGen::rand()) / m);
|
||||
#endif
|
||||
//#endif
|
||||
assert(res>=min && res<=max);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] min = %d, max = %d, res = %d\n",__FILE__,__FUNCTION__,__LINE__,min,max,res);
|
||||
@@ -63,12 +63,12 @@ int RandomGen::randRange(int min, int max){
|
||||
float RandomGen::randRange(float min, float max){
|
||||
assert(min<=max);
|
||||
|
||||
#ifdef USE_STREFLOP
|
||||
float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
|
||||
#else
|
||||
//#ifdef USE_STREFLOP
|
||||
// float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
|
||||
//#else
|
||||
float rand01= static_cast<float>(RandomGen::rand())/(m-1);
|
||||
float res= min+((max-min)*rand01);
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
assert(res>=min && res<=max);
|
||||
|
||||
|
Reference in New Issue
Block a user