count everything inside a container, or just shop-owned items inside */
| 3617 | |
| 3618 | /* count everything inside a container, or just shop-owned items inside */ |
| 3619 | long |
| 3620 | count_contents( |
| 3621 | struct obj *container, |
| 3622 | boolean nested, /* include contents of any nested containers */ |
| 3623 | boolean quantity, /* count all vs count separate stacks */ |
| 3624 | boolean everything, /* all objects vs only unpaid objects */ |
| 3625 | boolean newdrop) /* on floor, but hero-owned items haven't |
| 3626 | * been marked no_charge yet and shop-owned |
| 3627 | * items are still marked unpaid -- used |
| 3628 | * when asking the player whether to sell */ |
| 3629 | { |
| 3630 | struct obj *otmp, *topc; |
| 3631 | boolean shoppy = FALSE; |
| 3632 | long count = 0L; |
| 3633 | |
| 3634 | if (!everything && !newdrop) { |
| 3635 | coordxy x, y; |
| 3636 | |
| 3637 | for (topc = container; topc->where == OBJ_CONTAINED; |
| 3638 | topc = topc->ocontainer) |
| 3639 | continue; |
| 3640 | if (topc->where == OBJ_FLOOR && get_obj_location(topc, &x, &y, 0)) |
| 3641 | shoppy = costly_spot(x, y); |
| 3642 | } |
| 3643 | for (otmp = container->cobj; otmp; otmp = otmp->nobj) { |
| 3644 | if (nested && Has_contents(otmp)) |
| 3645 | count += count_contents(otmp, nested, quantity, everything, |
| 3646 | newdrop); |
| 3647 | if (everything || otmp->unpaid || (shoppy && !otmp->no_charge)) |
| 3648 | count += quantity ? otmp->quan : 1L; |
| 3649 | } |
| 3650 | return count; |
| 3651 | } |
| 3652 | |
| 3653 | staticfn void |
| 3654 | dounpaid( |
no test coverage detected