From b39226f02c5336c216d53f5400266090dd5ba4d2 Mon Sep 17 00:00:00 2001 From: haranp Date: Thu, 8 Nov 2007 18:17:54 +0000 Subject: 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 --- crawl-ref/source/chardump.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'crawl-ref/source/chardump.cc') 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"); -- cgit v1.2.3-54-g00ecf