|
|
@ -5,6 +5,8 @@ local ms = require 'memscan'
|
|
|
|
|
|
|
|
|
|
|
|
local is_known = dfhack.internal.getAddress
|
|
|
|
local is_known = dfhack.internal.getAddress
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local os_type = dfhack.getOSType()
|
|
|
|
|
|
|
|
|
|
|
|
local force_scan = {}
|
|
|
|
local force_scan = {}
|
|
|
|
for _,v in ipairs({...}) do
|
|
|
|
for _,v in ipairs({...}) do
|
|
|
|
force_scan[v] = true
|
|
|
|
force_scan[v] = true
|
|
|
@ -56,6 +58,34 @@ local function validate_offset(name,validator,addr,tname,...)
|
|
|
|
ms.found_offset(name,obj)
|
|
|
|
ms.found_offset(name,obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function zoomed_searcher(startn, end_or_sz)
|
|
|
|
|
|
|
|
if force_scan.nozoom then
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local sv = is_known(startn)
|
|
|
|
|
|
|
|
if not sv then
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local ev
|
|
|
|
|
|
|
|
if type(end_or_sz) == 'number' then
|
|
|
|
|
|
|
|
ev = sv + end_or_sz
|
|
|
|
|
|
|
|
if end_or_sz < 0 then
|
|
|
|
|
|
|
|
sv, ev = ev, sv
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
ev = is_known(end_or_sz)
|
|
|
|
|
|
|
|
if not ev then
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
sv = sv - (sv % 4)
|
|
|
|
|
|
|
|
ev = ev + 3
|
|
|
|
|
|
|
|
ev = ev - (ev % 4)
|
|
|
|
|
|
|
|
if data:contains_range(sv, ev-sv) then
|
|
|
|
|
|
|
|
return ms.DiffSearcher.new(ms.MemoryArea.new(sv,ev))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local function exec_finder(finder, names)
|
|
|
|
local function exec_finder(finder, names)
|
|
|
|
if type(names) ~= 'table' then
|
|
|
|
if type(names) ~= 'table' then
|
|
|
|
names = { names }
|
|
|
|
names = { names }
|
|
|
@ -80,7 +110,8 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
local ordinal_names = {
|
|
|
|
local ordinal_names = {
|
|
|
|
[0] = '1st entry',
|
|
|
|
[0] = '1st entry',
|
|
|
|
[1] = '2nd entry'
|
|
|
|
[1] = '2nd entry',
|
|
|
|
|
|
|
|
[2] = '3rd entry'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setmetatable(ordinal_names, {
|
|
|
|
setmetatable(ordinal_names, {
|
|
|
|
__index = function(self,idx) return (idx+1)..'th entry' end
|
|
|
|
__index = function(self,idx) return (idx+1)..'th entry' end
|
|
|
@ -578,6 +609,124 @@ NOTE: If not done after first 3-4 steps, resize the game window.]],
|
|
|
|
ms.found_offset('window_z', addr)
|
|
|
|
ms.found_offset('window_z', addr)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
-- cur_year
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function find_cur_year()
|
|
|
|
|
|
|
|
local zone
|
|
|
|
|
|
|
|
if os_type == 'windows' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('formation_next_id', 32)
|
|
|
|
|
|
|
|
elseif os_type == 'darwin' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('cursor', -32)
|
|
|
|
|
|
|
|
elseif os_type == 'linux' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('ui_building_assign_type', -512)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if not zone then
|
|
|
|
|
|
|
|
dfhack.printerr('Cannot search for cur_year - prerequisites missing.')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local yvalue = utils.prompt_input('Please enter current in-game year: ', utils.check_number)
|
|
|
|
|
|
|
|
local idx, addr = zone.area.int32_t:find_one{yvalue}
|
|
|
|
|
|
|
|
if idx then
|
|
|
|
|
|
|
|
ms.found_offset('cur_year', addr)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dfhack.printerr('Could not find cur_year')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
-- cur_year_tick
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function find_cur_year_tick()
|
|
|
|
|
|
|
|
local zone
|
|
|
|
|
|
|
|
if os_type == 'windows' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('artifact_next_id', -32)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
zone = zoomed_searcher('cur_year', 128)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
if not zone then
|
|
|
|
|
|
|
|
dfhack.printerr('Cannot search for cur_year_tick - prerequisites missing.')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local addr = zone:find_counter([[
|
|
|
|
|
|
|
|
Searching for cur_year_tick. Please exit to main dwarfmode
|
|
|
|
|
|
|
|
menu, then do as instructed below:]],
|
|
|
|
|
|
|
|
'int32_t', 1,
|
|
|
|
|
|
|
|
"Please press '.' to step the game one frame."
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ms.found_offset('cur_year_tick', addr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
-- process_jobs
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function get_process_zone()
|
|
|
|
|
|
|
|
if os_type == 'windows' then
|
|
|
|
|
|
|
|
return zoomed_searcher('ui_workshop_job_cursor', 'ui_building_in_resize')
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
return zoomed_searcher('cur_year', 'cur_year_tick')
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function find_process_jobs()
|
|
|
|
|
|
|
|
local zone = get_process_zone() or searcher
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local addr = zone:find_menu_cursor([[
|
|
|
|
|
|
|
|
Searching for process_jobs. Please do as instructed below:]],
|
|
|
|
|
|
|
|
'int8_t',
|
|
|
|
|
|
|
|
{ 1, 0 },
|
|
|
|
|
|
|
|
{ [1] = 'designate a building to be constructed, e.g a bed',
|
|
|
|
|
|
|
|
[0] = 'step or unpause the game to reset the flag' }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ms.found_offset('process_jobs', addr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
-- process_dig
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function find_process_dig()
|
|
|
|
|
|
|
|
local zone = get_process_zone() or searcher
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local addr = zone:find_menu_cursor([[
|
|
|
|
|
|
|
|
Searching for process_dig. Please do as instructed below:]],
|
|
|
|
|
|
|
|
'int8_t',
|
|
|
|
|
|
|
|
{ 1, 0 },
|
|
|
|
|
|
|
|
{ [1] = 'designate a tile to be mined out',
|
|
|
|
|
|
|
|
[0] = 'step or unpause the game to reset the flag' }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ms.found_offset('process_dig', addr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
-- pause_state
|
|
|
|
|
|
|
|
--
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function find_pause_state()
|
|
|
|
|
|
|
|
local zone
|
|
|
|
|
|
|
|
if os_type == 'linux' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('ui_look_cursor', 32)
|
|
|
|
|
|
|
|
elseif os_type == 'windows' then
|
|
|
|
|
|
|
|
zone = zoomed_searcher('ui_workshop_job_cursor', 64)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
zone = zone or searcher
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local addr = zone:find_menu_cursor([[
|
|
|
|
|
|
|
|
Searching for pause_state. Please do as instructed below:]],
|
|
|
|
|
|
|
|
'int8_t',
|
|
|
|
|
|
|
|
{ 1, 0 },
|
|
|
|
|
|
|
|
{ [1] = 'PAUSE the game',
|
|
|
|
|
|
|
|
[0] = 'UNPAUSE the game' }
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
ms.found_offset('pause_state', addr)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- MAIN FLOW
|
|
|
|
-- MAIN FLOW
|
|
|
|
--
|
|
|
|
--
|
|
|
@ -611,5 +760,13 @@ exec_finder(find_window_x, 'window_x')
|
|
|
|
exec_finder(find_window_y, 'window_y')
|
|
|
|
exec_finder(find_window_y, 'window_y')
|
|
|
|
exec_finder(find_window_z, 'window_z')
|
|
|
|
exec_finder(find_window_z, 'window_z')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print('\nUnpausing globals:\n')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exec_finder(find_cur_year, 'cur_year')
|
|
|
|
|
|
|
|
exec_finder(find_cur_year_tick, 'cur_year_tick')
|
|
|
|
|
|
|
|
exec_finder(find_process_jobs, 'process_jobs')
|
|
|
|
|
|
|
|
exec_finder(find_process_dig, 'process_dig')
|
|
|
|
|
|
|
|
exec_finder(find_pause_state, 'pause_state')
|
|
|
|
|
|
|
|
|
|
|
|
print('\nDone. Now add newly-found globals to symbols.xml.')
|
|
|
|
print('\nDone. Now add newly-found globals to symbols.xml.')
|
|
|
|
searcher:reset()
|
|
|
|
searcher:reset()
|
|
|
|