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

Function findit

src/detect.c:1791–1898  ·  view source on GitHub ↗

returns number of things found */

Source from the content-addressed store, hash-verified

1789
1790/* returns number of things found */
1791int
1792findit(void)
1793{
1794 int num = 0, k;
1795 char buf[BUFSZ];
1796 struct found_things found;
1797
1798 /*
1799 * findit() -> do_clear_area(findone) -> findone() -> foundone()
1800 * is used to notify player where various things have been found.
1801 * Changing FOUND_FLASH_COUNT to 0 will switch to tmp_at() to
1802 * highlight all discoveries for the current operation, but requires
1803 * player to respond to --More-- when done. Neither allows browsing
1804 * the map via getpos() autodescribe (until after it has reverted to
1805 * normal display, where found traps might be covered by objects).
1806 */
1807
1808 if (u.uswallow)
1809 return 0;
1810
1811#if FOUND_FLASH_COUNT == 0 /* _COUNT > 0 doesn't need to init tmp_at() */
1812 tmp_at(DISP_ALL, GLYPH_NOTHING);
1813#endif
1814 (void) memset((genericptr_t) &found, 0, sizeof found);
1815 do_clear_area(u.ux, u.uy, BOLT_LIM, findone, (genericptr_t) &found);
1816 /* count that controls "reveal" punctuation; 0..4 */
1817 k = !!found.num_sdoors + !!found.num_scorrs + !!found.num_traps
1818 + !!found.num_mons;
1819
1820 buf[0] = '\0';
1821 if (found.num_sdoors) {
1822 if (found.num_sdoors > 1)
1823 Sprintf(eos(buf), "%d secret doors", found.num_sdoors);
1824 else
1825 Strcat(buf, "a secret door");
1826 num += found.num_sdoors;
1827 }
1828 /* note: non-\0 *buf implies that at least one previous type is present */
1829 if (found.num_scorrs) {
1830 if (*buf) /* "doors and corrs" or "doors, corrs ..." */
1831 Strcat(buf, (k == 2) ? " and " : ", ");
1832 if (found.num_scorrs > 1)
1833 Sprintf(eos(buf), "%d secret corridors", found.num_scorrs);
1834 else
1835 Strcat(buf, "a secret corridor");
1836 num += found.num_scorrs;
1837 }
1838 if (found.num_traps) {
1839 if (*buf) /* "doors, corrs, and traps" or "{doors|corrs} and traps"
1840 * or "..., traps ..." */
1841 Strcat(buf, (k == 3 && !found.num_mons) ? ", and "
1842 : (k == 2) ? " and " : ", ");
1843 if (found.num_traps > 1)
1844 Sprintf(eos(buf), "%d traps", found.num_traps);
1845 else
1846 Strcat(buf, "a trap");
1847 num += found.num_traps;
1848 }

Callers 3

wiz_detectFunction · 0.85
zapnodirFunction · 0.85
use_bellFunction · 0.85

Calls 5

tmp_atFunction · 0.85
do_clear_areaFunction · 0.85
eosFunction · 0.85
YouFunction · 0.85
You_feelFunction · 0.85

Tested by

no test coverage detected