mark the top object of nearby stacks as having been seen, and if that object was being displayed as generic, redisplay it as specific */
| 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 */ |
| 1575 | void |
| 1576 | see_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. |
no test coverage detected