call dfhack.init even in TEXT mode

develop
jj 2014-01-27 14:13:31 +01:00
parent c0d3e9189d
commit 6b6164c099
1 changed files with 20 additions and 3 deletions

@ -811,6 +811,15 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent)
} }
} }
// Load dfhack.init in a dedicated thread (non-interactive console mode)
void fInitthread(void * iodata)
{
IODATA * iod = ((IODATA*) iodata);
Core * core = iod->core;
Console & con = core->getConsole();
core->loadScriptFile(con, "dfhack.init", true);
}
// A thread function... for the interactive console. // A thread function... for the interactive console.
void fIOthread(void * iodata) void fIOthread(void * iodata)
{ {
@ -822,7 +831,7 @@ void fIOthread(void * iodata)
main_history.load("dfhack.history"); main_history.load("dfhack.history");
Console & con = core->getConsole(); Console & con = core->getConsole();
if(plug_mgr == 0 || core == 0) if (plug_mgr == 0)
{ {
con.printerr("Something horrible happened in Core's constructor...\n"); con.printerr("Something horrible happened in Core's constructor...\n");
return; return;
@ -1008,16 +1017,24 @@ bool Core::Init()
IODATA *temp = new IODATA; IODATA *temp = new IODATA;
temp->core = this; temp->core = this;
temp->plug_mgr = plug_mgr; temp->plug_mgr = plug_mgr;
HotkeyMutex = new mutex();
HotkeyCond = new condition_variable();
if (!is_text_mode) if (!is_text_mode)
{ {
cerr << "Starting IO thread.\n"; cerr << "Starting IO thread.\n";
// create IO thread // create IO thread
thread * IO = new thread(fIOthread, (void *) temp); thread * IO = new thread(fIOthread, (void *) temp);
} }
else
{
cerr << "Starting dfhack.init thread.\n";
thread * init = new thread(fInitthread, (void *) temp);
}
cerr << "Starting DF input capture thread.\n"; cerr << "Starting DF input capture thread.\n";
// set up hotkey capture // set up hotkey capture
HotkeyMutex = new mutex();
HotkeyCond = new condition_variable();
thread * HK = new thread(fHKthread, (void *) temp); thread * HK = new thread(fHKthread, (void *) temp);
screen_window = new Windows::top_level_window(); screen_window = new Windows::top_level_window();
screen_window->addChild(new Windows::dfhack_dummy(5,10)); screen_window->addChild(new Windows::dfhack_dummy(5,10));