]> granicus.if.org Git - nethack/commitdiff
more perm_invent handling
authornethack.rankin <nethack.rankin>
Sat, 24 May 2003 04:07:14 +0000 (04:07 +0000)
committernethack.rankin <nethack.rankin>
Sat, 24 May 2003 04:07:14 +0000 (04:07 +0000)
     Keep permanent inventory window up to date when using charged items.
Also a status line bit for the #tip command.

include/extern.h
src/apply.c
src/detect.c
src/invent.c
src/makemon.c
src/music.c
src/pickup.c
src/trap.c

index 24d9538f2a7c606f40e98e975803de9e5928aa2a..548290712f84aa2e089607959c2ede64433647f5 100644 (file)
@@ -765,6 +765,7 @@ E struct obj *FDECL(hold_another_object,
                        (struct obj *,const char *,const char *,const char *));
 E void FDECL(useupall, (struct obj *));
 E void FDECL(useup, (struct obj *));
+E void FDECL(consume_obj_charge, (struct obj *,BOOLEAN_P));
 E void FDECL(freeinv_core, (struct obj *));
 E void FDECL(freeinv, (struct obj *));
 E void FDECL(delallobj, (int,int));
index 6a7c4f3ff4b00a67854456cbd7984fc1d4c05908..a1f5debabf84dd62055eff7793d91bc34182cd10 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)apply.c    3.4     2003/03/29      */
+/*     SCCS Id: @(#)apply.c    3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -65,8 +65,8 @@ use_camera(obj)
                pline(nothing_happens);
                return (1);
        }
-       check_unpaid(obj);
-       obj->spe--;
+       consume_obj_charge(obj, TRUE);
+
        if (obj->cursed && !rn2(2)) {
                (void) zapyourself(obj, TRUE);
        } else if (u.uswallow) {
@@ -782,8 +782,7 @@ struct obj **optr;
 
        } else {
            /* charged Bell of Opening */
-           check_unpaid(obj);
-           obj->spe--;
+           consume_obj_charge(obj, TRUE);
 
            if (u.uswallow) {
                if (!obj->cursed)
@@ -1410,8 +1409,8 @@ register struct obj *obj;
                pline("That's too insubstantial to tin.");
                return;
        }
