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

Function reassign

src/invent.c:4854–4884  ·  view source on GitHub ↗

give consecutive letters to every item in inventory (for !fixinv mode); gold is always forced to '$' slot at head of list */

Source from the content-addressed store, hash-verified

4852/* give consecutive letters to every item in inventory (for !fixinv mode);
4853 gold is always forced to '$' slot at head of list */
4854void
4855reassign(void)
4856{
4857 int i;
4858 struct obj *obj, *prevobj, *goldobj;
4859
4860 /* first, remove [first instance of] gold from invent, if present */
4861 prevobj = goldobj = 0;
4862 for (obj = gi.invent; obj; prevobj = obj, obj = obj->nobj)
4863 if (obj->oclass == COIN_CLASS) {
4864 goldobj = obj;
4865 if (prevobj)
4866 prevobj->nobj = goldobj->nobj;
4867 else
4868 gi.invent = goldobj->nobj;
4869 break;
4870 }
4871 /* second, re-letter the rest of the list */
4872 for (obj = gi.invent, i = 0; obj; obj = obj->nobj, i++)
4873 obj->invlet =
4874 (i < 26) ? ('a' + i) : (i < 52) ? ('A' + i - 26) : NOINVSYM;
4875 /* third, assign gold the "letter" '$' and re-insert it at head */
4876 if (goldobj) {
4877 goldobj->invlet = GOLD_SYM;
4878 goldobj->nobj = gi.invent;
4879 gi.invent = goldobj;
4880 }
4881 if (i >= 52)
4882 i = 52 - 1;
4883 gl.lastinvnr = i;
4884}
4885
4886/* invent gold sanity check; used by doorganize() to control how getobj()
4887 deals with gold and also by wizard mode sanity_check() */

Callers 7

paintEventMethod · 0.85
optfn_booleanFunction · 0.85
getobjFunction · 0.85
obj_to_letFunction · 0.85
invent.cFile · 0.85
dounpaidFunction · 0.85
doorganizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected