- commented out streflop from random # generator

This commit is contained in:
Mark Vejvoda
2010-06-01 19:48:35 +00:00
parent c703de994f
commit 57f28913d0
5 changed files with 53 additions and 30 deletions

View File

@@ -268,32 +268,38 @@ void Program::resize(SizeState sizeState){
void Program::setState(ProgramState *programState, bool cleanupOldState) void Program::setState(ProgramState *programState, bool cleanupOldState)
{ {
try { try {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(cleanupOldState == true) { if(cleanupOldState == true) {
delete this->programState; if(this->programState != programState) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete this->programState;
this->programState = NULL;
}
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
this->programState= programState; this->programState= programState;
programState->load(); programState->load();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
programState->init(); programState->init();
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] %d\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
updateTimer.reset(); updateTimer.reset();
updateCameraTimer.reset(); updateCameraTimer.reset();
fpsTimer.reset(); fpsTimer.reset();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] END\n",__FILE__,__FUNCTION__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
catch(const exception &e){ catch(const exception &e){
//exceptionMessage(e); //exceptionMessage(e);
//throw runtime_error(e.what()); //throw runtime_error(e.what());
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
this->showMessage(e.what()); this->showMessage(e.what());
setState(new Intro(this)); setState(new Intro(this));
} }

View File

@@ -251,7 +251,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
//chatManager.init(&console, world.getThisTeamIndex()); //chatManager.init(&console, world.getThisTeamIndex());
chatManager.init(&console, -1); chatManager.init(&console, -1);
publishToMasterserverThread = new SimpleTaskThread(this,0,150); publishToMasterserverThread = new SimpleTaskThread(this,0,50);
publishToMasterserverThread->start(); publishToMasterserverThread->start();
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
@@ -366,6 +366,18 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
saveGameSettingsToFile("lastCustomGamSettings.mgg"); saveGameSettingsToFile("lastCustomGamSettings.mgg");
BaseThread::shutdownAndWait(publishToMasterserverThread); BaseThread::shutdownAndWait(publishToMasterserverThread);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
delete publishToMasterserverThread;
publishToMasterserverThread = NULL;
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
assert(program != NULL);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
program->setState(new Game(program, &gameSettings)); program->setState(new Game(program, &gameSettings));
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);

View File

@@ -1,7 +1,7 @@
// ============================================================== // ==============================================================
// This file is part of Glest Shared Library (www.glest.org) // 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 // You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published // the terms of the GNU General Public License as published
@@ -12,7 +12,7 @@
#ifndef _SHARED_UTIL_RANDOM_H_ #ifndef _SHARED_UTIL_RANDOM_H_
#define _SHARED_UTIL_RANDOM_H_ #define _SHARED_UTIL_RANDOM_H_
#include "math_wrapper.h" //#include "math_wrapper.h"
namespace Shared { namespace Util { namespace Shared { namespace Util {
@@ -28,9 +28,9 @@ private:
private: private:
int lastNumber; int lastNumber;
#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
streflop::RandomState randomState; // streflop::RandomState randomState;
#endif //#endif
public: public:
RandomGen(); RandomGen();

View File

@@ -29,7 +29,9 @@ BaseThread::BaseThread() : Thread() {
} }
BaseThread::~BaseThread() { BaseThread::~BaseThread() {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
shutdownAndWait(); shutdownAndWait();
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
void BaseThread::signalQuit() { void BaseThread::signalQuit() {
@@ -87,17 +89,20 @@ void BaseThread::setRunningStatus(bool value) {
} }
void BaseThread::shutdownAndWait(BaseThread *pThread) { void BaseThread::shutdownAndWait(BaseThread *pThread) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(pThread != NULL && pThread->getRunningStatus() == true) { if(pThread != NULL && pThread->getRunningStatus() == true) {
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
pThread->signalQuit(); pThread->signalQuit();
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 10; ) { for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 10; ) {
if(pThread->getRunningStatus() == false) { if(pThread->getRunningStatus() == false) {
break; 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__);
} }
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
void BaseThread::shutdownAndWait() { void BaseThread::shutdownAndWait() {

View File

@@ -15,21 +15,21 @@ const int RandomGen::b= 150889;
RandomGen::RandomGen(){ RandomGen::RandomGen(){
#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
lastNumber = streflop::RandomInit(0); // streflop // lastNumber = streflop::RandomInit(0); // streflop
#else //#else
lastNumber= 0; lastNumber= 0;
#endif //#endif
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber); //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,lastNumber);
} }
void RandomGen::init(int seed){ void RandomGen::init(int seed){
#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
lastNumber = streflop::RandomInit(seed); // streflop // lastNumber = streflop::RandomInit(seed); // streflop
#else //#else
lastNumber= seed % m; lastNumber= seed % m;
#endif //#endif
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] seed = %d, lastNumber = %d\n",__FILE__,__FUNCTION__,__LINE__,seed,lastNumber); //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){ int RandomGen::randRange(int min, int max){
assert(min<=max); assert(min<=max);
#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
int res = streflop::Random<true, false, float>(min, max); // streflop // int res = streflop::Random<true, false, float>(min, max); // streflop
#else //#else
int diff= max-min; int diff= max-min;
int res= min + static_cast<int>((static_cast<float>(diff+1)*RandomGen::rand()) / m); int res= min + static_cast<int>((static_cast<float>(diff+1)*RandomGen::rand()) / m);
#endif //#endif
assert(res>=min && res<=max); 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); //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){ float RandomGen::randRange(float min, float max){
assert(min<=max); assert(min<=max);
#ifdef USE_STREFLOP //#ifdef USE_STREFLOP
float res = streflop::Random<true, false, float>(min, max, randomState); // streflop // float res = streflop::Random<true, false, float>(min, max, randomState); // streflop
#else //#else
float rand01= static_cast<float>(RandomGen::rand())/(m-1); float rand01= static_cast<float>(RandomGen::rand())/(m-1);
float res= min+((max-min)*rand01); float res= min+((max-min)*rand01);
#endif //#endif
assert(res>=min && res<=max); assert(res>=min && res<=max);