diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-18 21:55:39 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-11-18 21:55:39 +0000 |
commit | d94245983324bbedff384a23e7113715fa1da63f (patch) | |
tree | d671b5fc496bb203be236c17f4095d63d57f7e34 /crawl-ref/source/chardump.cc | |
parent | b1550dd18c1c2d41eee11bb2a33f01baccb0d8eb (diff) | |
download | crawl-ref-d94245983324bbedff384a23e7113715fa1da63f.tar.gz crawl-ref-d94245983324bbedff384a23e7113715fa1da63f.zip |
Fixed crawl -mapstat segfaulting.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7485 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/chardump.cc')
-rw-r--r-- | crawl-ref/source/chardump.cc | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index 714f282234..c02ecac128 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -1125,7 +1125,7 @@ static std::string morgue_directory() return (dir); } -void dump_map(FILE *fp) +void dump_map(FILE *fp, bool debug) { // Duplicate the screenshot() trick. FixedVector<unsigned, NUM_DCHAR_TYPES> char_table_bk; @@ -1134,24 +1134,38 @@ void dump_map(FILE *fp) init_char_table(CSET_ASCII); init_feature_table(); - int min_x = GXM-1, max_x = 0, min_y = GYM-1, max_y = 0; + if (debug) + { + // Write the whole map out without checking for mappedness. Handy + // for debugging level-generation issues. + for (int y = 0; y < GYM; ++y) + { + for (int x = 0; x < GXM; ++x) + fputc(grid_character_at(coord_def(x,y)), fp); + fputc('\n', fp); + } + } + else + { + int min_x = GXM-1, max_x = 0, min_y = GYM-1, max_y = 0; - for (int i = X_BOUND_1; i <= X_BOUND_2; i++) - for (int j = Y_BOUND_1; j <= Y_BOUND_2; 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 i = X_BOUND_1; i <= X_BOUND_2; i++) + for (int j = Y_BOUND_1; j <= Y_BOUND_2; 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 ); + 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); + fputc('\n', fp); + } } // Restore char and feature tables @@ -1159,13 +1173,13 @@ void dump_map(FILE *fp) init_feature_table(); } -void dump_map(const char* fname) +void dump_map(const char* fname, bool debug) { FILE* fp = fopen(fname, "w"); if (!fp) return; - dump_map(fp); + dump_map(fp, debug); fclose(fp); } |