summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/chardump.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2013-10-03 22:50:04 +0200
committerAdam Borowski <kilobyte@angband.pl>2013-10-03 22:53:29 +0200
commitba8f2199795fa0dffcb763575a8358f94dc830bc (patch)
treef2193f1af3a5a37cf101dec6936fe4f116c9e086 /crawl-ref/source/chardump.cc
parent298c0bfce864b758fac74a2bf390e8022a5a51fd (diff)
downloadcrawl-ref-ba8f2199795fa0dffcb763575a8358f94dc830bc.tar.gz
crawl-ref-ba8f2199795fa0dffcb763575a8358f94dc830bc.zip
A new build flag: COLOURED_DUMPS.
If set, maps will be colour-coded to show what vaults were placed, and where. Such dumps are fit for viewing on a terminal (via cat or less -R), but not with GUI text viewers. For HTML, you probably want ansi2html.
Diffstat (limited to 'crawl-ref/source/chardump.cc')
-rw-r--r--crawl-ref/source/chardump.cc43
1 files changed, 42 insertions, 1 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index be0194d20c..41dd244fc7 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1360,13 +1360,51 @@ void dump_map(FILE *fp, bool debug, bool dist)
{
if (debug)
{
+#ifdef COLOURED_DUMPS
+ // Usage: make EXTERNAL_DEFINES="-DCOLOURED_DUMPS"
+ // To read the dumps, cat them or use less -R.
+ // ansi2html can be used to make html.
+
+ fprintf(fp, "Vaults used:\n");
+ for (size_t i = 0; i < env.level_vaults.size(); ++i)
+ {
+ const vault_placement &vp(*env.level_vaults[i]);
+ fprintf(fp, " \e[3%lum%s\e[0m at (%d,%d) size (%d,%d)\n",
+ 6 - i % 6, vp.map.name.c_str(),
+ vp.pos.x, vp.pos.y, vp.size.x, vp.size.y);
+ }
+ fprintf(fp, " (bright = stacked, \e[37;1mwhite\e[0m = not in level_map_ids)\n");
+ size_t last_nv = 0;
+ int last_v = 0;
+#endif
// 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)
{
- if (you.pos() == coord_def(x, y))
+#ifdef COLOURED_DUMPS
+ size_t nv = 0;
+ for (size_t i = 0; i < env.level_vaults.size(); ++i)
+ if (env.level_vaults[i]->map.in_map(coord_def(x, y)
+ - env.level_vaults[i]->pos))
+ {
+ nv++;
+ }
+ int v = env.level_map_ids[x][y];
+ if (nv && v == INVALID_MAP_INDEX)
+ v = -1;
+ if (nv != last_nv || v != last_v)
+ {
+ if (nv)
+ fprintf(fp, "\e[%d;3%dm", nv > 1, 6 - v % 6);
+ else
+ fprintf(fp, "\e[0m");
+ last_nv = nv;
+ last_v = v;
+ }
+#endif
+ if (dist && you.pos() == coord_def(x, y))
fputc('@', fp);
else if (testbits(env.pgrid[x][y], FPROP_HIGHLIGHT))
fputc('?', fp);
@@ -1386,6 +1424,9 @@ void dump_map(FILE *fp, bool debug, bool dist)
}
fputc('\n', fp);
}
+#ifdef COLOURED_DUMPS
+ fprintf(fp, "\e[0m");
+#endif
}
else
{