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

Function notice_all_mons

src/hack.c:1743–1783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1741}
1742
1743void
1744notice_all_mons(boolean reset)
1745{
1746 if (a11y.mon_notices && !a11y.mon_notices_blocked) {
1747 struct monst *mtmp;
1748 struct monst **arr = NULL;
1749 int j, i = 0, cnt = 0;
1750
1751 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1752 if (DEADMONSTER(mtmp))
1753 continue;
1754 if (canspotmon(mtmp))
1755 cnt++;
1756 else if (reset)
1757 mtmp->mspotted = FALSE;
1758 }
1759 if (!cnt)
1760 return;
1761
1762 arr = (struct monst **) alloc(cnt * sizeof (struct monst *));
1763
1764 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
1765 if (DEADMONSTER(mtmp))
1766 continue;
1767 if (!canspotmon(mtmp))
1768 mtmp->mspotted = FALSE;
1769 else if (i < cnt)
1770 arr[i++] = mtmp;
1771 }
1772
1773 if (i) {
1774 qsort((genericptr_t) arr, (size_t) i, sizeof *arr,
1775 notice_mons_cmp);
1776
1777 for (j = 0; j < i; j++)
1778 notice_mon(arr[j]);
1779 }
1780
1781 free(arr);
1782 }
1783}
1784
1785/* maybe disturb buried zombies when an object is dropped or thrown nearby */
1786void

Callers 4

newgameFunction · 0.85
teledsFunction · 0.85
vision_recalcFunction · 0.85
goto_levelFunction · 0.85

Calls 3

qsortFunction · 0.85
notice_monFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected