Fix some crashes when running without globals and update structures.

develop
Alexander Gavrilov 2014-07-24 23:10:37 +04:00
parent 34ce7f61de
commit 4902c577b3
5 changed files with 23 additions and 3 deletions

@ -841,6 +841,12 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent)
static void run_dfhack_init(color_ostream &out, Core *core) static void run_dfhack_init(color_ostream &out, Core *core)
{ {
if (!df::global::world || !df::global::ui || !df::global::gview)
{
out.printerr("Key globals are missing, skipping loading dfhack.init.\n");
return;
}
if (!core->loadScriptFile(out, "dfhack.init", true)) if (!core->loadScriptFile(out, "dfhack.init", true))
{ {
core->runCommand(out, "gui/no-dfhack-init"); core->runCommand(out, "gui/no-dfhack-init");

@ -268,7 +268,7 @@ function found_offset(name,val)
if cval then if cval then
if cval ~= val then if cval ~= val then
error(string.format('Mismatch with the current value: %x',val)) error(string.format('Mismatch with the current value: %x != %x',val,cval))
end end
else else
dfhack.internal.setAddress(name, val) dfhack.internal.setAddress(name, val)

@ -1310,6 +1310,9 @@ void Gui::showAutoAnnouncement(
df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed) df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed)
{ {
if (!gview)
return NULL;
df::viewscreen * ws = &gview->view; df::viewscreen * ws = &gview->view;
while (ws && ws->child) while (ws && ws->child)
ws = ws->child; ws = ws->child;

@ -1 +1 @@
Subproject commit e8e415684e9d8a2fdf1c69f5283889f6a2595157 Subproject commit 996c5190247607a39da51b8b412fe11ed890d842

@ -4,6 +4,17 @@ local utils = require 'utils'
local ms = require 'memscan' local ms = require 'memscan'
local gui = require 'gui' local gui = require 'gui'
--[[
Arguments:
* global names to force finding them
* 'all' to force all globals
* 'nofeed' to block automated fake input searches
* 'nozoom' to disable neighboring object heuristics
]]
local is_known = dfhack.internal.getAddress local is_known = dfhack.internal.getAddress
local os_type = dfhack.getOSType() local os_type = dfhack.getOSType()
@ -1415,7 +1426,7 @@ local function find_process_jobs()
Searching for process_jobs. Please do as instructed below:]], Searching for process_jobs. Please do as instructed below:]],
'int8_t', 'int8_t',
{ 1, 0 }, { 1, 0 },
{ [1] = 'designate a building to be constructed, e.g a bed', { [1] = 'designate a building to be constructed, e.g a bed or a wall',
[0] = 'step or unpause the game to reset the flag' } [0] = 'step or unpause the game to reset the flag' }
) )
ms.found_offset('process_jobs', addr) ms.found_offset('process_jobs', addr)