-       check_unpaid(obj);
-       obj->spe--;
+       consume_obj_charge(obj, TRUE);
+
        if ((can = mksobj(TIN, FALSE, FALSE)) != 0) {
            static const char you_buy_it[] = "You tin it, you bought it!";
 
@@ -1766,8 +1765,8 @@ struct obj *obj;
 
        if (obj->spe > 0) {
                if ((obj->cursed || Fumbling) && !rn2(2)) {
-                       check_unpaid(obj);
-                       obj->spe--;
+                       consume_obj_charge(obj, TRUE);
+
                        pline("%s from your %s.", Tobjnam(obj, "slip"),
                              makeplural(body_part(FINGER)));
                        dropx(obj);
@@ -1789,8 +1788,8 @@ struct obj *obj;
                        return;
                }
 #endif
-               check_unpaid(obj);
-               obj->spe--;
+               consume_obj_charge(obj, TRUE);
+
                if (otmp != &zeroobj) {
                        You("cover %s with a thick layer of grease.",
                            yname(otmp));
@@ -2915,8 +2914,7 @@ doapply()
                    struct obj *otmp;
                    const char *what;
 
-                   check_unpaid(obj);
-                   obj->spe--;
+                   consume_obj_charge(obj, TRUE);
                    if (!rn2(13)) {
                        otmp = mkobj(POTION_CLASS, FALSE);
                        if (objects[otmp->otyp].oc_magic) do {
index ae30ecb8f472242f117e074cc38a067e8fc6f3f4..328b979b3e67aa2a1dcfd8105c095a41f078c829 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)detect.c   3.4     1999/12/06      */
+/*     SCCS Id: @(#)detect.c   3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -800,8 +800,7 @@ struct obj *obj;
            losehp(rnd(30), "exploding crystal ball", KILLED_BY_AN);
            break;
        }
-       check_unpaid(obj);
-       obj->spe--;
+       consume_obj_charge(obj, TRUE);
        return;
     }
 
@@ -825,8 +824,7 @@ struct obj *obj;
            default: pline("Oh wow... like a kaleidoscope!");
                break;
            }
-           check_unpaid(obj);
-           obj->spe--;
+           consume_obj_charge(obj, TRUE);
        }
        return;
     }
@@ -848,8 +846,7 @@ struct obj *obj;
        int ret = 0;
 
        makeknown(CRYSTAL_BALL);
-       check_unpaid(obj);
-       obj->spe--;
+       consume_obj_charge(obj, TRUE);
 
        if ((class = def_char_to_objclass(ch)) != MAXOCLASSES)
                ret = object_detect((struct obj *)0, class);
index cce171291297f67d18dfeeb5648633e51ad0b8b5..6ba6aa9679ba07dea5bbe2659c0578eea4d247cf 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)invent.c   3.4     2003/04/02      */
+/*     SCCS Id: @(#)invent.c   3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -464,6 +464,17 @@ register struct obj *obj;
        }
 }
 
+/* use one charge from an item and possibly incur shop debt for it */
+void
+consume_obj_charge(obj, maybe_unpaid)
+struct obj *obj;
+boolean maybe_unpaid;  /* false if caller handles shop billing */
+{
+       if (maybe_unpaid) check_unpaid(obj);
+       obj->spe -= 1;
+       if (obj->known) update_inventory();
+}
+
 #endif /* OVLB */
 #ifdef OVL3
 
index 48e70bc52dafa4fb7242f01a3f5f2982498d50b5..eccb363f43f6897d6594fc757af1738cf4cd6015 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)makemon.c  3.4     2003/03/29      */
+/*     SCCS Id: @(#)makemon.c  3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1732,8 +1732,8 @@ struct obj *bag;
        boolean gotone = FALSE;
        int cnt = 1;
 
-       check_unpaid(bag);
-       bag->spe--;
+       consume_obj_charge(bag, TRUE);
+
        if (!rn2(23)) cnt += rn1(7, 1);
        while (cnt-- > 0) {
            if (makemon((struct permonst *)0, u.ux, u.uy, NO_MM_FLAGS))
index 72ee70de291324eef2817d47629d3a2fb971df66..e7391d885b45646762c343f6a18236008dccda26 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)music.c    3.4     2003/03/10      */
+/*     SCCS Id: @(#)music.c    3.4     2003/05/25      */
 /*     Copyright (c) 1989 by Jean-Christophe Collet */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -384,8 +384,8 @@ struct obj *instr;
        switch (instr->otyp) {
        case MAGIC_FLUTE:               /* Make monster fall asleep */
            if (do_spec && instr->spe > 0) {
-               check_unpaid(instr);
-               instr->spe--;
+               consume_obj_charge(instr, TRUE);
+
                You("produce soft music.");
                put_monsters_to_sleep(u.ulevel * 5);
                exercise(A_DEX, TRUE);
@@ -400,8 +400,8 @@ struct obj *instr;
        case FROST_HORN:                /* Idem wand of cold */
        case FIRE_HORN:                 /* Idem wand of fire */
            if (do_spec && instr->spe > 0) {
-               check_unpaid(instr);
-               instr->spe--;
+               consume_obj_charge(instr, TRUE);
+
                if (!getdir((char *)0)) {
                    pline("%s.", Tobjnam(instr, "vibrate"));
                    break;
@@ -430,8 +430,8 @@ struct obj *instr;
            break;
        case MAGIC_HARP:                /* Charm monsters */
            if (do_spec && instr->spe > 0) {
-               check_unpaid(instr);
-               instr->spe--;
+               consume_obj_charge(instr, TRUE);
+
                pline("%s very attractive music.", Tobjnam(instr, "produce"));
                charm_monsters((u.ulevel - 1) / 3 + 1);
                exercise(A_DEX, TRUE);
@@ -446,8 +446,8 @@ struct obj *instr;
            break;
        case DRUM_OF_EARTHQUAKE:        /* create several pits */
            if (do_spec && instr->spe > 0) {
-               check_unpaid(instr);
-               instr->spe--;
+               consume_obj_charge(instr, TRUE);
+
                You("produce a heavy, thunderous rolling!");
                pline_The("entire dungeon is shaking around you!");
                do_earthquake((u.ulevel - 1) / 3 + 1);
index 55414691e31c63313eaaa527689c06885e117368..1daf7b129b2f3c554a1e7ea129b65a10f46658a6 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pickup.c   3.4     2003/05/08      */
+/*     SCCS Id: @(#)pickup.c   3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -2417,8 +2417,7 @@ dotip()
              surface(u.ux, u.uy), buf);
        /* shop usage message comes after the spill message */
        if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) {
-           check_unpaid(cobj);
-           cobj->spe--;                /* doesn't affect cobj->owt */
+           consume_obj_charge(cobj, TRUE);
        }
        /* something [useless] happened */
        return 1;
@@ -2477,6 +2476,7 @@ struct obj *box;  /* or bag */
        }
        if (loss)
            You("owe %ld %s for lost merchandise.", loss, currency(loss));
+       if (held) (void)encumber_msg();
     }
 }
 
index b04d9da87ef0c914cbac9d6ff93d2a2511134350..854ba9be7b0577b59bdd28ae735d78f2e22aa05c 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)trap.c     3.4     2003/05/09      */
+/*     SCCS Id: @(#)trap.c     3.4     2003/05/25      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3150,9 +3150,7 @@ struct trap *ttmp;
 
        /* successfully used oil or grease to fix squeaky board */
        if (obj->otyp == CAN_OF_GREASE) {
-           check_unpaid(obj);
-           obj->spe--;
-           update_inventory();
+           consume_obj_charge(obj, TRUE);
        } else {
            useup(obj); /* oil */
            makeknown(POT_OIL);