diff --git a/include/hack.h b/include/hack.h index 75dd2ba7e..d95dd4146 100644 --- a/include/hack.h +++ b/include/hack.h @@ -786,17 +786,18 @@ enum InputState { struct sortloot_item { struct obj *obj; char *str; /* result of loot_xname(obj) in some cases, otherwise null */ - int indx; /* signed int, because sortloot()'s qsort comparison routine - assumes (a->indx - b->indx) might yield a negative result */ - xint16 orderclass; /* order rather than object class; 0 => not yet init'd */ - xint16 subclass; /* subclass for some classes */ - xint16 disco; /* discovery status */ + /* these need to be signed; 'indx' should be big enough to hold a count + of the largest pile of items, the others would fit within char */ + int indx; /* index into original list (used as tie-breaker) */ + int orderclass; /* order rather than object class; 0 => not yet init'd */ + int subclass; /* subclass for some classes */ + int disco; /* discovery status */ }; typedef struct sortloot_item Loot; typedef struct strbuf { int len; - char * str; + char *str; char buf[256]; } strbuf_t; diff --git a/src/invent.c b/src/invent.c index 7b3c29074..0998438ac 100644 --- a/src/invent.c +++ b/src/invent.c @@ -94,7 +94,7 @@ loot_classify(Loot *sort_item, struct obj *obj) k = 1 + (int) (p - classorder); else k = 1 + (int) strlen(classorder) + (oclass != VENOM_CLASS); - sort_item->orderclass = (coordxy) k; + sort_item->orderclass = k; /* subclass designation; only a few classes have subclasses and the non-armor ones we use are fairly arbitrary */ switch (oclass) { @@ -210,13 +210,13 @@ loot_classify(Loot *sort_item, struct obj *obj) k = 1; /* any non-zero would do */ break; } - sort_item->subclass = (coordxy) k; + sort_item->subclass = k; /* discovery status */ k = !seen ? 1 /* unseen */ : (discovered || !OBJ_DESCR(objects[otyp])) ? 4 : (objects[otyp].oc_uname) ? 3 /* named (partially discovered) */ : 2; /* undiscovered */ - sort_item->disco = (coordxy) k; + sort_item->disco = k; } /* sortloot() formatting routine; for alphabetizing, not shown to user */