From 27c0c41536a8683d31956f036e9c1c27f1a31e59 Mon Sep 17 00:00:00 2001 From: myk002 Date: Sat, 2 Oct 2021 12:52:43 -0700 Subject: [PATCH] only create empty blueprints on explicit request and use the new functionality in the ecosystem tests, which simplifies the blueprint commandline creation --- plugins/blueprint.cpp | 25 +++++++++++++++---------- test/quickfort/ecosystem.lua | 12 +++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/plugins/blueprint.cpp b/plugins/blueprint.cpp index 04ecb1b31..71c33735b 100644 --- a/plugins/blueprint.cpp +++ b/plugins/blueprint.cpp @@ -708,11 +708,13 @@ typedef void (init_ctx_fn)(const df::coord &pos, tile_context &ctx); struct blueprint_processor { bp_volume mapdata; const string phase; + const bool force_create; get_tile_fn * const get_tile; init_ctx_fn * const init_ctx; - blueprint_processor(const string &phase, get_tile_fn *get_tile, - init_ctx_fn *init_ctx = NULL) - : phase(phase), get_tile(get_tile), init_ctx(init_ctx) { } + blueprint_processor(const string &phase, bool force_create, + get_tile_fn *get_tile, init_ctx_fn *init_ctx = NULL) + : phase(phase), force_create(force_create), get_tile(get_tile), + init_ctx(init_ctx) { } }; static void write_minimal(ofstream &ofile, const blueprint_options &opts, @@ -825,16 +827,17 @@ static bool do_transform(color_ostream &out, vector processors; if (opts.auto_phase || opts.dig) - processors.push_back(blueprint_processor("dig", get_tile_dig)); + processors.push_back(blueprint_processor("dig", opts.dig, + get_tile_dig)); if (opts.auto_phase || opts.build) - processors.push_back(blueprint_processor("build", get_tile_build, - ensure_building)); + processors.push_back(blueprint_processor("build", opts.build, + get_tile_build, ensure_building)); if (opts.auto_phase || opts.place) - processors.push_back(blueprint_processor("place", get_tile_place, - ensure_building)); + processors.push_back(blueprint_processor("place", opts.place, + get_tile_place, ensure_building)); if (opts.auto_phase || opts.query) - processors.push_back(blueprint_processor("query", get_tile_query, - ensure_building)); + processors.push_back(blueprint_processor("query", opts.query, + get_tile_query, ensure_building)); if (processors.empty()) { out.printerr("no phases requested! nothing to do!\n"); @@ -874,6 +877,8 @@ static bool do_transform(color_ostream &out, std::map output_files; for (blueprint_processor &processor : processors) { + if (processor.mapdata.empty() && !processor.force_create) + continue; if (!write_blueprint(out, output_files, opts, processor, pretty)) break; } diff --git a/test/quickfort/ecosystem.lua b/test/quickfort/ecosystem.lua index 6c16f29ae..76b0ba5ac 100644 --- a/test/quickfort/ecosystem.lua +++ b/test/quickfort/ecosystem.lua @@ -192,15 +192,9 @@ local function designate_area(pos, spec) end local function run_blueprint(basename, set, pos) - local blueprint_args = {tostring(set.spec.width), - tostring(set.spec.height), - tostring(-set.spec.depth), - output_dir..basename, get_cursor_arg(pos), - '-tphase'} - for _,mode_name in pairs(mode_names) do - if set.modes[mode_name] then table.insert(blueprint_args, mode_name) end - end - blueprint.run(table.unpack(blueprint_args)) + blueprint.run(tostring(set.spec.width), tostring(set.spec.height), + tostring(-set.spec.depth), output_dir..basename, + get_cursor_arg(pos), '-tphase') end local function reset_area(area, spec)