extend wizard-mode '#stats' command
Extend #stats beyond just monsters and objects. Have it display memory usage for traps, engravings, light sources, timers, pending shop wall/floor repair, regions, bones tracking, named object types, and dungeon overview. No doubt there are other memory consumers that I've overlooked.
This commit is contained in:
45
src/region.c
45
src/region.c
@@ -95,14 +95,13 @@ int nrect;
|
||||
if (nrect > 0) {
|
||||
reg->bounding_box = rects[0];
|
||||
} else {
|
||||
reg->bounding_box.lx = 99;
|
||||
reg->bounding_box.ly = 99;
|
||||
reg->bounding_box.hx = 0;
|
||||
reg->bounding_box.lx = COLNO;
|
||||
reg->bounding_box.ly = ROWNO;
|
||||
reg->bounding_box.hx = 0; /* 1 */
|
||||
reg->bounding_box.hy = 0;
|
||||
}
|
||||
reg->nrects = nrect;
|
||||
reg->rects =
|
||||
nrect > 0 ? (NhRect *) alloc((sizeof(NhRect)) * nrect) : (NhRect *) 0;
|
||||
reg->rects = (nrect > 0) ? (NhRect *) alloc(nrect * sizeof (NhRect)) : 0;
|
||||
for (i = 0; i < nrect; i++) {
|
||||
if (rects[i].lx < reg->bounding_box.lx)
|
||||
reg->bounding_box.lx = rects[i].lx;
|
||||
@@ -145,10 +144,10 @@ NhRect *rect;
|
||||
{
|
||||
NhRect *tmp_rect;
|
||||
|
||||
tmp_rect = (NhRect *) alloc(sizeof(NhRect) * (reg->nrects + 1));
|
||||
tmp_rect = (NhRect *) alloc((reg->nrects + 1) * sizeof (NhRect));
|
||||
if (reg->nrects > 0) {
|
||||
(void) memcpy((genericptr_t) tmp_rect, (genericptr_t) reg->rects,
|
||||
(sizeof(NhRect) * reg->nrects));
|
||||
reg->nrects * sizeof (NhRect));
|
||||
free((genericptr_t) reg->rects);
|
||||
}
|
||||
tmp_rect[reg->nrects] = *rect;
|
||||
@@ -177,7 +176,7 @@ struct monst *mon;
|
||||
unsigned *tmp_m;
|
||||
|
||||
if (reg->max_monst <= reg->n_monst) {
|
||||
tmp_m = (unsigned *) alloc(sizeof(unsigned)
|
||||
tmp_m = (unsigned *) alloc(sizeof (unsigned)
|
||||
* (reg->max_monst + MONST_INC));
|
||||
if (reg->max_monst > 0) {
|
||||
for (i = 0; i < reg->max_monst; i++)
|
||||
@@ -297,10 +296,10 @@ NhRegion *reg;
|
||||
if (max_regions <= n_regions) {
|
||||
tmp_reg = regions;
|
||||
regions =
|
||||
(NhRegion **) alloc(sizeof(NhRegion *) * (max_regions + 10));
|
||||
(NhRegion **) alloc((max_regions + 10) * sizeof (NhRegion *));
|
||||
if (max_regions > 0) {
|
||||
(void) memcpy((genericptr_t) regions, (genericptr_t) tmp_reg,
|
||||
max_regions * sizeof(NhRegion *));
|
||||
max_regions * sizeof (NhRegion *));
|
||||
free((genericptr_t) tmp_reg);
|
||||
}
|
||||
max_regions += 10;
|
||||
@@ -763,6 +762,32 @@ boolean ghostly; /* If a bones file restore */
|
||||
reset_region_mids(regions[i]);
|
||||
}
|
||||
|
||||
/* to support '#stats' wizard-mode command */
|
||||
void
|
||||
region_stats(hdrfmt, hdrbuf, count, size)
|
||||
const char *hdrfmt;
|
||||
char *hdrbuf;
|
||||
long *count, *size;
|
||||
{
|
||||
NhRegion *rg;
|
||||
int i;
|
||||
|
||||
/* other stats formats take one parameter; this takes two */
|
||||
Sprintf(hdrbuf, hdrfmt, (long) sizeof (NhRegion), (long) sizeof (NhRect));
|
||||
*count = (long) n_regions; /* might be 0 even though max_regions isn't */
|
||||
*size = (long) max_regions * (long) sizeof (NhRegion);
|
||||
for (i = 0; i < n_regions; ++i) {
|
||||
rg = regions[i];
|
||||
*size += (long) rg->nrects * (long) sizeof (NhRect);
|
||||
if (rg->enter_msg)
|
||||
*size += (long) (strlen(rg->enter_msg) + 1);
|
||||
if (rg->leave_msg)
|
||||
*size += (long) (strlen(rg->leave_msg) + 1);
|
||||
*size += (long) rg->max_monst * (long) sizeof *rg->monsters;
|
||||
}
|
||||
/* ? */
|
||||
}
|
||||
|
||||
/* update monster IDs for region being loaded from bones; `ghostly' implied */
|
||||
STATIC_OVL void
|
||||
reset_region_mids(reg)
|
||||
|
||||
Reference in New Issue
Block a user