MCPcopy Index your code
hub / github.com/NetHack/NetHack / do_screen_description

Function do_screen_description

src/pager.c:1246–1627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1244}
1245
1246int
1247do_screen_description(
1248 coord cc, boolean looked,
1249 int sym, char *out_str,
1250 const char **firstmatch,
1251 struct permonst **for_supplement)
1252{
1253 static const char mon_interior[] = "the interior of a monster",
1254 unreconnoitered[] = "unreconnoitered";
1255 static char look_buf[BUFSZ];
1256 char prefix[BUFSZ];
1257 int i, j, alt_i, glyph = NO_GLYPH,
1258 skipped_venom = 0, found = 0; /* count of matching syms found */
1259 boolean hit_trap, need_to_look = FALSE,
1260 submerged = (Underwater && !Is_waterlevel(&u.uz)),
1261 hallucinate = (Hallucination && !program_state.gameover);
1262 const char *x_str;
1263 nhsym tmpsym;
1264 glyph_info glyphinfo = nul_glyphinfo;
1265
1266 if (looked) {
1267 glyph = glyph_at(cc.x, cc.y);
1268 /* Convert glyph at selected position to a symbol for use below. */
1269 map_glyphinfo(cc.x, cc.y, glyph, 0, &glyphinfo);
1270 sym = glyphinfo.ttychar;
1271 Sprintf(prefix, "%s ", encglyph(glyphinfo.glyph));
1272 } else
1273 Sprintf(prefix, "%c ", sym);
1274
1275 /*
1276 * Check all the possibilities, saving all explanations in a buffer.
1277 * When all have been checked then the string is printed.
1278 */
1279
1280 /*
1281 * Handle restricted vision range (limited to adjacent spots when
1282 * swallowed or underwater) cases first.
1283 *
1284 * 3.6.0 listed anywhere on map, other than self, as "interior
1285 * of a monster" when swallowed, and non-adjacent water or
1286 * non-water anywhere as "dark part of a room" when underwater.
1287 * "unreconnoitered" is an attempt to convey "even if you knew
1288 * what was there earlier, you don't know what is there in the
1289 * current circumstance".
1290 *
1291 * (Note: 'self' will always be visible when swallowed so we don't
1292 * need special swallow handling for <ux,uy>.
1293 * Another note: for '#terrain' without monsters, u.uswallow and
1294 * submerged will always both be False and skip this code.)
1295 */
1296 x_str = 0;
1297 if (!looked) {
1298 ; /* skip special handling */
1299 } else if (((u.uswallow || submerged) && !next2u(cc.x, cc.y))
1300 /* detection showing some category, so mostly background */
1301 || ((iflags.terrainmode & (TER_DETECT | TER_MAP)) == TER_DETECT
1302 && glyph == cmap_to_glyph(S_stone))) {
1303 x_str = unreconnoitered;

Callers 5

show_glyphFunction · 0.85
do_lookFunction · 0.85
dolookaroundFunction · 0.85
auto_describeFunction · 0.85
getpos_menuFunction · 0.85

Calls 14

glyph_atFunction · 0.85
map_glyphinfoFunction · 0.85
encglyphFunction · 0.85
is_swallow_symFunction · 0.85
append_strFunction · 0.85
anFunction · 0.85
strstriFunction · 0.85
add_cmap_descrFunction · 0.85
sobj_atFunction · 0.85
lookatFunction · 0.85
ice_descrFunction · 0.85
on_levelFunction · 0.85

Tested by

no test coverage detected