summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/chardump.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/chardump.cc')
-rw-r--r--crawl-ref/source/chardump.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index e40581271f..adbf4b6815 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1131,6 +1131,48 @@ static std::string morgue_directory()
return (dir);
}
+static void dump_map(const char* fname)
+{
+ // Duplicate the screenshot() trick.
+ FixedVector<unsigned, NUM_DCHAR_TYPES> char_table_bk;
+ char_table_bk = Options.char_table;
+
+ init_char_table(CSET_ASCII);
+ init_feature_table();
+
+ FILE* fp = fopen(fname, "w");
+ if ( !fp )
+ return;
+
+ int min_x = GXM-1, max_x = 0, min_y = GYM-1, max_y = 0;
+
+ for (int i = 0; i < GXM; i++)
+ for (int j = 0; j < GYM; j++)
+ if (env.map[i][j].known())
+ {
+ if ( i > max_x )
+ max_x = i;
+ if ( i < min_x )
+ min_x = i;
+ if ( j > max_y )
+ max_y = j;
+ if ( j < min_y )
+ min_y = j;
+ }
+
+ for ( int y = min_y; y <= max_y; ++y )
+ {
+ for ( int x = min_x; x <= max_x; ++x )
+ fputc( env.map[x][y].glyph(), fp );
+ fputc('\n', fp);
+ }
+ fclose(fp);
+
+ // Restore char and feature tables
+ Options.char_table = char_table_bk;
+ init_feature_table();
+}
+
static bool write_dump(
const std::string &fname,
dump_params &par)
@@ -1146,6 +1188,9 @@ static bool write_dump(
stash_file_name += ".lst";
stashes.dump(stash_file_name.c_str(), par.full_id);
+ std::string map_file_name = file_name + ".map";
+ dump_map(map_file_name.c_str());
+
file_name += ".txt";
FILE *handle = fopen(file_name.c_str(), "w");