only create empty blueprints on explicit request

and use the new functionality in the ecosystem tests, which simplifies
the blueprint commandline creation
develop
myk002 2021-10-02 12:52:43 -07:00 committed by Myk
parent d013b336ba
commit 27c0c41536
2 changed files with 18 additions and 19 deletions

@ -708,11 +708,13 @@ typedef void (init_ctx_fn)(const df::coord &pos, tile_context &ctx);
struct blueprint_processor { struct blueprint_processor {
bp_volume mapdata; bp_volume mapdata;
const string phase; const string phase;
const bool force_create;
get_tile_fn * const get_tile; get_tile_fn * const get_tile;
init_ctx_fn * const init_ctx; init_ctx_fn * const init_ctx;
blueprint_processor(const string &phase, get_tile_fn *get_tile, blueprint_processor(const string &phase, bool force_create,
init_ctx_fn *init_ctx = NULL) get_tile_fn *get_tile, init_ctx_fn *init_ctx = NULL)
: phase(phase), get_tile(get_tile), init_ctx(init_ctx) { } : phase(phase), force_create(force_create), get_tile(get_tile),
init_ctx(init_ctx) { }
}; };
static void write_minimal(ofstream &ofile, const blueprint_options &opts, static void write_minimal(ofstream &ofile, const blueprint_options &opts,
@ -825,16 +827,17 @@ static bool do_transform(color_ostream &out,
vector<blueprint_processor> processors; vector<blueprint_processor> processors;
if (opts.auto_phase || opts.dig) 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) if (opts.auto_phase || opts.build)
processors.push_back(blueprint_processor("build", get_tile_build, processors.push_back(blueprint_processor("build", opts.build,
ensure_building)); get_tile_build, ensure_building));
if (opts.auto_phase || opts.place) if (opts.auto_phase || opts.place)
processors.push_back(blueprint_processor("place", get_tile_place, processors.push_back(blueprint_processor("place", opts.place,
ensure_building)); get_tile_place, ensure_building));
if (opts.auto_phase || opts.query) if (opts.auto_phase || opts.query)
processors.push_back(blueprint_processor("query", get_tile_query, processors.push_back(blueprint_processor("query", opts.query,
ensure_building)); get_tile_query, ensure_building));
if (processors.empty()) { if (processors.empty()) {
out.printerr("no phases requested! nothing to do!\n"); out.printerr("no phases requested! nothing to do!\n");
@ -874,6 +877,8 @@ static bool do_transform(color_ostream &out,
std::map<string, ofstream*> output_files; std::map<string, ofstream*> output_files;
for (blueprint_processor &processor : processors) { for (blueprint_processor &processor : processors) {
if (processor.mapdata.empty() && !processor.force_create)
continue;
if (!write_blueprint(out, output_files, opts, processor, pretty)) if (!write_blueprint(out, output_files, opts, processor, pretty))
break; break;
} }

@ -192,15 +192,9 @@ local function designate_area(pos, spec)
end end
local function run_blueprint(basename, set, pos) local function run_blueprint(basename, set, pos)
local blueprint_args = {tostring(set.spec.width), blueprint.run(tostring(set.spec.width), tostring(set.spec.height),
tostring(set.spec.height), tostring(-set.spec.depth), output_dir..basename,
tostring(-set.spec.depth), get_cursor_arg(pos), '-tphase')
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))
end end
local function reset_area(area, spec) local function reset_area(area, spec)