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. */
| 2199 | Return the number of times fn was called successfully. |
| 2200 | If combo is TRUE, we just use this to get a category list. */ |
| 2201 | int |
| 2202 | ggetobj(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'; |
no test coverage detected