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

Function let_to_name

src/invent.c:4797–4839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4795static NEARDATA const char *oth_names[] = { "Bagged/Boxed items" };
4796
4797DISABLE_WARNING_FORMAT_NONLITERAL
4798
4799char *
4800let_to_name(char let, boolean unpaid, boolean showsym)
4801{
4802 const char *ocsymfmt = " ('%c')";
4803 const int invbuf_sympadding = 8; /* arbitrary */
4804 const char *class_name;
4805 const char *pos;
4806 int oclass = (let >= 1 && let < MAXOCLASSES) ? let : 0;
4807 unsigned len;
4808
4809 if (oclass)
4810 class_name = names[oclass];
4811 else if ((pos = strchr(oth_symbols, let)) != 0)
4812 class_name = oth_names[pos - oth_symbols];
4813 else
4814 class_name = names[ILLOBJ_CLASS];
4815
4816 len = Strlen(class_name) + (unpaid ? sizeof "unpaid_" : sizeof "")
4817 + (oclass ? (Strlen(ocsymfmt) + invbuf_sympadding) : 0);
4818 if (len > gi.invbufsiz) {
4819 if (gi.invbuf)
4820 free((genericptr_t) gi.invbuf);
4821 gi.invbufsiz = len + 10; /* add slop to reduce incremental realloc */
4822 gi.invbuf = (char *) alloc(gi.invbufsiz);
4823 }
4824 if (unpaid)
4825 Strcat(strcpy(gi.invbuf, "Unpaid "), class_name);
4826 else
4827 Strcpy(gi.invbuf, class_name);
4828 if ((oclass != 0) && showsym) {
4829 char *bp = eos(gi.invbuf);
4830 int mlen = invbuf_sympadding - Strlen(class_name);
4831 while (--mlen > 0) {
4832 *bp = ' ';
4833 bp++;
4834 }
4835 *bp = '\0';
4836 Sprintf(eos(gi.invbuf), ocsymfmt, def_oc_syms[oclass].sym);
4837 }
4838 return gi.invbuf;
4839}
4840
4841RESTORE_WARNING_FORMAT_NONLITERAL
4842

Callers 9

dodiscoveredFunction · 0.85
oclass_to_nameFunction · 0.85
doclassdiscoFunction · 0.85
rename_discoFunction · 0.85
invent.cFile · 0.85
display_used_invletsFunction · 0.85
dounpaidFunction · 0.85
query_objlistFunction · 0.85
query_categoryFunction · 0.85

Calls 2

eosFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected