* Display a list of buried or underwater items in inventory style. * Return a non-zero value if there were items at that spot. * * Currently, this is only used with a wand of probing zapped downwards. */
| 5486 | * Currently, this is only used with a wand of probing zapped downwards. |
| 5487 | */ |
| 5488 | int |
| 5489 | display_binventory(coordxy x, coordxy y, boolean as_if_seen) |
| 5490 | { |
| 5491 | struct obj *obj; |
| 5492 | char qbuf[QBUFSZ]; |
| 5493 | const char *underwhat = "here"; |
| 5494 | menu_item *selected = 0; |
| 5495 | int n, n2 = 0; |
| 5496 | |
| 5497 | /* if hero is levitating or flying over water or lava, list any items |
| 5498 | below (the map won't be showing them); if hero is underwater, player |
| 5499 | should use the normal look_here command instead of probing (caller |
| 5500 | has already used bhitpile() which will have set dknown on all items) */ |
| 5501 | if (is_pool_or_lava(x, y) && !Underwater |
| 5502 | && (obj = svl.level.objects[x][y]) != 0) { |
| 5503 | const char *real_liquid = is_pool(x, y) ? "water" : "lava", |
| 5504 | *seen_liquid = hliquid(real_liquid); |
| 5505 | |
| 5506 | if (!obj->nexthere) { |
| 5507 | boolean more_than_1 = is_plural(obj); |
| 5508 | |
| 5509 | There("%s %s under the %s here.", more_than_1 ? "are" : "is", |
| 5510 | doname(obj), seen_liquid); |
| 5511 | n2 = 1; |
| 5512 | /* "pair of boots" is singular but "beneath it" sounds strange */ |
| 5513 | if (pair_of(obj)) |
| 5514 | more_than_1 = TRUE; |
| 5515 | underwhat = more_than_1 ? "under them" : "beneath it"; |
| 5516 | } else { |
| 5517 | Sprintf(qbuf, "Things that are under the %s here:", seen_liquid); |
| 5518 | if (query_objlist(qbuf, &svl.level.objects[x][y], BY_NEXTHERE, |
| 5519 | &selected, PICK_NONE, allow_all) > 0) |
| 5520 | free((genericptr_t) selected), selected = 0; |
| 5521 | for (n2 = 0; obj; obj = obj->nexthere) |
| 5522 | ++n2; |
| 5523 | underwhat = "beneath them"; |
| 5524 | } |
| 5525 | } |
| 5526 | |
| 5527 | /* count # of buried objects here */ |
| 5528 | for (n = 0, obj = svl.level.buriedobjlist; obj; obj = obj->nobj) |
| 5529 | if (obj->ox == x && obj->oy == y) { |
| 5530 | if (as_if_seen) |
| 5531 | observe_object(obj); |
| 5532 | n++; |
| 5533 | } |
| 5534 | |
| 5535 | if (n) { |
| 5536 | go.only.x = x; |
| 5537 | go.only.y = y; |
| 5538 | /* "buried here", but vary if we've already shown underwater items */ |
| 5539 | Sprintf(qbuf, "Things that are buried %s:", underwhat); |
| 5540 | if (query_objlist(qbuf, &svl.level.buriedobjlist, INVORDER_SORT, |
| 5541 | &selected, PICK_NONE, only_here) > 0) |
| 5542 | free((genericptr_t) selected); |
| 5543 | go.only.x = go.only.y = 0; |
| 5544 | } |
| 5545 | return n + n2; |
no test coverage detected