summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-08 18:35:07 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-08 18:35:07 +0000
commit03a9a6865be3addb608f2e6e7be4c06f0ca166e3 (patch)
tree54e9aacccb9bc0f5884734866ceecca4ae1da3ff
parent3123b0daa3b86ecc112d0cca1be070bb0e314932 (diff)
downloadcrawl-ref-03a9a6865be3addb608f2e6e7be4c06f0ca166e3.tar.gz
crawl-ref-03a9a6865be3addb608f2e6e7be4c06f0ca166e3.zip
Merge r2822:2824: map dumping to FILE.map added to '#'.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2825 c06c8d41-db1a-0410-9941-cceddc491573
-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");