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

Function ggetobj

src/invent.c:2201–2369  ·  view source on GitHub ↗

Interactive version of getobj - used for Drop, Identify, and Takeoff (A). Return the number of times fn was called successfully. If combo is TRUE, we just use this to get a category list. */

Source from the content-addressed store, hash-verified

2199 Return the number of times fn was called successfully.
2200 If combo is TRUE, we just use this to get a category list. */
2201int
2202ggetobj(const char *word, int (*fn)(OBJ_P), int mx,
2203 boolean combo, /* combination menu flag */
2204 unsigned *resultflags)
2205{
2206 int (*ckfn)(OBJ_P) = (int (*)(OBJ_P)) 0;
2207 boolean (*ofilter)(OBJ_P) = (boolean (*)(OBJ_P)) 0;
2208 boolean takeoff, ident, allflag, m_seen;
2209 int itemcount;
2210 int oletct, iletct, unpaid, oc_of_sym;
2211 char sym, *ip, olets[MAXOCLASSES + 6], ilets[MAXOCLASSES + 11];
2212 char extra_removeables[3 + 1]; /* uwep,uswapwep,uquiver */
2213 char buf[BUFSZ] = DUMMY, qbuf[QBUFSZ];
2214
2215 if (!gi.invent) {
2216 You("have nothing to %s.", word);
2217 if (resultflags)
2218 *resultflags = ALL_FINISHED;
2219 return 0;
2220 }
2221 if (resultflags)
2222 *resultflags = 0;
2223 takeoff = ident = allflag = m_seen = FALSE;
2224 add_valid_menu_class(0); /* reset */
2225 if (taking_off(word)) {
2226 takeoff = TRUE;
2227 ofilter = is_worn;
2228 } else if (!strcmp(word, "identify")) {
2229 ident = TRUE;
2230 ofilter = not_fully_identified;
2231 }
2232
2233 iletct = collect_obj_classes(ilets, gi.invent, FALSE, ofilter,
2234 &itemcount);
2235 unpaid = count_unpaid(gi.invent);
2236
2237 if (ident && !iletct) {
2238 return -1; /* no further identifications */
2239 } else if (gi.invent) {
2240 ilets[iletct++] = ' ';
2241 if (unpaid)
2242 ilets[iletct++] = 'u';
2243 if (count_buc(gi.invent, BUC_BLESSED, ofilter))
2244 ilets[iletct++] = 'B';
2245 if (count_buc(gi.invent, BUC_UNCURSED, ofilter))
2246 ilets[iletct++] = 'U';
2247 if (count_buc(gi.invent, BUC_CURSED, ofilter))
2248 ilets[iletct++] = 'C';
2249 if (count_buc(gi.invent, BUC_UNKNOWN, ofilter))
2250 ilets[iletct++] = 'X';
2251 if (count_justpicked(gi.invent))
2252 ilets[iletct++] = 'P';
2253 ilets[iletct++] = 'a';
2254 }
2255 ilets[iletct++] = 'i';
2256 if (!combo)
2257 ilets[iletct++] = 'm'; /* allow menu presentation on request */
2258 ilets[iletct] = '\0';

Callers 5

doddoremarmFunction · 0.85
menu_remarmFunction · 0.85
doddropFunction · 0.85
menu_dropFunction · 0.85
identify_packFunction · 0.85

Calls 15

YouFunction · 0.85
add_valid_menu_classFunction · 0.85
taking_offFunction · 0.85
collect_obj_classesFunction · 0.85
count_unpaidFunction · 0.85
count_bucFunction · 0.85
count_justpickedFunction · 0.85
getlinFunction · 0.85
strkittenFunction · 0.85
display_inventoryFunction · 0.85
def_char_to_objclassFunction · 0.85
wearing_armorFunction · 0.85

Tested by

no test coverage detected