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

Function loot_xname

src/invent.c:308–387  ·  view source on GitHub ↗

sortloot() formatting routine; for alphabetizing, not shown to user */

Source from the content-addressed store, hash-verified

306
307/* sortloot() formatting routine; for alphabetizing, not shown to user */
308staticfn char *
309loot_xname(struct obj *obj)
310{
311 struct obj saveo;
312 boolean save_debug;
313 char *res, *save_oname;
314
315 /*
316 * Deal with things that xname() includes as a prefix. We don't
317 * want such because they change alphabetical ordering. First,
318 * remember 'obj's current settings.
319 */
320 saveo.odiluted = obj->odiluted;
321 saveo.blessed = obj->blessed, saveo.cursed = obj->cursed;
322 saveo.spe = obj->spe;
323 saveo.owt = obj->owt;
324 save_oname = has_oname(obj) ? ONAME(obj) : 0;
325 save_debug = flags.debug;
326 /* suppress "diluted" for potions and "holy/unholy" for water;
327 sortloot() will deal with them using other criteria than name */
328 if (obj->oclass == POTION_CLASS) {
329 obj->odiluted = 0;
330 if (obj->otyp == POT_WATER)
331 obj->blessed = 0, obj->cursed = 0;
332 }
333 /* make "wet towel" and "moist towel" format as "towel" so that all
334 three group together */
335 if (obj->otyp == TOWEL)
336 obj->spe = 0;
337 /* group globs by monster type rather than by size: force all to
338 have the same size adjective hence same "small glob of " prefix */
339 if (obj->globby)
340 obj->owt = 20; /* weight of a fresh glob (one pudding's worth) */
341 /* suppress user-assigned name */
342 if (save_oname && !obj->oartifact)
343 ONAME(obj) = 0;
344 /* avoid wizard mode formatting variations */
345 if (wizard) { /* flags.debug */
346 /* paranoia: before toggling off wizard mode, guard against a
347 panic in xname() producing a normal mode panic save file */
348 program_state.something_worth_saving = 0;
349 flags.debug = FALSE;
350 }
351
352 res = cxname_singular(obj);
353
354 if (save_debug) {
355 flags.debug = TRUE;
356 program_state.something_worth_saving = 1;
357 }
358 /* restore the object */
359 if (obj->oclass == POTION_CLASS) {
360 obj->odiluted = saveo.odiluted;
361 if (obj->otyp == POT_WATER)
362 obj->blessed = saveo.blessed, obj->cursed = saveo.cursed;
363 }
364 if (obj->otyp == TOWEL) {
365 obj->spe = saveo.spe;

Callers 1

sortloot_cmpFunction · 0.85

Calls 1

cxname_singularFunction · 0.85

Tested by

no test coverage detected