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

Function wiz_show_stats

src/wizcmds.c:1615–1697  ·  view source on GitHub ↗

the #stats command * Display memory usage of all monsters and objects on the level. */

Source from the content-addressed store, hash-verified

1613 * Display memory usage of all monsters and objects on the level.
1614 */
1615int
1616wiz_show_stats(void)
1617{
1618 char buf[BUFSZ];
1619 winid win;
1620 long total_obj_size, total_obj_count,
1621 total_mon_size, total_mon_count,
1622 total_ovr_size, total_ovr_count,
1623 total_misc_size, total_misc_count;
1624
1625 win = create_nhwindow(NHW_TEXT);
1626 putstr(win, 0, "Current memory statistics:");
1627
1628 total_obj_count = total_obj_size = 0L;
1629 putstr(win, 0, stats_hdr);
1630 Sprintf(buf, " Objects, base size %ld", (long) sizeof (struct obj));
1631 putstr(win, 0, buf);
1632 obj_chain(win, "invent", gi.invent, TRUE,
1633 &total_obj_count, &total_obj_size);
1634 obj_chain(win, "fobj", fobj, TRUE, &total_obj_count, &total_obj_size);
1635 obj_chain(win, "buried", svl.level.buriedobjlist, FALSE,
1636 &total_obj_count, &total_obj_size);
1637 obj_chain(win, "migrating obj", gm.migrating_objs, FALSE,
1638 &total_obj_count, &total_obj_size);
1639 obj_chain(win, "billobjs", gb.billobjs, FALSE,
1640 &total_obj_count, &total_obj_size);
1641 mon_invent_chain(win, "minvent", fmon, &total_obj_count, &total_obj_size);
1642 mon_invent_chain(win, "migrating minvent", gm.migrating_mons,
1643 &total_obj_count, &total_obj_size);
1644 contained_stats(win, "contained", &total_obj_count, &total_obj_size);
1645 putstr(win, 0, stats_sep);
1646 Sprintf(buf, template, " Obj total", total_obj_count, total_obj_size);
1647 putstr(win, 0, buf);
1648
1649 total_mon_count = total_mon_size = 0L;
1650 putstr(win, 0, "");
1651 Sprintf(buf, " Monsters, base size %ld", (long) sizeof (struct monst));
1652 putstr(win, 0, buf);
1653 mon_chain(win, "fmon", fmon, TRUE, &total_mon_count, &total_mon_size);
1654 mon_chain(win, "migrating", gm.migrating_mons, FALSE,
1655 &total_mon_count, &total_mon_size);
1656 /* 'gm.mydogs' is only valid during level change or end of game disclosure,
1657 but conceivably we've been called from within debugger at such time */
1658 if (gm.mydogs) /* monsters accompanying hero */
1659 mon_chain(win, "mydogs", gm.mydogs, FALSE,
1660 &total_mon_count, &total_mon_size);
1661 putstr(win, 0, stats_sep);
1662 Sprintf(buf, template, " Mon total", total_mon_count, total_mon_size);
1663 putstr(win, 0, buf);
1664
1665 total_ovr_count = total_ovr_size = 0L;
1666 putstr(win, 0, "");
1667 putstr(win, 0, " Overview");
1668 overview_stats(win, template, &total_ovr_count, &total_ovr_size);
1669 putstr(win, 0, stats_sep);
1670 Sprintf(buf, template, " Over total", total_ovr_count, total_ovr_size);
1671 putstr(win, 0, buf);
1672

Callers

nothing calls this directly

Calls 7

obj_chainFunction · 0.85
mon_invent_chainFunction · 0.85
contained_statsFunction · 0.85
mon_chainFunction · 0.85
overview_statsFunction · 0.85
misc_statsFunction · 0.85
show_borlandc_statsFunction · 0.85

Tested by

no test coverage detected