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

Function look_engrs

src/pager.c:2143–2228  ·  view source on GitHub ↗

display of discovered engravings including headstones, even when they're covered provided they've been read */

Source from the content-addressed store, hash-verified

2141/* display of discovered engravings including headstones, even when they're
2142 covered provided they've been read */
2143staticfn void
2144look_engrs(boolean nearby)
2145{
2146 winid win;
2147 struct engr *e;
2148 char lookbuf[BUFSZ], outbuf[BUFSZ];
2149 coordxy x, y, lo_x, lo_y, hi_x, hi_y;
2150 boolean is_headstone;
2151 nhsym sym;
2152 int glyph, count = 0;
2153
2154 win = create_nhwindow(NHW_TEXT);
2155 look_region_nearby(&lo_x, &lo_y, &hi_x, &hi_y, nearby);
2156 /*assert(lo_x >= 1 && lo_y >= 0 && hi_x < MAXCO && hi_y < MAXLI);*/
2157 for (y = lo_y; y <= hi_y; y++) {
2158 for (x = lo_x; x <= hi_x; x++) {
2159 lookbuf[0] = '\0';
2160 if (!levl[x][y].seenv)
2161 continue;
2162 /* this won't find remembered engravings which aren't there
2163 anymore (in case the hero is unaware that they're gone;
2164 scuffed away by monster movement or deleted during shop
2165 or vault wall repair); not sure what to do about that */
2166 e = engr_at(x, y);
2167 if (!e)
2168 continue;
2169 is_headstone = IS_GRAVE(svl.lastseentyp[x][y]);
2170 Sprintf(lookbuf, " (%s", is_headstone ? "grave" : "engraving");
2171 (void) add_quoted_engraving(x, y, lookbuf, TRUE);
2172 /* the paren is used by farlook and add_quoted_engraving()
2173 expected to see it; we don't want it here */
2174 if (is_headstone) {
2175 (void) strsubst(lookbuf, "(grave with ", "");
2176 (void) strsubst(lookbuf, "(grave whose ", "");
2177 } else {
2178 (void) strsubst(lookbuf, "(engraving with ", "");
2179 (void) strsubst(lookbuf, "(engraving ", "engraving ");
2180 }
2181
2182 glyph = glyph_at(x, y);
2183 sym = glyph_is_cmap(glyph) ? glyph_to_cmap(glyph) : SYM_NOTHING;
2184 if (is_cmap_engraving(sym) || sym == S_grave) {
2185 /* engraving or grave+headstone shown on the map */
2186 ++count;
2187 } else {
2188 /* engraving or grave covered by object(s) */
2189 Snprintf(eos(lookbuf), sizeof lookbuf - strlen(lookbuf),
2190 ", obscured by %s", encglyph(glyph));
2191 glyph = is_headstone ? cmap_to_glyph(S_grave)
2192 : engraving_to_glyph(e);
2193 ++count;
2194 }
2195 if (*lookbuf) { /* (redundant) */
2196 char coordbuf[20], cmode;
2197
2198 cmode = (iflags.getpos_coords != GPCOORDS_NONE)
2199 ? iflags.getpos_coords : GPCOORDS_MAP;
2200 if (count == 1) {

Callers 1

do_lookFunction · 0.85

Calls 11

look_region_nearbyFunction · 0.85
engr_atFunction · 0.85
add_quoted_engravingFunction · 0.85
strsubstFunction · 0.85
glyph_atFunction · 0.85
glyph_to_cmapFunction · 0.85
eosFunction · 0.85
encglyphFunction · 0.85
upstartFunction · 0.85
coord_descFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected