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

Function see_nearby_objects

src/display.c:1575–1605  ·  view source on GitHub ↗

mark the top object of nearby stacks as having been seen, and if that object was being displayed as generic, redisplay it as specific */

Source from the content-addressed store, hash-verified

1573/* mark the top object of nearby stacks as having been seen, and if
1574 that object was being displayed as generic, redisplay it as specific */
1575void
1576see_nearby_objects(void)
1577{
1578 struct obj *obj;
1579 int glyph;
1580 coordxy ix, iy, x = u.ux, y = u.uy;
1581 /* these 'r' and 'neardist' calculations match distant_name(objnam.c) */
1582 int r = (u.xray_range > 2) ? u.xray_range : 2,
1583 /* neardist produces a small square with rounded corners */
1584 neardist = (r * r) * 2 - r; /* same as r*r + r*(r-1) */
1585
1586 /* [note: this could be optimized to avoid the distu() calculations] */
1587 for (iy = y - r; iy <= y + r; ++iy)
1588 for (ix = x - r; ix <= x + r; ++ix) {
1589 if (!isok(ix, iy))
1590 continue;
1591 /* skip if no object or the object has already been marked as
1592 having been seen up close */
1593 if ((obj = vobj_at(ix, iy)) == 0 || obj->dknown)
1594 continue;
1595 /* skip if the spot can't be seen or is too far (diagonal) */
1596 if (!cansee(ix, iy) || distu(ix, iy) > neardist)
1597 continue;
1598
1599 observe_object(obj);
1600 /* operate on remembered glyph rather than current one */
1601 glyph = levl[ix][iy].glyph;
1602 if (glyph_is_generic_object(glyph))
1603 newsym_force(ix, iy);
1604 }
1605}
1606
1607/*
1608 * Update hallucinated traps.

Callers 1

u_on_newposFunction · 0.85

Calls 3

isokFunction · 0.85
observe_objectFunction · 0.85
newsym_forceFunction · 0.85

Tested by

no test coverage detected