for 'sanity_check' option, called by you_sanity_check() */
| 352 | |
| 353 | /* for 'sanity_check' option, called by you_sanity_check() */ |
| 354 | void |
| 355 | check_wornmask_slots(void) |
| 356 | { |
| 357 | /* we'll skip ball and chain here--they warrant separate sanity check */ |
| 358 | #define IGNORE_SLOTS (W_ART | W_ARTI | W_SADDLE | W_BALL| W_CHAIN) |
| 359 | char whybuf[BUFSZ]; |
| 360 | const struct worn *wp; |
| 361 | struct obj *o, *otmp; |
| 362 | long m; |
| 363 | |
| 364 | for (wp = worn; wp->w_mask; wp++) { |
| 365 | m = wp->w_mask; |
| 366 | if ((m & IGNORE_SLOTS) != 0L && (m & ~IGNORE_SLOTS) == 0L) |
| 367 | continue; |
| 368 | if ((o = *wp->w_obj) != 0) { |
| 369 | whybuf[0] = '\0'; |
| 370 | /* slot pointer (uarm, uwep, &c) is populated; check that object |
| 371 | is in inventory and has the relevant owornmask bit set */ |
| 372 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) |
| 373 | if (otmp == o) |
| 374 | break; |
| 375 | if (!otmp) |
| 376 | Sprintf(whybuf, "%s (%s) not found in invent", |
| 377 | wp->w_what, fmt_ptr(o)); |
| 378 | else if ((o->owornmask & m) == 0L) |
| 379 | Sprintf(whybuf, "%s bit not set in owornmask [0x%08lx]", |
| 380 | wp->w_what, o->owornmask); |
| 381 | else if ((o->owornmask & ~(m | IGNORE_SLOTS)) != 0L) |
| 382 | Sprintf(whybuf, "%s wrong bit set in owornmask [0x%08lx]", |
| 383 | wp->w_what, o->owornmask); |
| 384 | if (whybuf[0]) |
| 385 | impossible("Worn-slot insanity: %s.", whybuf); |
| 386 | } /* o != NULL */ |
| 387 | |
| 388 | /* check whether any item other than the one in the slot pointer |
| 389 | claims to be worn/wielded in this slot; make this test whether |
| 390 | 'o' is Null or not; [sanity_check_worn(mkobj.c) for object by |
| 391 | object checking will most likely have already caught this] */ |
| 392 | for (otmp = gi.invent; otmp; otmp = otmp->nobj) { |
| 393 | if (otmp != o && (otmp->owornmask & m) != 0L |
| 394 | /* embedded scales owornmask is W_ARM|I_SPECIAL so would |
| 395 | give a false complaint about item other than uarm having |
| 396 | W_ARM bit set if we didn't screen it out here */ |
| 397 | && (m != W_ARM || otmp != uskin |
| 398 | || (otmp->owornmask & I_SPECIAL) == 0L)) { |
| 399 | Sprintf(whybuf, "%s [0x%08lx] has %s mask 0x%08lx bit set", |
| 400 | simpleonames(otmp), otmp->owornmask, wp->w_what, m); |
| 401 | impossible("Worn-slot insanity: %s.", whybuf); |
| 402 | } |
| 403 | } |
| 404 | } /* for wp in worn[] */ |
| 405 | |
| 406 | #ifdef EXTRA_SANITY_CHECKS |
| 407 | if (uskin) { |
| 408 | const char *what = "embedded scales"; |
| 409 | |
| 410 | o = uskin; |
| 411 | m = W_ARM | I_SPECIAL; |
no test coverage detected