long worm #stats

When #stats shows memory use for monsters, include long worm tails.
This commit is contained in:
PatR
2016-05-01 00:34:36 -07:00
parent 16c08f7296
commit 759544dd33
4 changed files with 29 additions and 11 deletions
+1
View File
@@ -2719,6 +2719,7 @@ E void FDECL(rest_worm, (int));
E void FDECL(place_wsegs, (struct monst *)); E void FDECL(place_wsegs, (struct monst *));
E void FDECL(remove_worm, (struct monst *)); E void FDECL(remove_worm, (struct monst *));
E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P)); E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
E int FDECL(size_wseg, (struct monst *));
E int FDECL(count_wsegs, (struct monst *)); E int FDECL(count_wsegs, (struct monst *));
E boolean FDECL(worm_known, (struct monst *)); E boolean FDECL(worm_known, (struct monst *));
E boolean FDECL(worm_cross, (int, int, int, int)); E boolean FDECL(worm_cross, (int, int, int, int));
+9 -3
View File
@@ -144,7 +144,7 @@ extern void FDECL(show_borlandc_stats, (winid));
#ifdef DEBUG_MIGRATING_MONS #ifdef DEBUG_MIGRATING_MONS
STATIC_PTR int NDECL(wiz_migrate_mons); STATIC_PTR int NDECL(wiz_migrate_mons);
#endif #endif
STATIC_DCL int FDECL(size_monst, (struct monst *)); STATIC_DCL int FDECL(size_monst, (struct monst *, BOOLEAN_P));
STATIC_DCL int FDECL(size_obj, (struct obj *)); STATIC_DCL int FDECL(size_obj, (struct obj *));
STATIC_DCL void FDECL(count_obj, (struct obj *, long *, long *, STATIC_DCL void FDECL(count_obj, (struct obj *, long *, long *,
BOOLEAN_P, BOOLEAN_P)); BOOLEAN_P, BOOLEAN_P));
@@ -3016,11 +3016,15 @@ long *total_size;
} }
STATIC_OVL int STATIC_OVL int
size_monst(mtmp) size_monst(mtmp, incl_wsegs)
struct monst *mtmp; struct monst *mtmp;
boolean incl_wsegs;
{ {
int sz = (int) sizeof (struct monst); int sz = (int) sizeof (struct monst);
if (mtmp->wormno && incl_wsegs)
sz += size_wseg(mtmp);
if (mtmp->mextra) { if (mtmp->mextra) {
sz += (int) sizeof (struct mextra); sz += (int) sizeof (struct mextra);
if (MNAME(mtmp)) if (MNAME(mtmp))
@@ -3052,11 +3056,13 @@ long *total_size;
char buf[BUFSZ]; char buf[BUFSZ];
long count, size; long count, size;
struct monst *mon; struct monst *mon;
/* mon->wormno means something different for migrating_mons and mydogs */
boolean incl_wsegs = !strcmpi(src, "fmon");
count = size = 0L; count = size = 0L;
for (mon = chain; mon; mon = mon->nmon) { for (mon = chain; mon; mon = mon->nmon) {
count++; count++;
size += size_monst(mon); size += size_monst(mon, incl_wsegs);
} }
if (count || size || force) { if (count || size || force) {
*total_count += count; *total_count += count;
+3
View File
@@ -1580,6 +1580,9 @@ struct monst **monst_list; /* &migrating_mons or &mydogs or null */
seemimic(mon); seemimic(mon);
} }
if (mon->wormno)
remove_worm(mon);
else
remove_monster(mx, my); remove_monster(mx, my);
if (mon == fmon) { if (mon == fmon) {
+8
View File
@@ -677,6 +677,14 @@ register xchar *nx, *ny;
: (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2))); : (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2)));
} }
/* for size_monst(cmd.c) to support #stats */
int
size_wseg(worm)
struct monst *worm;
{
return (int) (count_wsegs(worm) * sizeof (struct wseg));
}
/* count_wsegs() /* count_wsegs()
* returns the number of segments that a worm has. * returns the number of segments that a worm has.
*/ */