void docall(struct obj *obj) { char buf[BUFSZ], qbuf[QBUFSZ]; struct obj otemp; char **str1; if (!obj->dknown) return; /* probably blind */ otemp = *obj; otemp.quan = 1L; otemp.onamelth = 0; otemp.oxlth = 0; if (objects[otemp.otyp].oc_class == POTION_CLASS && otemp.fromsink) /* kludge, meaning it's sink water */ sprintf(qbuf,"Call a stream of %s fluid:", OBJ_DESCR(objects[otemp.otyp])); else sprintf(qbuf, "Call %s:", an(xname(&otemp))); getlin(qbuf, buf); if (!*buf || *buf == '\033') return; /* clear old name */ str1 = &(objects[obj->otyp].oc_uname); if (*str1) free(*str1); /* strip leading and trailing spaces; uncalls item if all spaces */ mungspaces(buf); if (!*buf) { if (*str1) { /* had name, so possibly remove from disco[] */ /* strip name first, for the update_inventory() call from undiscover_object() */ *str1 = NULL; undiscover_object(obj->otyp); } } else { *str1 = strcpy(malloc((unsigned)strlen(buf)+1), buf); discover_object(obj->otyp, FALSE, TRUE); /* possibly add to disco[] */ } }
/* like disclose, but don't ask any questions */ static void dump_disclose(int how) { struct obj *obj; /* temporarily redirect menu window output into the dumpfile */ dump_catch_menus(TRUE); /* re-"display" all the disclosure menus */ /* make sure the inventory is fully identified, even if DYWYPI = n */ for (obj = invent; obj; obj = obj->nobj) { discover_object(obj->otyp, TRUE, FALSE, TRUE); obj->known = obj->bknown = obj->dknown = obj->rknown = 1; } display_inventory(NULL, TRUE); container_contents(invent, TRUE, TRUE); dump_spells(); dump_skills(); enlighten_mon(&youmonst, how > LAST_KILLER ? 1 : 2, 1); /* final */ list_vanquished('y', FALSE); list_genocided('y', FALSE); show_conduct(how > LAST_KILLER ? 1 : 2); dooverview(&(struct nh_cmd_arg){.argtype = 0});
static void docall_inner(const struct nh_cmd_arg *arg, int otyp) { const char *qbuf, *buf; char **str1; const char *ot = obj_typename(otyp); qbuf = "Call "; if (strstr(ot, " boots") || strstr(ot, " gloves")) qbuf = msgcat(qbuf, ot); else qbuf = msgcat(qbuf, an(ot)); qbuf = msgcat(qbuf, ":"); buf = getarglin(arg, qbuf); if (!*buf || *buf == '\033') return; /* clear old name */ str1 = &(objects[otyp].oc_uname); if (*str1) free(*str1); /* strip leading and trailing spaces; uncalls item if all spaces */ buf = msgmungspaces(buf); if (!*buf) { if (*str1) { /* had name, so possibly remove from disco[] */ /* strip name first, for the update_inventory() call from undiscover_object() */ *str1 = (char *)0; undiscover_object(otyp); } } else { *str1 = strcpy((char *)malloc((unsigned)strlen(buf) + 1), buf); discover_object(otyp, FALSE, TRUE, TRUE); /* possibly add to disco[] */ } }
static void disclose(int how, boolean taken, long umoney) { char c = 0, defquery; const char *qbuf; boolean ask = should_query_disclose_options(&defquery); if (invent) { if (taken) qbuf = msgprintf("Do you want to see what you had when you %s?", (how == QUIT) ? "quit" : "died"); else /* This phrase is so fundamentally NetHack, I felt a huge sense of pride when I got to edit it, even though I was just changing it from a stack allocation to a string literal. Then I felt I should add a comment to it because it feels important enough to be dignified with one. So here it is. --AIS */ qbuf = "Do you want your possessions identified?"; if (!done_stopprint) { c = ask ? yn_function(qbuf, ynqchars, defquery) : defquery; if (c == 'y') { struct obj *obj; for (obj = invent; obj; obj = obj->nobj) { discover_object(obj->otyp, TRUE, FALSE, TRUE); obj->known = obj->bknown = obj->dknown = obj->rknown = 1; } display_inventory(NULL, FALSE); container_contents(invent, TRUE, TRUE); } if (c == 'q') done_stopprint++; } } if (!done_stopprint) { c = ask ? yn_function("Do you want to see your attributes?", ynqchars, defquery) : defquery; if (c == 'y') enlighten_mon(&youmonst, how > LAST_KILLER ? 1 : 2, 1); /* final */ if (c == 'q') done_stopprint++; } if (!done_stopprint) list_vanquished(defquery, ask); if (!done_stopprint) list_genocided(defquery, ask); if (!done_stopprint) { c = ask ? yn_function("Do you want to see your conduct?", ynqchars, defquery) : defquery; if (c == 'y') show_conduct(how > LAST_KILLER ? 1 : 2); if (c == 'q') done_stopprint++; } if (!done_stopprint) { c = ask ? yn_function("Do you want to see a breakdown of your score?", ynqchars, defquery) : defquery; if (c == 'y') calc_score(how, TRUE, umoney); if (c == 'q') done_stopprint++; } }