Removed some silly data races from using cerr...

develop
Petr Mrázek 2011-07-11 23:07:42 +02:00
parent 4015586d89
commit fa4d2d9b2e
3 changed files with 8 additions and 16 deletions

@ -1,7 +1,7 @@
# main project file. use it from a build sub-folder, see COMPILE for details
## some generic CMake magic
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(dfhack)
SET(CMAKE_MODULE_PATH

@ -323,17 +323,11 @@ void Core::Resume()
}
// should always be from simulation thread!
static bool flip2 = false;
int Core::Update()
{
if(!started) Init();
if(errorstate)
return -1;
if(!flip2)
{
std::cerr << "Update from Thread " << SDL_ThreadID() << std::endl;
flip2 = true;
}
// notify all the plugins that a game tick is finished
plug_mgr->OnUpdate();
@ -380,16 +374,10 @@ int Core::Shutdown ( void )
return -1;
}
static bool flip3 = 0;
int Core::SDL_Event(SDL::Event* ev, int orig_return)
{
// do NOT process events before we are ready.
if(!started) return orig_return;
if(!flip3)
{
std::cerr << "Event from Thread " << SDL_ThreadID() << std::endl;
flip3 = true;
}
if(!ev)
return orig_return;
if(ev && ev->type == SDL::ET_KEYDOWN || ev->type == SDL::ET_KEYUP)
@ -413,7 +401,6 @@ int Core::SDL_Event(SDL::Event* ev, int orig_return)
return orig_return;
else
{
std::cerr << "Hotkey " << idx << " triggered. Thread " << SDL_ThreadID() << std::endl;
t_hotkey & hotkey = (*g->hotkeys)[idx];
setHotkeyCmd(hotkey.name);
}

@ -76,9 +76,12 @@ bool inited = false;
DFhackCExport int SDL_NumJoysticks(void)
{
inited = true;
DFHack::Core & c = DFHack::Core::getInstance();
return c.Update();
// the 'inited' variable should be normally protected by a lock. It isn't
int ret = c.Update();
if(ret == 0)
inited = true;
return ret;
}
// ptr to the real functions
@ -162,6 +165,8 @@ DFhackCExport int SDL_PollEvent(SDL::Event* event)
// only send events to Core after we get first SDL_NumJoysticks call
// DF event loop is possibly polling for SDL events before things get inited properly
// SDL handles it. We don't, because we use some other parts of SDL too.
// possible data race. whatever. it's a flag, we don't mind all that much
if(inited && event != 0)
{
DFHack::Core & c = DFHack::Core::getInstance();