doname() for itemized buying of 'obj' from a shop */
| 2310 | |
| 2311 | /* doname() for itemized buying of 'obj' from a shop */ |
| 2312 | char * |
| 2313 | paydoname(struct obj *obj) |
| 2314 | { |
| 2315 | static const char and_contents[] = " and its contents"; |
| 2316 | char *p; |
| 2317 | unsigned save_cknown = obj->cknown; |
| 2318 | boolean save_wizweight = iflags.wizweight; |
| 2319 | |
| 2320 | if (Has_contents(obj)) |
| 2321 | obj->cknown = 0; |
| 2322 | /* avoid showing item weights to unclutter billing's pay-menu a bit */ |
| 2323 | iflags.wizweight = FALSE; |
| 2324 | /* suppress invent-style price; caller will add billing-style price */ |
| 2325 | iflags.suppress_price++; |
| 2326 | p = doname_base(obj, 0U); |
| 2327 | iflags.suppress_price--; |
| 2328 | iflags.wizweight = save_wizweight; |
| 2329 | |
| 2330 | if (Has_contents(obj)) { |
| 2331 | /* buy_container() sets no_charge for a container that has just |
| 2332 | been purchased so that when paydoname() is called by |
| 2333 | shk_names_obj(), we'll provide "a/an <container>" instead of |
| 2334 | "your <container>" */ |
| 2335 | if (!obj->no_charge) { |
| 2336 | if (!strncmp(p, "a ", 2)) |
| 2337 | p += 2; |
| 2338 | else if (!strncmp(p, "an ", 3)) |
| 2339 | p += 3; |
| 2340 | p = strprepend(p, obj->unpaid ? "an unpaid " : "your "); |
| 2341 | } |
| 2342 | |
| 2343 | if (!obj->cknown) { |
| 2344 | if (obj->unpaid) { |
| 2345 | if ((int) strlen(p) + sizeof and_contents - 1 |
| 2346 | < BUFSZ - PREFIX) |
| 2347 | Strcat(p, and_contents); |
| 2348 | } else { |
| 2349 | p = strprepend(p, "the contents of "); |
| 2350 | } |
| 2351 | } |
| 2352 | } |
| 2353 | obj->cknown = save_cknown; |
| 2354 | return p; |
| 2355 | } |
| 2356 | |
| 2357 | /* returns "[your ]xname(obj)" or "Foobar's xname(obj)" or "the xname(obj)" */ |
| 2358 | char * |
no test coverage detected