MCPcopy Create free account
hub / github.com/NetHack/NetHack / reveal_terrain

Function reveal_terrain

src/detect.c:2355–2414  ·  view source on GitHub ↗

idea from crawl; show known portion of map without any monsters, objects, or traps occluding the view of the underlying terrain; in explore or wizard modes, can also display unexplored portion */

Source from the content-addressed store, hash-verified

2353 objects, or traps occluding the view of the underlying terrain;
2354 in explore or wizard modes, can also display unexplored portion */
2355void
2356reveal_terrain(
2357 unsigned which_subset) /* TER_TRP | TER_OBJ | TER_MON | TER_FULL */
2358{
2359 /* 'full' overrides impairment and implies no-traps, no-objs, no-mons */
2360 boolean full = (which_subset & TER_FULL) != 0; /* show whole map */
2361
2362 if ((Hallucination || Stunned || Confusion) && !full) {
2363 You("are too disoriented for this.");
2364 } else {
2365 coordxy x, y;
2366 int glyph, default_glyph;
2367 char buf[BUFSZ];
2368 /* there is a TER_MAP bit too; we always show map regardless of it */
2369 boolean keep_traps = (which_subset & TER_TRP) != 0,
2370 keep_objs = (which_subset & TER_OBJ) != 0,
2371 keep_mons = (which_subset & TER_MON) != 0; /* not used */
2372 unsigned swallowed = u.uswallow; /* before unconstrain_map() */
2373 nhsym default_sym = svl.level.flags.arboreal ? S_tree : S_stone;
2374
2375 if (unconstrain_map())
2376 docrt();
2377 default_glyph = cmap_to_glyph(default_sym);
2378
2379 for (x = 1; x < COLNO; x++)
2380 for (y = 0; y < ROWNO; y++) {
2381 glyph = reveal_terrain_getglyph(x, y, swallowed,
2382 default_glyph, which_subset);
2383 show_glyph(x, y, glyph);
2384 }
2385
2386 /* hero's location is not highlighted, but getpos() starts with
2387 cursor there, and after moving it anywhere '@' moves it back */
2388 flush_screen(1);
2389 if (full) {
2390 Strcpy(buf, "underlying terrain");
2391 } else {
2392 Strcpy(buf, "known terrain");
2393 if (keep_traps)
2394 Sprintf(eos(buf), "%s traps",
2395 (keep_objs || keep_mons) ? "," : " and");
2396 if (keep_objs)
2397 Sprintf(eos(buf), "%s%s objects",
2398 (keep_traps || keep_mons) ? "," : "",
2399 keep_mons ? "" : " and");
2400 if (keep_mons)
2401 Sprintf(eos(buf), "%s and monsters",
2402 (keep_traps || keep_objs) ? "," : "");
2403 }
2404 pline("Showing %s only...", buf);
2405
2406 /* allow player to move cursor around and get autodescribe feedback
2407 based on what is visible now rather than what is on 'real' map */
2408 which_subset |= TER_MAP; /* guarantee non-zero */
2409 browse_map(which_subset, "anything of interest");
2410
2411 map_redisplay();
2412 }

Callers 1

doterrainFunction · 0.85

Calls 10

YouFunction · 0.85
unconstrain_mapFunction · 0.85
docrtFunction · 0.85
reveal_terrain_getglyphFunction · 0.85
show_glyphFunction · 0.85
flush_screenFunction · 0.85
eosFunction · 0.85
browse_mapFunction · 0.85
map_redisplayFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected