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

Function findone

src/detect.c:1638–1726  ·  view source on GitHub ↗

find something at one location; this should find all somethings there since it is used for magical detection rather than physical searching */

Source from the content-addressed store, hash-verified

1636/* find something at one location; this should find all somethings there
1637 since it is used for magical detection rather than physical searching */
1638staticfn void
1639findone(coordxy zx, coordxy zy, genericptr_t whatfound)
1640{
1641 struct rm *lev = &levl[zx][zy];
1642 struct trap *ttmp = t_at(zx, zy);
1643 struct monst *mtmp = m_at(zx, zy);
1644 struct found_things *found_p = (struct found_things *) whatfound;
1645
1646 if (mtmp && (DEADMONSTER(mtmp) || (mtmp->isgd && !mtmp->mx)))
1647 mtmp = (struct monst *) NULL;
1648 found_p->ft_cc.x = zx; /* needed by detect_obj_traps() */
1649 found_p->ft_cc.y = zy;
1650
1651 if (lev->typ == SDOOR) {
1652 nhsym sym = lev->horizontal ? S_hcdoor : S_vcdoor;
1653
1654 flash_glyph_at(zx, zy, cmap_to_glyph(sym), FOUND_FLASH_COUNT);
1655 cvt_sdoor_to_door(lev); /* set lev->typ = DOOR */
1656 recalc_block_point(zx, zy);
1657 magic_map_background(zx, zy, 0);
1658 foundone(zx, zy, back_to_glyph(zx, zy));
1659 found_p->num_sdoors++;
1660 } else if (lev->typ == SCORR) {
1661 flash_glyph_at(zx, zy, cmap_to_glyph(S_corr), FOUND_FLASH_COUNT);
1662 lev->typ = CORR;
1663 unblock_point(zx, zy);
1664 magic_map_background(zx, zy, 0);
1665 foundone(zx, zy, cmap_to_glyph(S_corr));
1666 found_p->num_scorrs++;
1667 }
1668
1669 if (ttmp && !ttmp->tseen
1670 /* [shouldn't successful 'find' reveal and activate statue traps?] */
1671 && ttmp->ttyp != STATUE_TRAP) {
1672 flash_glyph_at(zx, zy, trap_to_glyph(ttmp), FOUND_FLASH_COUNT);
1673 ttmp->tseen = 1;
1674 sense_trap(ttmp, zx, zy, 0); /* handles Hallucination */
1675 foundone(zx, zy, trap_to_glyph(ttmp));
1676 found_p->num_traps++;
1677 }
1678 if (closed_door(zx, zy) && (lev->doormask & D_TRAPPED) != 0) {
1679 dummytrap.ttyp = TRAPPED_DOOR;
1680 dummytrap.tx = zx, dummytrap.ty = zy;
1681 flash_glyph_at(zx, zy, trap_to_glyph(&dummytrap), FOUND_FLASH_COUNT);
1682 dummytrap.tseen = 1;
1683 sense_trap(&dummytrap, zx, zy, 0); /* handles Hallucination */
1684 foundone(zx, zy, trap_to_glyph(&dummytrap));
1685 found_p->num_traps++;
1686 }
1687 /* trapped chests */
1688 (void) detect_obj_traps(svl.level.buriedobjlist, TRUE, 0, found_p);
1689 (void) detect_obj_traps(fobj, TRUE, 0, found_p);
1690 if (mtmp)
1691 (void) detect_obj_traps(mtmp->minvent, TRUE, 0, found_p);
1692 if (u_at(zx, zy))
1693 (void) detect_obj_traps(gi.invent, TRUE, 0, found_p);
1694
1695 if (mtmp && (!canspotmon(mtmp) || mtmp->mundetected || M_AP_TYPE(mtmp))) {

Callers

nothing calls this directly

Calls 15

t_atFunction · 0.85
flash_glyph_atFunction · 0.85
cvt_sdoor_to_doorFunction · 0.85
recalc_block_pointFunction · 0.85
magic_map_backgroundFunction · 0.85
foundoneFunction · 0.85
back_to_glyphFunction · 0.85
unblock_pointFunction · 0.85
sense_trapFunction · 0.85
closed_doorFunction · 0.85
detect_obj_trapsFunction · 0.85
seemimicFunction · 0.85

Tested by

no test coverage detected