From 6b6164c0995828d60915bf068cfcedecf5d48a51 Mon Sep 17 00:00:00 2001 From: jj Date: Mon, 27 Jan 2014 14:13:31 +0100 Subject: [PATCH] call dfhack.init even in TEXT mode --- library/Core.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index fad01e4b2..0f0b18ae7 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -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. void fIOthread(void * iodata) { @@ -822,7 +831,7 @@ void fIOthread(void * iodata) main_history.load("dfhack.history"); Console & con = core->getConsole(); - if(plug_mgr == 0 || core == 0) + if (plug_mgr == 0) { con.printerr("Something horrible happened in Core's constructor...\n"); return; @@ -1008,16 +1017,24 @@ bool Core::Init() IODATA *temp = new IODATA; temp->core = this; temp->plug_mgr = plug_mgr; + + HotkeyMutex = new mutex(); + HotkeyCond = new condition_variable(); + if (!is_text_mode) { cerr << "Starting IO thread.\n"; // create IO thread 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"; // set up hotkey capture - HotkeyMutex = new mutex(); - HotkeyCond = new condition_variable(); thread * HK = new thread(fHKthread, (void *) temp); screen_window = new Windows::top_level_window(); screen_window->addChild(new Windows::dfhack_dummy(5,10));