Unify probing an object chain

This commit is contained in:
Pasi Kallinen
2022-04-25 18:11:32 +03:00
parent 9334086506
commit 9c2ca1577f
+17 -22
View File
@@ -12,6 +12,7 @@
*/ */
#define MAGIC_COOKIE 1000 #define MAGIC_COOKIE 1000
static void probe_objchain(struct obj *);
static boolean zombie_can_dig(xchar x, xchar y); static boolean zombie_can_dig(xchar x, xchar y);
static void polyuse(struct obj *, int, int); static void polyuse(struct obj *, int, int);
static void create_polymon(struct obj *, int); static void create_polymon(struct obj *, int);
@@ -508,24 +509,28 @@ release_hold(void)
} }
} }
static void
probe_objchain(struct obj *otmp)
{
for (; otmp; otmp = otmp->nobj) {
otmp->dknown = 1; /* treat as "seen" */
if (Is_container(otmp) || otmp->otyp == STATUE) {
otmp->lknown = 1;
if (!SchroedingersBox(otmp))
otmp->cknown = 1;
}
}
}
void void
probe_monster(struct monst *mtmp) probe_monster(struct monst *mtmp)
{ {
struct obj *otmp;
mstatusline(mtmp); mstatusline(mtmp);
if (g.notonhead) if (g.notonhead)
return; /* don't show minvent for long worm tail */ return; /* don't show minvent for long worm tail */
if (mtmp->minvent) { if (mtmp->minvent) {
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) { probe_objchain(mtmp->minvent);
otmp->dknown = 1; /* treat as "seen" */
if (Is_container(otmp) || otmp->otyp == STATUE) {
otmp->lknown = 1;
if (!SchroedingersBox(otmp))
otmp->cknown = 1;
}
}
(void) display_minventory(mtmp, MINV_ALL | MINV_NOLET | PICK_NONE, (void) display_minventory(mtmp, MINV_ALL | MINV_NOLET | PICK_NONE,
(char *) 0); (char *) 0);
} else { } else {
@@ -2701,22 +2706,12 @@ zapyourself(struct obj *obj, boolean ordinary)
case SPE_DETECT_UNSEEN: case SPE_DETECT_UNSEEN:
case WAN_NOTHING: case WAN_NOTHING:
break; break;
case WAN_PROBING: { case WAN_PROBING:
struct obj *otmp; probe_objchain(g.invent);
for (otmp = g.invent; otmp; otmp = otmp->nobj) {
otmp->dknown = 1;
if (Is_container(otmp) || otmp->otyp == STATUE) {
otmp->lknown = 1;
if (!SchroedingersBox(otmp))
otmp->cknown = 1;
}
}
update_inventory(); update_inventory();
learn_it = TRUE; learn_it = TRUE;
ustatusline(); ustatusline();
break; break;
}
case SPE_STONE_TO_FLESH: { case SPE_STONE_TO_FLESH: {
struct obj *otmp, *onxt; struct obj *otmp, *onxt;
boolean didmerge; boolean didmerge;