miscellaneous invent.c bits
Unrelated changes pulled out of pending patch.
This commit is contained in:
+20
-16
@@ -5,9 +5,10 @@
|
|||||||
|
|
||||||
#include "hack.h"
|
#include "hack.h"
|
||||||
|
|
||||||
#define NOINVSYM '#'
|
/* fake inventory letters, not 'a'..'z' or 'A'..'Z' */
|
||||||
|
#define NOINVSYM '#' /* overflow because all 52 letters are in use */
|
||||||
#define CONTAINED_SYM '>' /* designator for inside a container */
|
#define CONTAINED_SYM '>' /* designator for inside a container */
|
||||||
#define HANDS_SYM '-'
|
#define HANDS_SYM '-' /* hands|fingers|self depending on context */
|
||||||
|
|
||||||
static char *loot_xname(struct obj *);
|
static char *loot_xname(struct obj *);
|
||||||
static int invletter_value(char);
|
static int invletter_value(char);
|
||||||
@@ -60,7 +61,8 @@ static boolean in_perm_invent_toggled;
|
|||||||
*/
|
*/
|
||||||
static const char venom_inv[] = { VENOM_CLASS, 0 }; /* (constant) */
|
static const char venom_inv[] = { VENOM_CLASS, 0 }; /* (constant) */
|
||||||
|
|
||||||
/* sortloot() classification; called at most once [per sort] for each object */
|
/* sortloot() classification; called at most once [per sort] for each object;
|
||||||
|
also called by '\' command if discoveries use sortloot order */
|
||||||
void
|
void
|
||||||
loot_classify(Loot *sort_item, struct obj *obj)
|
loot_classify(Loot *sort_item, struct obj *obj)
|
||||||
{
|
{
|
||||||
@@ -336,7 +338,7 @@ sortloot_cmp(const genericptr vptr1, const genericptr vptr2)
|
|||||||
val1 = sli1->orderclass;
|
val1 = sli1->orderclass;
|
||||||
val2 = sli2->orderclass;
|
val2 = sli2->orderclass;
|
||||||
if (val1 != val2)
|
if (val1 != val2)
|
||||||
return (int) (val1 - val2);
|
return val1 - val2;
|
||||||
|
|
||||||
/* skip sub-classes when ordering by sortpack+invlet */
|
/* skip sub-classes when ordering by sortpack+invlet */
|
||||||
if ((gs.sortlootmode & SORTLOOT_INVLET) == 0) {
|
if ((gs.sortlootmode & SORTLOOT_INVLET) == 0) {
|
||||||
@@ -491,6 +493,7 @@ sortloot(
|
|||||||
boolean by_nexthere, /* T: traverse via obj->nexthere, F: via obj->nobj */
|
boolean by_nexthere, /* T: traverse via obj->nexthere, F: via obj->nobj */
|
||||||
boolean (*filterfunc)(struct obj *)) /* optional filter */
|
boolean (*filterfunc)(struct obj *)) /* optional filter */
|
||||||
{
|
{
|
||||||
|
static Loot zerosli;
|
||||||
Loot *sliarray;
|
Loot *sliarray;
|
||||||
struct obj *o;
|
struct obj *o;
|
||||||
unsigned n, i;
|
unsigned n, i;
|
||||||
@@ -513,16 +516,14 @@ sortloot(
|
|||||||
&& (!augment_filter || o->otyp != CORPSE
|
&& (!augment_filter || o->otyp != CORPSE
|
||||||
|| !touch_petrifies(&mons[o->corpsenm])))
|
|| !touch_petrifies(&mons[o->corpsenm])))
|
||||||
continue;
|
continue;
|
||||||
|
sliarray[i] = zerosli;
|
||||||
sliarray[i].obj = o, sliarray[i].indx = (int) i;
|
sliarray[i].obj = o, sliarray[i].indx = (int) i;
|
||||||
sliarray[i].str = (char *) 0;
|
|
||||||
sliarray[i].orderclass = sliarray[i].subclass = sliarray[i].disco = 0;
|
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
n = i;
|
n = i;
|
||||||
/* add a terminator so that we don't have to pass 'n' back to caller */
|
/* add a terminator so that we don't have to pass 'n' back to caller */
|
||||||
sliarray[n].obj = (struct obj *) 0, sliarray[n].indx = -1;
|
sliarray[n] = zerosli;
|
||||||
sliarray[n].str = (char *) 0;
|
sliarray[n].indx = -1;
|
||||||
sliarray[n].orderclass = sliarray[n].subclass = sliarray[n].disco = 0;
|
|
||||||
|
|
||||||
/* do the sort; if no sorting is requested, we'll just return
|
/* do the sort; if no sorting is requested, we'll just return
|
||||||
a sortloot_item array reflecting the current ordering */
|
a sortloot_item array reflecting the current ordering */
|
||||||
@@ -1396,7 +1397,8 @@ currency(long amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct obj *
|
struct obj *
|
||||||
u_carried_gloves(void) {
|
u_carried_gloves(void)
|
||||||
|
{
|
||||||
struct obj *otmp, *gloves = (struct obj *) 0;
|
struct obj *otmp, *gloves = (struct obj *) 0;
|
||||||
|
|
||||||
if (uarmg) {
|
if (uarmg) {
|
||||||
@@ -1897,7 +1899,7 @@ getobj(
|
|||||||
silly_thing(word, otmp);
|
silly_thing(word, otmp);
|
||||||
return (struct obj *) 0;
|
return (struct obj *) 0;
|
||||||
}
|
}
|
||||||
split_otmp:
|
split_otmp:
|
||||||
if (cntgiven) {
|
if (cntgiven) {
|
||||||
if (cnt == 0)
|
if (cnt == 0)
|
||||||
return (struct obj *) 0;
|
return (struct obj *) 0;
|
||||||
@@ -2491,8 +2493,9 @@ learn_unseen_invent(void)
|
|||||||
for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
|
for (otmp = gi.invent; otmp; otmp = otmp->nobj) {
|
||||||
if (otmp->dknown && (otmp->bknown || !Role_if(PM_CLERIC)))
|
if (otmp->dknown && (otmp->bknown || !Role_if(PM_CLERIC)))
|
||||||
continue; /* already seen */
|
continue; /* already seen */
|
||||||
/* set dknown, perhaps bknown (for priest[ess]) */
|
/* xname() will set dknown, perhaps bknown (for priest[ess]);
|
||||||
(void) xname(otmp);
|
result from xname() is immediately released for re-use */
|
||||||
|
maybereleaseobuf(xname(otmp));
|
||||||
/*
|
/*
|
||||||
* If object->eknown gets implemented (see learnwand(zap.c)),
|
* If object->eknown gets implemented (see learnwand(zap.c)),
|
||||||
* handle deferred discovery here.
|
* handle deferred discovery here.
|
||||||
@@ -3370,8 +3373,8 @@ display_pickinv(
|
|||||||
* an issue if empty checks are done before hand and the call
|
* an issue if empty checks are done before hand and the call
|
||||||
* to here is short circuited away.
|
* to here is short circuited away.
|
||||||
*
|
*
|
||||||
* 2: our count here is only to distinguish between 0 and 1 and
|
* 2: our count here is only to distinguish between 0 or 1 or
|
||||||
* more than 1; for the last one, we don't need a precise number.
|
* more than 1; for the last case, we don't need a precise number.
|
||||||
* For perm_invent update we force 'more than 1'.
|
* For perm_invent update we force 'more than 1'.
|
||||||
*/
|
*/
|
||||||
n = (doing_perm_invent && !lets && !want_reply) ? 2
|
n = (doing_perm_invent && !lets && !want_reply) ? 2
|
||||||
@@ -3625,7 +3628,8 @@ display_inventory(const char *lets, boolean want_reply)
|
|||||||
for (otmp = gi.invent; otmp; otmp = otmp->nobj)
|
for (otmp = gi.invent; otmp; otmp = otmp->nobj)
|
||||||
if (otmp->invlet == cmdq->key
|
if (otmp->invlet == cmdq->key
|
||||||
&& (!lets || !*lets
|
&& (!lets || !*lets
|
||||||
|| strchr(lets, def_oc_syms[(int) otmp->oclass].sym))) {
|
|| strchr(lets,
|
||||||
|
def_oc_syms[(int) otmp->oclass].sym))) {
|
||||||
free(cmdq);
|
free(cmdq);
|
||||||
return otmp->invlet;
|
return otmp->invlet;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user