| 2291 | |
| 2292 | #ifdef DUMPLOG |
| 2293 | void |
| 2294 | dump_map(void) |
| 2295 | { |
| 2296 | char buf[COLBUFSZ]; |
| 2297 | coordxy x, y; |
| 2298 | int glyph, skippedrows, lastnonblank; |
| 2299 | boolean blankrow, toprow; |
| 2300 | unsigned subset = TER_MAP | TER_TRP | TER_OBJ | TER_MON; |
| 2301 | /* cmap_to_glyph() evaluates its argument multiple times, so pull the |
| 2302 | tree vs stone conditional out of it */ |
| 2303 | nhsym default_sym = svl.level.flags.arboreal ? S_tree : S_stone; |
| 2304 | int default_glyph = cmap_to_glyph(default_sym); |
| 2305 | |
| 2306 | /* |
| 2307 | * Squeeze out excess vertical space when dumping the map. |
| 2308 | * If there are any blank map rows at the top, suppress them |
| 2309 | * (our caller has already printed a separator). If there is |
| 2310 | * more than one blank map row at the bottom, keep just one. |
| 2311 | * Any blank rows within the middle of the map are kept. |
| 2312 | * Note: putstr() with winid==0 is for dumplog. |
| 2313 | */ |
| 2314 | skippedrows = 0; |
| 2315 | toprow = TRUE; |
| 2316 | for (y = 0; y < ROWNO; y++) { |
| 2317 | blankrow = TRUE; /* assume blank until we discover otherwise */ |
| 2318 | lastnonblank = -1; /* buf[] index rather than map's x */ |
| 2319 | for (x = 1; x < COLNO; x++) { |
| 2320 | int ch; |
| 2321 | glyph_info glyphinfo; |
| 2322 | |
| 2323 | glyph = reveal_terrain_getglyph(x, y, u.uswallow, |
| 2324 | default_glyph, subset); |
| 2325 | map_glyphinfo(x, y, glyph, 0, &glyphinfo); |
| 2326 | ch = glyphinfo.ttychar; |
| 2327 | buf[x - 1] = ch; |
| 2328 | if (ch != ' ') { |
| 2329 | blankrow = FALSE; |
| 2330 | lastnonblank = x - 1; |
| 2331 | } |
| 2332 | } |
| 2333 | if (!blankrow) { |
| 2334 | buf[lastnonblank + 1] = '\0'; |
| 2335 | if (toprow) { |
| 2336 | skippedrows = 0; |
| 2337 | toprow = FALSE; |
| 2338 | } |
| 2339 | for (x = 0; x < skippedrows; x++) |
| 2340 | putstr(0, 0, ""); |
| 2341 | putstr(0, 0, buf); /* map row #y */ |
| 2342 | skippedrows = 0; |
| 2343 | } else { |
| 2344 | ++skippedrows; |
| 2345 | } |
| 2346 | } |
| 2347 | if (skippedrows) |
| 2348 | putstr(0, 0, ""); |
| 2349 | } |
| 2350 | #endif /* DUMPLOG */ |
no test coverage detected