MCPcopy Create free account
hub / github.com/NetHack/NetHack / display_cinventory

Function display_cinventory

src/invent.c:5445–5473  ·  view source on GitHub ↗

Display the contents of a container in inventory style. Used for wand of probing of non-empty containers and statues. */

Source from the content-addressed store, hash-verified

5443/* Display the contents of a container in inventory style.
5444 Used for wand of probing of non-empty containers and statues. */
5445struct obj *
5446display_cinventory(struct obj *obj)
5447{
5448 struct obj *ret;
5449 char qbuf[QBUFSZ];
5450 int n;
5451 menu_item *selected = 0;
5452
5453 (void) safe_qbuf(qbuf, "Contents of ", ":", obj,
5454 /* custom formatting routines to insert "trapped"
5455 into the object's name when appropriate;
5456 last resort "that" won't ever get used */
5457 cinv_doname, cinv_ansimpleoname, "that");
5458
5459 if (obj->cobj) {
5460 n = query_objlist(qbuf, &(obj->cobj), INVORDER_SORT,
5461 &selected, PICK_NONE, allow_all);
5462 } else {
5463 invdisp_nothing(qbuf, "(empty)");
5464 n = 0;
5465 }
5466 if (n > 0) {
5467 ret = selected[0].item.a_obj;
5468 free((genericptr_t) selected);
5469 } else
5470 ret = (struct obj *) 0;
5471 obj->cknown = 1;
5472 return ret;
5473}
5474
5475
5476staticfn boolean

Callers 1

bhitoFunction · 0.85

Calls 3

safe_qbufFunction · 0.85
query_objlistFunction · 0.85
invdisp_nothingFunction · 0.85

Tested by

no test coverage detected