sanity check for objects on specified list (fobj, &c) */
| 3029 | |
| 3030 | /* sanity check for objects on specified list (fobj, &c) */ |
| 3031 | staticfn void |
| 3032 | objlist_sanity(struct obj *objlist, int wheretype, const char *mesg) |
| 3033 | { |
| 3034 | struct obj *obj; |
| 3035 | |
| 3036 | for (obj = objlist; obj; obj = obj->nobj) { |
| 3037 | if (obj->where != wheretype) |
| 3038 | insane_object(obj, ofmt0, mesg, (struct monst *) 0); |
| 3039 | if (obj->where == OBJ_INVENT && obj->how_lost != LOST_NONE) { |
| 3040 | char lostbuf[40]; |
| 3041 | |
| 3042 | /* %d: bitfield is unsigned but narrow, so promotes to int */ |
| 3043 | Sprintf(lostbuf, "how_lost=%d obj in inventory!", obj->how_lost); |
| 3044 | insane_object(obj, ofmt0, lostbuf, (struct monst *) 0); |
| 3045 | } |
| 3046 | if (Has_contents(obj)) { |
| 3047 | if (wheretype == OBJ_ONBILL) |
| 3048 | /* containers on shop bill should always be empty */ |
| 3049 | insane_object(obj, "%s obj contains something! %s %s: %s", |
| 3050 | mesg, (struct monst *) 0); |
| 3051 | check_contained(obj, mesg); |
| 3052 | } |
| 3053 | if (obj->unpaid || obj->no_charge) { |
| 3054 | shop_obj_sanity(obj, mesg); |
| 3055 | } |
| 3056 | if (obj->owornmask) { |
| 3057 | char maskbuf[40]; |
| 3058 | boolean bc_ok = FALSE; |
| 3059 | |
| 3060 | switch (obj->where) { |
| 3061 | case OBJ_INVENT: |
| 3062 | case OBJ_MINVENT: |
| 3063 | sanity_check_worn(obj); |
| 3064 | break; |
| 3065 | case OBJ_MIGRATING: |
| 3066 | /* migrating objects overload the owornmask field |
| 3067 | with a destination code; skip attempt to check it */ |
| 3068 | break; |
| 3069 | case OBJ_FLOOR: |
| 3070 | /* note: ball and chain can also be OBJ_FREE, but not across |
| 3071 | turns so this sanity check shouldn't encounter that */ |
| 3072 | bc_ok = TRUE; |
| 3073 | FALLTHROUGH; |
| 3074 | /*FALLTHRU*/ |
| 3075 | default: |
| 3076 | if ((obj != uchain && obj != uball) || !bc_ok) { |
| 3077 | /* discovered an object not in inventory which |
| 3078 | erroneously has worn mask set */ |
| 3079 | Sprintf(maskbuf, "worn mask 0x%08lx", obj->owornmask); |
| 3080 | insane_object(obj, ofmt0, maskbuf, (struct monst *) 0); |
| 3081 | } |
| 3082 | break; |
| 3083 | } |
| 3084 | } |
| 3085 | if (obj->otyp == LEASH && obj->leashmon) { |
| 3086 | char buf[BUFSZ]; |
| 3087 | struct monst *mtmp = find_mid(obj->leashmon, FM_FMON); |
| 3088 |
no test coverage detected