From: Pasi Kallinen Date: Mon, 25 Apr 2022 15:11:32 +0000 (+0300) Subject: Unify probing an object chain X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9c2ca1577f6bd96881a90e31b050a3aad7d9f004;p=nethack Unify probing an object chain --- diff --git a/src/zap.c b/src/zap.c index 06509cd86..2d7c70299 100644 --- a/src/zap.c +++ b/src/zap.c @@ -12,6 +12,7 @@ */ #define MAGIC_COOKIE 1000 +static void probe_objchain(struct obj *); static boolean zombie_can_dig(xchar x, xchar y); static void polyuse(struct obj *, int, 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 probe_monster(struct monst *mtmp) { - struct obj *otmp; - mstatusline(mtmp); if (g.notonhead) return; /* don't show minvent for long worm tail */ if (mtmp->minvent) { - for (otmp = mtmp->minvent; 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; - } - } + probe_objchain(mtmp->minvent); (void) display_minventory(mtmp, MINV_ALL | MINV_NOLET | PICK_NONE, (char *) 0); } else { @@ -2701,22 +2706,12 @@ zapyourself(struct obj *obj, boolean ordinary) case SPE_DETECT_UNSEEN: case WAN_NOTHING: break; - case WAN_PROBING: { - struct obj *otmp; - - 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; - } - } + case WAN_PROBING: + probe_objchain(g.invent); update_inventory(); learn_it = TRUE; ustatusline(); break; - } case SPE_STONE_TO_FLESH: { struct obj *otmp, *onxt; boolean didmerge;