- commented out streflop from random # generator
This commit is contained in:
parent
c703de994f
commit
57f28913d0
|
@ -268,32 +268,38 @@ void Program::resize(SizeState sizeState){
|
|||
void Program::setState(ProgramState *programState, bool cleanupOldState)
|
||||
{
|
||||
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) {
|
||||
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;
|
||||
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();
|
||||
|
||||
//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();
|
||||
updateCameraTimer.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){
|
||||
//exceptionMessage(e);
|
||||
//throw runtime_error(e.what());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s LineL: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
this->showMessage(e.what());
|
||||
setState(new Intro(this));
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
//chatManager.init(&console, world.getThisTeamIndex());
|
||||
chatManager.init(&console, -1);
|
||||
|
||||
publishToMasterserverThread = new SimpleTaskThread(this,0,150);
|
||||
publishToMasterserverThread = new SimpleTaskThread(this,0,50);
|
||||
publishToMasterserverThread->start();
|
||||
|
||||
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");
|
||||
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));
|
||||
}
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// ==============================================================
|
||||
// This file is part of Glest Shared Library (www.glest.org)
|
||||
//
|
||||
// Copyright (C) 2001-2008 Martiñ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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user