|
|
|
@ -1095,11 +1095,12 @@ static bool create_output_dir(color_ostream &out,
|
|
|
|
|
static bool get_filename(string &fname,
|
|
|
|
|
color_ostream &out,
|
|
|
|
|
blueprint_options opts, // copy because we can't const
|
|
|
|
|
const string &phase) {
|
|
|
|
|
const string &phase,
|
|
|
|
|
int32_t ordinal) {
|
|
|
|
|
auto L = Lua::Core::State;
|
|
|
|
|
Lua::StackUnwinder top(L);
|
|
|
|
|
|
|
|
|
|
if (!lua_checkstack(L, 3) ||
|
|
|
|
|
if (!lua_checkstack(L, 4) ||
|
|
|
|
|
!Lua::PushModulePublic(
|
|
|
|
|
out, L, "plugins.blueprint", "get_filename")) {
|
|
|
|
|
out.printerr("Failed to load blueprint Lua code\n");
|
|
|
|
@ -1108,8 +1109,9 @@ static bool get_filename(string &fname,
|
|
|
|
|
|
|
|
|
|
Lua::Push(L, &opts);
|
|
|
|
|
Lua::Push(L, phase);
|
|
|
|
|
Lua::Push(L, ordinal);
|
|
|
|
|
|
|
|
|
|
if (!Lua::SafeCall(out, L, 2, 1)) {
|
|
|
|
|
if (!Lua::SafeCall(out, L, 3, 1)) {
|
|
|
|
|
out.printerr("Failed Lua call to get_filename\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@ -1228,9 +1230,9 @@ static bool write_blueprint(color_ostream &out,
|
|
|
|
|
std::map<string, ofstream*> &output_files,
|
|
|
|
|
const blueprint_options &opts,
|
|
|
|
|
const blueprint_processor &processor,
|
|
|
|
|
bool pretty) {
|
|
|
|
|
bool pretty, int32_t ordinal) {
|
|
|
|
|
string fname;
|
|
|
|
|
if (!get_filename(fname, out, opts, processor.phase))
|
|
|
|
|
if (!get_filename(fname, out, opts, processor.phase, ordinal))
|
|
|
|
|
return false;
|
|
|
|
|
if (!output_files.count(fname))
|
|
|
|
|
output_files[fname] = new ofstream(fname, ofstream::trunc);
|
|
|
|
@ -1249,9 +1251,10 @@ static bool write_blueprint(color_ostream &out,
|
|
|
|
|
static void write_meta_blueprint(color_ostream &out,
|
|
|
|
|
std::map<string, ofstream*> &output_files,
|
|
|
|
|
const blueprint_options &opts,
|
|
|
|
|
const std::vector<string> & meta_phases) {
|
|
|
|
|
const std::vector<string> & meta_phases,
|
|
|
|
|
int32_t ordinal) {
|
|
|
|
|
string fname;
|
|
|
|
|
get_filename(fname, out, opts, meta_phases.front());
|
|
|
|
|
get_filename(fname, out, opts, meta_phases.front(), ordinal);
|
|
|
|
|
ofstream &ofile = *output_files[fname];
|
|
|
|
|
|
|
|
|
|
ofile << "#meta label(";
|
|
|
|
@ -1285,7 +1288,7 @@ static void add_processor(vector<blueprint_processor> &processors,
|
|
|
|
|
|
|
|
|
|
static bool do_transform(color_ostream &out,
|
|
|
|
|
const df::coord &start, const df::coord &end,
|
|
|
|
|
blueprint_options &opts,
|
|
|
|
|
blueprint_options opts, // copy so we can munge it
|
|
|
|
|
vector<string> &filenames) {
|
|
|
|
|
// empty map instances to pass to emplace() below
|
|
|
|
|
static const bp_area EMPTY_AREA;
|
|
|
|
@ -1368,16 +1371,26 @@ static bool do_transform(color_ostream &out,
|
|
|
|
|
if (meta_phases.size() <= 1)
|
|
|
|
|
opts.nometa = true;
|
|
|
|
|
|
|
|
|
|
bool in_meta = false;
|
|
|
|
|
int32_t ordinal = 0;
|
|
|
|
|
std::map<string, ofstream*> output_files;
|
|
|
|
|
for (blueprint_processor &processor : processors) {
|
|
|
|
|
if (processor.mapdata.empty() && !processor.force_create)
|
|
|
|
|
continue;
|
|
|
|
|
if (!write_blueprint(out, output_files, opts, processor, pretty))
|
|
|
|
|
bool meta_phase = is_meta_phase(out, opts, processor.phase);
|
|
|
|
|
if (!in_meta)
|
|
|
|
|
++ordinal;
|
|
|
|
|
if (in_meta && !meta_phase) {
|
|
|
|
|
write_meta_blueprint(out, output_files, opts, meta_phases, ordinal);
|
|
|
|
|
++ordinal;
|
|
|
|
|
}
|
|
|
|
|
in_meta = meta_phase;
|
|
|
|
|
if (!write_blueprint(out, output_files, opts, processor, pretty,
|
|
|
|
|
ordinal))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!opts.nometa) {
|
|
|
|
|
write_meta_blueprint(out, output_files, opts, meta_phases);
|
|
|
|
|
}
|
|
|
|
|
if (in_meta)
|
|
|
|
|
write_meta_blueprint(out, output_files, opts, meta_phases, ordinal);
|
|
|
|
|
|
|
|
|
|
for (auto &it : output_files) {
|
|
|
|
|
filenames.push_back(it.first);
|
|
|
|
|