예제 #1
0
파일: environ.c 프로젝트: 74AC153/paren
static int print_env_cb(node_t *env, void *p)
{
	char buf[17];
	stream_t *s = (stream_t *) p;
	stream_putln(s, "env frame @ ", fmt_ptr(buf, env), ":");
	return 0;
}
예제 #2
0
/* obj sanity check: check objs contained by container */
STATIC_OVL void
check_contained(struct obj *container, const char *mesg)
{
    struct obj *obj;
    char obj1_address[20], obj2_address[20];

    for (obj = container->cobj; obj; obj = obj->nobj) {
        if (obj->where != OBJ_CONTAINED)
            pline("contained %s obj %s: %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj1_address),
                  where_name(obj->where));
        else if (obj->ocontainer != container)
            pline("%s obj %s not in container %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj1_address),
                  fmt_ptr((genericptr_t)container, obj2_address));
    }
}
예제 #3
0
/* Check all object lists for consistency. */
void
obj_sanity_check(void)
{
    int x, y;
    struct obj *obj;
    struct monst *mon;
    const char *mesg;
    char obj_address[20], mon_address[20];  /* room for formatted pointers */

    mesg = "fobj sanity";
    for (obj = fobj; obj; obj = obj->nobj) {
        if (obj->where != OBJ_FLOOR) {
            pline("%s obj %s %s@(%d,%d): %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  where_name(obj->where),
                  obj->ox, obj->oy, doname(obj));
        }
        check_contained(obj, mesg);
    }

    mesg = "location sanity";
    for (x = 0; x < COLNO; x++)
        for (y = 0; y < ROWNO; y++)
            for (obj = level.objects[x][y]; obj; obj = obj->nexthere)
                if (obj->where != OBJ_FLOOR) {
                    pline("%s obj %s %s@(%d,%d): %s\n", mesg,
                          fmt_ptr((genericptr_t)obj, obj_address),
                          where_name(obj->where),
                          obj->ox, obj->oy, doname(obj));
                }

    mesg = "invent sanity";
    for (obj = invent; obj; obj = obj->nobj) {
        if (obj->where != OBJ_INVENT) {
            pline("%s obj %s %s: %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  where_name(obj->where), doname(obj));
        }
        check_contained(obj, mesg);
    }

    mesg = "migrating sanity";
    for (obj = migrating_objs; obj; obj = obj->nobj) {
        if (obj->where != OBJ_MIGRATING) {
            pline("%s obj %s %s: %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  where_name(obj->where), doname(obj));
        }
        check_contained(obj, mesg);
    }

    mesg = "buried sanity";
    for (obj = level.buriedobjlist; obj; obj = obj->nobj) {
        if (obj->where != OBJ_BURIED) {
            pline("%s obj %s %s: %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  where_name(obj->where), doname(obj));
        }
        check_contained(obj, mesg);
    }

    mesg = "bill sanity";
    for (obj = billobjs; obj; obj = obj->nobj) {
        if (obj->where != OBJ_ONBILL) {
            pline("%s obj %s %s: %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  where_name(obj->where), doname(obj));
        }
        /* shouldn't be a full container on the bill */
        if (obj->cobj) {
            pline("%s obj %s contains %s! %s\n", mesg,
                  fmt_ptr((genericptr_t)obj, obj_address),
                  something, doname(obj));
        }
    }

    mesg = "minvent sanity";
    for (mon = fmon; mon; mon = mon->nmon)
        for (obj = mon->minvent; obj; obj = obj->nobj) {
            if (obj->where != OBJ_MINVENT) {
                pline("%s obj %s %s: %s\n", mesg,
                      fmt_ptr((genericptr_t)obj, obj_address),
                      where_name(obj->where), doname(obj));
            }
            if (obj->ocarry != mon) {
                pline("%s obj %s (%s) not held by mon %s (%s)\n", mesg,
                      fmt_ptr((genericptr_t)obj, obj_address),
                      doname(obj),
                      fmt_ptr((genericptr_t)mon, mon_address),
                      mon_nam(mon));
            }
            check_contained(obj, mesg);
        }
}