From d06118ad8ef99927b31487fec2f6f7cb5a761bd3 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 20 May 2023 16:00:59 -0700 Subject: [PATCH] support recording stockpiles in blueprints --- docs/changelog.txt | 3 ++- plugins/blueprint.cpp | 26 +++++++++----------------- plugins/lua/blueprint.lua | 12 ++++++------ plugins/lua/stockpiles.lua | 4 ++-- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 2e5b482f0..df00cf34a 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -55,7 +55,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: - Terminal console no longer appears in front of the game window on startup - `gui/control-panel`: new preference for whether filters in lists search for substrings in the middle of words (e.g. if set to true, then "ee" will match "steel") - `gui/design`: Improved performance for drawing shapes -- Dreamfort: improve traffic patterns throughout the fortress (stockpiles and zones are still not working, pending updates in `quickfort`) +- Dreamfort: improve traffic patterns throughout the fortress +- `gui/blueprint`: recording of stockpile layouts and categories is now supported. note that detailed stockpile configurations will *not* be saved (yet) - Core: For debugging purposes, you can now pass ``--disable-dfhack`` on the Dwarf Fortress commandline or specify ``DFHACK_DISABLE=1`` in the environment to disable DFHack for the current session. - `overlay`: added links to the quickstart guide and the control panel on the DF title screen - `gui/autodump`: fort-mode keybinding: Ctrl-H diff --git a/plugins/blueprint.cpp b/plugins/blueprint.cpp index 39847935d..d5a06cc5c 100644 --- a/plugins/blueprint.cpp +++ b/plugins/blueprint.cpp @@ -99,9 +99,9 @@ struct blueprint_options { bool construct = false; bool build = false; bool place = false; - bool zone = false; - bool query = false; - bool rooms = false; + // bool zone = false; + // bool query = false; + // bool rooms = false; static struct_identity _identity; }; @@ -125,9 +125,9 @@ static const struct_field_info blueprint_options_fields[] = { { struct_field_info::PRIMITIVE, "construct", offsetof(blueprint_options, construct), &df::identity_traits::identity, 0, 0 }, { struct_field_info::PRIMITIVE, "build", offsetof(blueprint_options, build), &df::identity_traits::identity, 0, 0 }, { struct_field_info::PRIMITIVE, "place", offsetof(blueprint_options, place), &df::identity_traits::identity, 0, 0 }, - { struct_field_info::PRIMITIVE, "zone", offsetof(blueprint_options, zone), &df::identity_traits::identity, 0, 0 }, - { struct_field_info::PRIMITIVE, "query", offsetof(blueprint_options, query), &df::identity_traits::identity, 0, 0 }, - { struct_field_info::PRIMITIVE, "rooms", offsetof(blueprint_options, rooms), &df::identity_traits::identity, 0, 0 }, + // { struct_field_info::PRIMITIVE, "zone", offsetof(blueprint_options, zone), &df::identity_traits::identity, 0, 0 }, + // { struct_field_info::PRIMITIVE, "query", offsetof(blueprint_options, query), &df::identity_traits::identity, 0, 0 }, + // { struct_field_info::PRIMITIVE, "rooms", offsetof(blueprint_options, rooms), &df::identity_traits::identity, 0, 0 }, { struct_field_info::END } }; struct_identity blueprint_options::_identity(sizeof(blueprint_options), &df::allocator_fn, NULL, "blueprint_options", NULL, blueprint_options_fields); @@ -855,7 +855,6 @@ static const char * get_tile_build(const df::coord &pos, return add_expansion_syntax(ctx, keys); } -/* TODO: understand how this changes for v50 static const char * get_place_keys(const tile_context &ctx) { df::building_stockpilest* sp = virtual_cast(ctx.b); @@ -908,6 +907,7 @@ static const char * get_tile_place(const df::coord &pos, return add_expansion_syntax(ctx, get_place_keys(ctx)); } +/* TODO: understand how this changes for v50 static bool hospital_maximums_eq(const df::hospital_supplies &a, const df::hospital_supplies &b) { return a.max_thread == b.max_thread && @@ -1333,23 +1333,15 @@ static bool do_transform(color_ostream &out, get_tile_construct, ensure_building); add_processor(processors, opts, "build", "build", opts.build, get_tile_build, ensure_building); -/* TODO: understand how this changes for v50 add_processor(processors, opts, "place", "place", opts.place, get_tile_place, ensure_building); +/* TODO: understand how this changes for v50 add_processor(processors, opts, "zone", "zone", opts.zone, get_tile_zone); add_processor(processors, opts, "query", "query", opts.query, get_tile_query, ensure_building); add_processor(processors, opts, "query", "rooms", opts.rooms, get_tile_rooms, ensure_building); -*/ if (opts.place) - out.printerr("'place' blueprints are not yet supported for the current version of DF\n"); - if (opts.zone) - out.printerr("'zone' blueprints are not yet supported for the current version of DF\n"); - if (opts.query) - out.printerr("'query' blueprints are not yet supported for the current version of DF\n"); - if (opts.rooms) - out.printerr("'rooms' blueprints are not yet supported for the current version of DF\n"); - +*/ if (processors.empty()) { out.printerr("no phases requested! nothing to do!\n"); return false; diff --git a/plugins/lua/blueprint.lua b/plugins/lua/blueprint.lua index 375cfc1b4..57dee31fc 100644 --- a/plugins/lua/blueprint.lua +++ b/plugins/lua/blueprint.lua @@ -9,17 +9,17 @@ local valid_phase_list = { 'construct', 'build', 'place', - 'zone', - 'query', - 'rooms', + -- 'zone', + -- 'query', + -- 'rooms', } valid_phases = utils.invert(valid_phase_list) local meta_phase_list = { 'build', 'place', - 'zone', - 'query', + -- 'zone', + -- 'query', } meta_phases = utils.invert(meta_phase_list) @@ -167,7 +167,7 @@ end function parse_commandline(opts, ...) local positionals = process_args(opts, {...}) - if opts.help then return end + if not positionals or opts.help then return end local width, height = tonumber(positionals[1]), tonumber(positionals[2]) if is_bad_dim(width) or is_bad_dim(height) then diff --git a/plugins/lua/stockpiles.lua b/plugins/lua/stockpiles.lua index 9e17cbe2b..379f2185a 100644 --- a/plugins/lua/stockpiles.lua +++ b/plugins/lua/stockpiles.lua @@ -81,7 +81,7 @@ local included_elements = { types=8, } -local function export_stockpile(name, opts) +function export_stockpile(name, opts) assert_safe_name(name) name = STOCKPILES_DIR .. '/' .. name @@ -101,7 +101,7 @@ local function export_stockpile(name, opts) stockpiles_export(name, get_sp_id(opts), includedElements) end -local function import_stockpile(name, opts) +function import_stockpile(name, opts) local is_library = false if name:startswith('library/') then name = name:sub(9)