| 3445 | } |
| 3446 | |
| 3447 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 3448 | |
| 3449 | /* decide whether a shopkeeper thinks an item belongs to her */ |
| 3450 | boolean |
| 3451 | billable( |
| 3452 | struct monst **shkpp, /* in: non-null if shk has been validated; |
| 3453 | * out: shk */ |
| 3454 | struct obj *obj, |
| 3455 | char roomno, |
| 3456 | boolean reset_nocharge) |
| 3457 | { |
| 3458 | struct monst *shkp = *shkpp; |
| 3459 | |
| 3460 | /* if caller hasn't supplied a shopkeeper, look one up now */ |
| 3461 | if (!shkp) { |
| 3462 | if (!roomno) |
| 3463 | return FALSE; |
| 3464 | shkp = shop_keeper(roomno); |
| 3465 | if (!shkp || !inhishop(shkp)) |
| 3466 | return FALSE; |
| 3467 | *shkpp = shkp; |
| 3468 | } |
| 3469 | /* perhaps we threw it away earlier */ |
| 3470 | if (onbill(obj, shkp, FALSE) |
| 3471 | || (obj->oclass == FOOD_CLASS && obj->oeaten)) |
| 3472 | return FALSE; |
| 3473 | /* outer container might be marked no_charge but still have contents |
| 3474 | which should be charged for; clear no_charge when picking things up */ |
| 3475 | if (obj->no_charge) { |
| 3476 | if (!Has_contents(obj) || (contained_gold(obj, TRUE) == 0L |
| 3477 | && contained_cost(obj, shkp, 0L, FALSE, |
| 3478 | !reset_nocharge) == 0L)) |
| 3479 | shkp = 0; /* not billable */ |
| 3480 | if (reset_nocharge && !shkp && obj->oclass != COIN_CLASS) { |
| 3481 | obj->no_charge = 0; |
| 3482 | if (Has_contents(obj)) |
| 3483 | picked_container(obj); /* clear no_charge */ |
| 3484 | } |
| 3485 | } |
| 3486 | return shkp ? TRUE : FALSE; |
| 3487 | } |
| 3488 | |
| 3489 | void |
| 3490 | addtobill( |
no test coverage detected