Add ui_menu_width finder, tweak instructions, and add a case for win exe.

develop
Alexander Gavrilov 2012-06-18 21:11:54 +04:00
parent a6bfc67038
commit bd5b675fa5
2 changed files with 68 additions and 53 deletions

@ -208,7 +208,8 @@ local function find_data_segment()
end
elseif mem.read and mem.write
and (string.match(mem.name,'/dwarfort%.exe$')
or string.match(mem.name,'/Dwarf_Fortress$'))
or string.match(mem.name,'/Dwarf_Fortress$')
or string.match(mem.name,'Dwarf Fortress%.exe'))
then
data_start = mem.start_addr
data_end = mem.end_addr

@ -20,10 +20,14 @@ MAKE IT RUN CORRECTLY if any data structures
changed, thus possibly leading to CRASHES AND/OR
PERMANENT SAVE CORRUPTION.
This script should be initially started immediately
after loading the game, WITHOUT first loading a world.
It expects vanilla game configuration, without any
custom tilesets or init file changes.
Finding the first few globals requires this script to be
started immediately after loading the game, WITHOUT
first loading a world.
The script expects vanilla game configuration, without
any custom tilesets or init file changes. Never unpause
the game unless instructed. When done, quit the game
without saving using 'die'.
]]
if not utils.prompt_yes_no('Proceed?') then
@ -140,8 +144,6 @@ local function find_cursor()
return false
end
exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' })
--
-- Announcements
--
@ -158,8 +160,6 @@ local function find_announcements()
dfhack.printerr('Could not find announcements.')
end
exec_finder(find_announcements, 'announcements')
--
-- d_init
--
@ -198,8 +198,6 @@ local function find_d_init()
dfhack.printerr('Could not find d_init')
end
exec_finder(find_d_init, 'd_init')
--
-- gview
--
@ -220,8 +218,6 @@ local function find_gview()
dfhack.printerr('Could not find gview')
end
exec_finder(find_gview, 'gview')
--
-- World
--
@ -257,8 +253,6 @@ menu, and select different types as instructed below:]],
validate_offset('world', is_valid_world, addr, df.world, 'selected_stockpile_type')
end
exec_finder(find_world, 'world')
--
-- UI
--
@ -291,8 +285,6 @@ menu, and switch modes as instructed below:]],
validate_offset('ui', is_valid_ui, addr, df.ui, 'main', 'mode')
end
exec_finder(find_ui, 'ui')
--
-- ui_sidebar_menus
--
@ -319,9 +311,9 @@ end
local function find_ui_sidebar_menus()
local addr = searcher:find_menu_cursor([[
Searching for ui_sidebar_menus. Please open the add job
ui of Mason, Craftsdwarfs, or Carpenters workshop, and
select entries in the list:]],
Searching for ui_sidebar_menus. Please switch to 'q' mode,
select a Mason, Craftsdwarfs, or Carpenters workshop, open
the Add Job menu, and move the cursor within:]],
'int32_t',
{ 0, 1, 2, 3, 4, 5, 6 },
ordinal_names
@ -330,8 +322,6 @@ select entries in the list:]],
addr, df.ui_sidebar_menus, 'workshop_job', 'cursor')
end
exec_finder(find_ui_sidebar_menus, 'ui_sidebar_menus')
--
-- ui_build_selector
--
@ -366,7 +356,25 @@ number, so when it shows "Min (5000df", it means 50000:]],
addr, df.ui_build_selector, 'plate_info', 'unit_min')
end
exec_finder(find_ui_build_selector, 'ui_build_selector')
--
-- ui_menu_width
--
local function find_ui_menu_width()
local addr = searcher:find_menu_cursor([[
Searching for ui_menu_width. Please exit to the main
dwarfmode menu, then use Tab to do as instructed below:]],
'int8_t',
{ 2, 3, 1 },
{ [2] = 'switch to the most usual [mapmap][menu] layout',
[3] = 'hide the menu completely',
[1] = 'switch to the default [map][menu][map] layout' }
)
ms.found_offset('ui_menu_width', addr)
-- NOTE: Assume that the vars are adjacent, as always
ms.found_offset('ui_area_map_width', addr+1)
end
--
-- ui_selected_unit
@ -395,8 +403,6 @@ into the prompts below:]],
ms.found_offset('ui_selected_unit', addr)
end
exec_finder(find_ui_selected_unit, 'ui_selected_unit')
--
-- ui_unit_view_mode
--
@ -412,8 +418,6 @@ with 'v', switch the pages as requested:]],
ms.found_offset('ui_unit_view_mode', addr)
end
exec_finder(find_ui_unit_view_mode, 'ui_unit_view_mode')
--
-- ui_look_cursor
--
@ -434,8 +438,6 @@ and select list entries as instructed:]],
ms.found_offset('ui_look_cursor', addr)
end
exec_finder(find_ui_look_cursor, 'ui_look_cursor')
--
-- ui_building_item_cursor
--
@ -456,8 +458,6 @@ with many contained items, and select as instructed:]],
ms.found_offset('ui_building_item_cursor', addr)
end
exec_finder(find_ui_building_item_cursor, 'ui_building_item_cursor')
--
-- ui_workshop_in_add
--
@ -468,7 +468,7 @@ Searching for ui_workshop_in_add. Please activate the 'q'
mode, find a workshop without jobs (or delete jobs),
and do as instructed below.
NOTE: After first 3 steps resize the game window.]],
NOTE: If not done after first 3-4 steps, resize the game window.]],
'int8_t',
{ 1, 0 },
{ [1] = 'enter the add job menu',
@ -477,8 +477,6 @@ NOTE: After first 3 steps resize the game window.]],
ms.found_offset('ui_workshop_in_add', addr)
end
exec_finder(find_ui_workshop_in_add, 'ui_workshop_in_add')
--
-- ui_workshop_job_cursor
--
@ -498,8 +496,6 @@ mode, find a workshop with many jobs, and select as instructed:]],
ms.found_offset('ui_workshop_job_cursor', addr)
end
exec_finder(find_ui_workshop_job_cursor, 'ui_workshop_job_cursor')
--
-- ui_building_in_assign
--
@ -510,7 +506,7 @@ Searching for ui_building_in_assign. Please activate
the 'q' mode, select a room building (e.g. a bedroom)
and do as instructed below.
NOTE: After first 3 steps resize the game window.]],
NOTE: If not done after first 3-4 steps, resize the game window.]],
'int8_t',
{ 1, 0 },
{ [1] = 'enter the Assign owner menu',
@ -519,8 +515,6 @@ NOTE: After first 3 steps resize the game window.]],
ms.found_offset('ui_building_in_assign', addr)
end
exec_finder(find_ui_building_in_assign, 'ui_building_in_assign')
--
-- ui_building_in_resize
--
@ -531,7 +525,7 @@ Searching for ui_building_in_resize. Please activate
the 'q' mode, select a room building (e.g. a bedroom)
and do as instructed below.
NOTE: After first 3 steps resize the game window.]],
NOTE: If not done after first 3-4 steps, resize the game window.]],
'int8_t',
{ 1, 0 },
{ [1] = 'enter the Resize room mode',
@ -540,9 +534,6 @@ NOTE: After first 3 steps resize the game window.]],
ms.found_offset('ui_building_in_resize', addr)
end
exec_finder(find_ui_building_in_resize, 'ui_building_in_resize')
--
-- window_x
--
@ -557,8 +548,6 @@ scroll to the LEFT edge, then do as instructed:]],
ms.found_offset('window_x', addr)
end
exec_finder(find_window_x, 'window_x')
--
-- window_y
--
@ -573,8 +562,6 @@ scroll to the TOP edge, then do as instructed:]],
ms.found_offset('window_y', addr)
end
exec_finder(find_window_y, 'window_y')
--
-- window_z
--
@ -582,20 +569,47 @@ exec_finder(find_window_y, 'window_y')
local function find_window_z()
local addr = searcher:find_counter([[
Searching for window_z. Please exit to main dwarfmode menu,
scroll to ground level, then do as instructed below.
scroll to a Z level near surface, then do as instructed below.
NOTE: After first 3 steps resize the game window.]],
NOTE: If not done after first 3-4 steps, resize the game window.]],
'int32_t', -1,
"Please press '>' to scroll one Z level down."
)
ms.found_offset('window_z', addr)
end
exec_finder(find_window_z, 'window_z')
--
-- THE END
-- MAIN FLOW
--
print('Done.')
print('\nInitial globals (need title screen):\n')
exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' })
exec_finder(find_announcements, 'announcements')
exec_finder(find_d_init, 'd_init')
exec_finder(find_gview, 'gview')
print('\nCompound globals (need loaded world):\n')
exec_finder(find_world, 'world')
exec_finder(find_ui, 'ui')
exec_finder(find_ui_sidebar_menus, 'ui_sidebar_menus')
exec_finder(find_ui_build_selector, 'ui_build_selector')
print('\nPrimitive globals:\n')
exec_finder(find_ui_menu_width, { 'ui_menu_width', 'ui_area_map_width' })
exec_finder(find_ui_selected_unit, 'ui_selected_unit')
exec_finder(find_ui_unit_view_mode, 'ui_unit_view_mode')
exec_finder(find_ui_look_cursor, 'ui_look_cursor')
exec_finder(find_ui_building_item_cursor, 'ui_building_item_cursor')
exec_finder(find_ui_workshop_in_add, 'ui_workshop_in_add')
exec_finder(find_ui_workshop_job_cursor, 'ui_workshop_job_cursor')
exec_finder(find_ui_building_in_assign, 'ui_building_in_assign')
exec_finder(find_ui_building_in_resize, 'ui_building_in_resize')
exec_finder(find_window_x, 'window_x')
exec_finder(find_window_y, 'window_y')
exec_finder(find_window_z, 'window_z')
print('\nDone. Now add newly-found globals to symbols.xml.')
searcher:reset()