summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/chardump.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-08 18:17:54 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-08 18:17:54 +0000
commitb39226f02c5336c216d53f5400266090dd5ba4d2 (patch)
tree85f3040390e87d640e7c328a31f0c65661d6e617 /crawl-ref/source/chardump.cc
parentbf0fe8202682ed06c3a1ac74ed8074742472032e (diff)
downloadcrawl-ref-b39226f02c5336c216d53f5400266090dd5ba4d2.tar.gz
crawl-ref-b39226f02c5336c216d53f5400266090dd5ba4d2.zip
Added map dumping (to NAME.map) to the '#' key. The map dump doesn't
include the hero (i.e., no '@' symbol.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2822 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/chardump.cc')
-rw-r--r--crawl-ref/source/chardump.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index f514b94d79..15f6b6488a 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1131,6 +1131,37 @@ static std::string morgue_directory()
return (dir);
}
+static void dump_map(const char* fname)
+{
+ FILE* fp = fopen(fname, "w");
+ if ( !fp )
+ return;
+
+ int min_x = GXM, max_x = 0, min_y = GYM, 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);
+}
+
static bool write_dump(
const std::string &fname,
dump_params &par)
@@ -1146,6 +1177,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");