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

Function dolookaround

src/cmd.c:1309–1369  ·  view source on GitHub ↗

#lookaround - describe what the hero can see, in text */

Source from the content-addressed store, hash-verified

1307
1308/* #lookaround - describe what the hero can see, in text */
1309int
1310dolookaround(void)
1311{
1312 coordxy x, y;
1313 int tmp_getloc_filter = iflags.getloc_filter;
1314 boolean tmp_accessiblemsg = a11y.accessiblemsg;
1315 boolean corr_next2u = FALSE;
1316
1317 a11y.accessiblemsg = TRUE;
1318 if (levl[u.ux][u.uy].typ == CORR) {
1319 /* In a corridor, mention corridors next to you. */
1320 corr_next2u = TRUE;
1321 /* TODO: if we know, describe where the corridor goes,
1322 perhaps by describing the rooms? */
1323 } else if (IS_DOOR(levl[u.ux][u.uy].typ)) {
1324 /* In a doorway, describe the rooms next to you */
1325 int i;
1326
1327 for (i = DIR_W; i < N_DIRS; i += 2) {
1328 x = u.ux + xdir[i];
1329 y = u.uy + ydir[i];
1330 if (isok(x, y) && IS_ROOM(levl[x][y].typ))
1331 lookaround_known_room(x, y);
1332 }
1333 corr_next2u = TRUE;
1334 } else {
1335 lookaround_known_room(u.ux, u.uy);
1336 }
1337
1338 /* TODO: maybe describe stuff outside the current room differently? */
1339
1340 iflags.getloc_filter = GFILTER_VIEW;
1341 for (y = 0; y < ROWNO; y++)
1342 for (x = 1; x < COLNO; x++) {
1343 int glyph, mapsym;
1344 boolean iscorr = (corr_next2u
1345 && (glyph = glyph_at(x, y)) >= 0
1346 && glyph_is_cmap(glyph)
1347 && ((mapsym = glyph_to_cmap(glyph)) == S_corr
1348 || mapsym == S_litcorr));
1349
1350 if (!u_at(x, y)
1351 && (gather_locs_interesting(x, y, GLOC_INTERESTING)
1352 /* note: GLOC_INTERESTING catches S_engrcorr */
1353 || iscorr)) {
1354 char buf[BUFSZ];
1355 coord cc;
1356 int sym = 0;
1357 const char *firstmatch = 0;
1358
1359 cc.x = x, cc.y = y;
1360 do_screen_description(cc, TRUE, sym, buf, &firstmatch, NULL);
1361 pline_xy(x, y, "%s.", firstmatch);
1362 }
1363 }
1364
1365 iflags.getloc_filter = tmp_getloc_filter;
1366 a11y.accessiblemsg = tmp_accessiblemsg;

Callers 1

newgameFunction · 0.85

Calls 7

isokFunction · 0.85
lookaround_known_roomFunction · 0.85
glyph_atFunction · 0.85
glyph_to_cmapFunction · 0.85
gather_locs_interestingFunction · 0.85
do_screen_descriptionFunction · 0.85
pline_xyFunction · 0.85

Tested by

no test coverage detected