MCPcopy Index your code
hub / github.com/NetHack/NetHack / docall

Function docall

src/do_name.c:635–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635void
636docall(struct obj *obj)
637{
638 char buf[BUFSZ], qbuf[QBUFSZ];
639 char **uname_p;
640 boolean had_name = FALSE;
641
642 if (!obj->dknown)
643 return; /* probably blind; Blind || Hallucination for 'fromsink' */
644 flush_screen(1); /* buffered updates might matter to player's response */
645
646 if (obj->oclass == POTION_CLASS && obj->fromsink)
647 /* fromsink: kludge, meaning it's sink water */
648 Sprintf(qbuf, "Call a stream of %s fluid:",
649 OBJ_DESCR(objects[obj->otyp]));
650 else
651 (void) safe_qbuf(qbuf, "Call ", ":", obj,
652 docall_xname, simpleonames, "thing");
653 /* pointer to old name */
654 uname_p = &(objects[obj->otyp].oc_uname);
655 /* use getlin() to get a name string from the player */
656 if (!name_from_player(buf, qbuf, *uname_p))
657 return;
658
659 /* clear old name */
660 if (*uname_p) {
661 had_name = TRUE;
662 free((genericptr_t) *uname_p), *uname_p = NULL; /* clear oc_uname */
663 }
664
665 /* strip leading and trailing spaces; uncalls item if all spaces */
666 (void) mungspaces(buf);
667 if (!*buf) {
668 if (had_name) /* possibly remove from disco[]; old *uname_p is gone */
669 undiscover_object(obj->otyp);
670 } else {
671 *uname_p = dupstr(buf);
672 discover_object(obj->otyp, FALSE, TRUE, TRUE); /* possibly add to disco[] */
673 }
674 if (obj->where == OBJ_INVENT || carrying(obj->otyp))
675 update_inventory();
676}
677
678staticfn void
679namefloorobj(void)

Callers 5

rename_discoFunction · 0.85
docallcmdFunction · 0.85
namefloorobjFunction · 0.85
potion_dipFunction · 0.85
trycallFunction · 0.85

Calls 9

flush_screenFunction · 0.85
safe_qbufFunction · 0.85
name_from_playerFunction · 0.85
mungspacesFunction · 0.85
undiscover_objectFunction · 0.85
dupstrFunction · 0.85
discover_objectFunction · 0.85
carryingFunction · 0.85
update_inventoryFunction · 0.85

Tested by

no test coverage detected