From 4902c577b360fe1b77259d6066ee68a0148c7378 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Thu, 24 Jul 2014 23:10:37 +0400 Subject: [PATCH] Fix some crashes when running without globals and update structures. --- library/Core.cpp | 6 ++++++ library/lua/memscan.lua | 2 +- library/modules/Gui.cpp | 3 +++ library/xml | 2 +- scripts/devel/find-offsets.lua | 13 ++++++++++++- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index d2e2d347e..6cc47292f 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -841,6 +841,12 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent) 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)) { core->runCommand(out, "gui/no-dfhack-init"); diff --git a/library/lua/memscan.lua b/library/lua/memscan.lua index ce7d2f1e5..00a80cc48 100644 --- a/library/lua/memscan.lua +++ b/library/lua/memscan.lua @@ -268,7 +268,7 @@ function found_offset(name,val) if cval 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 else dfhack.internal.setAddress(name, val) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index bb9ce6676..fedb95954 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -1310,6 +1310,9 @@ void Gui::showAutoAnnouncement( df::viewscreen *Gui::getCurViewscreen(bool skip_dismissed) { + if (!gview) + return NULL; + df::viewscreen * ws = &gview->view; while (ws && ws->child) ws = ws->child; diff --git a/library/xml b/library/xml index e8e415684..996c51902 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit e8e415684e9d8a2fdf1c69f5283889f6a2595157 +Subproject commit 996c5190247607a39da51b8b412fe11ed890d842 diff --git a/scripts/devel/find-offsets.lua b/scripts/devel/find-offsets.lua index 505400ffd..e907fe5de 100644 --- a/scripts/devel/find-offsets.lua +++ b/scripts/devel/find-offsets.lua @@ -4,6 +4,17 @@ local utils = require 'utils' local ms = require 'memscan' 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 os_type = dfhack.getOSType() @@ -1415,7 +1426,7 @@ local function find_process_jobs() Searching for process_jobs. Please do as instructed below:]], 'int8_t', { 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' } ) ms.found_offset('process_jobs', addr)