more perm_invent handling

Keep permanent inventory window up to date when using charged items.
Also a status line bit for the #tip command.
This commit is contained in:
nethack.rankin
2003-05-24 04:07:14 +00:00
parent aace75a34d
commit 9a39064b8f
8 changed files with 45 additions and 40 deletions

View File

@@ -765,6 +765,7 @@ E struct obj *FDECL(hold_another_object,
(struct obj *,const char *,const char *,const char *)); (struct obj *,const char *,const char *,const char *));
E void FDECL(useupall, (struct obj *)); E void FDECL(useupall, (struct obj *));
E void FDECL(useup, (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_core, (struct obj *));
E void FDECL(freeinv, (struct obj *)); E void FDECL(freeinv, (struct obj *));
E void FDECL(delallobj, (int,int)); E void FDECL(delallobj, (int,int));

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -65,8 +65,8 @@ use_camera(obj)
pline(nothing_happens); pline(nothing_happens);
return (1); return (1);
} }
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if (obj->cursed && !rn2(2)) { if (obj->cursed && !rn2(2)) {
(void) zapyourself(obj, TRUE); (void) zapyourself(obj, TRUE);
} else if (u.uswallow) { } else if (u.uswallow) {
@@ -782,8 +782,7 @@ struct obj **optr;
} else { } else {
/* charged Bell of Opening */ /* charged Bell of Opening */
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if (u.uswallow) { if (u.uswallow) {
if (!obj->cursed) if (!obj->cursed)
@@ -1410,8 +1409,8 @@ register struct obj *obj;
pline("That's too insubstantial to tin."); pline("That's too insubstantial to tin.");
return; return;
} }
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if ((can = mksobj(TIN, FALSE, FALSE)) != 0) { if ((can = mksobj(TIN, FALSE, FALSE)) != 0) {
static const char you_buy_it[] = "You tin it, you bought it!"; 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->spe > 0) {
if ((obj->cursed || Fumbling) && !rn2(2)) { if ((obj->cursed || Fumbling) && !rn2(2)) {
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
pline("%s from your %s.", Tobjnam(obj, "slip"), pline("%s from your %s.", Tobjnam(obj, "slip"),
makeplural(body_part(FINGER))); makeplural(body_part(FINGER)));
dropx(obj); dropx(obj);
@@ -1789,8 +1788,8 @@ struct obj *obj;
return; return;
} }
#endif #endif
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if (otmp != &zeroobj) { if (otmp != &zeroobj) {
You("cover %s with a thick layer of grease.", You("cover %s with a thick layer of grease.",
yname(otmp)); yname(otmp));
@@ -2915,8 +2914,7 @@ doapply()
struct obj *otmp; struct obj *otmp;
const char *what; const char *what;
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if (!rn2(13)) { if (!rn2(13)) {
otmp = mkobj(POTION_CLASS, FALSE); otmp = mkobj(POTION_CLASS, FALSE);
if (objects[otmp->otyp].oc_magic) do { if (objects[otmp->otyp].oc_magic) do {

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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); losehp(rnd(30), "exploding crystal ball", KILLED_BY_AN);
break; break;
} }
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
return; return;
} }
@@ -825,8 +824,7 @@ struct obj *obj;
default: pline("Oh wow... like a kaleidoscope!"); default: pline("Oh wow... like a kaleidoscope!");
break; break;
} }
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
} }
return; return;
} }
@@ -848,8 +846,7 @@ struct obj *obj;
int ret = 0; int ret = 0;
makeknown(CRYSTAL_BALL); makeknown(CRYSTAL_BALL);
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
if ((class = def_char_to_objclass(ch)) != MAXOCLASSES) if ((class = def_char_to_objclass(ch)) != MAXOCLASSES)
ret = object_detect((struct obj *)0, class); ret = object_detect((struct obj *)0, class);

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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 */ #endif /* OVLB */
#ifdef OVL3 #ifdef OVL3

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1732,8 +1732,8 @@ struct obj *bag;
boolean gotone = FALSE; boolean gotone = FALSE;
int cnt = 1; int cnt = 1;
check_unpaid(bag); consume_obj_charge(bag, TRUE);
bag->spe--;
if (!rn2(23)) cnt += rn1(7, 1); if (!rn2(23)) cnt += rn1(7, 1);
while (cnt-- > 0) { while (cnt-- > 0) {
if (makemon((struct permonst *)0, u.ux, u.uy, NO_MM_FLAGS)) if (makemon((struct permonst *)0, u.ux, u.uy, NO_MM_FLAGS))

View 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 */ /* Copyright (c) 1989 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -384,8 +384,8 @@ struct obj *instr;
switch (instr->otyp) { switch (instr->otyp) {
case MAGIC_FLUTE: /* Make monster fall asleep */ case MAGIC_FLUTE: /* Make monster fall asleep */
if (do_spec && instr->spe > 0) { if (do_spec && instr->spe > 0) {
check_unpaid(instr); consume_obj_charge(instr, TRUE);
instr->spe--;
You("produce soft music."); You("produce soft music.");
put_monsters_to_sleep(u.ulevel * 5); put_monsters_to_sleep(u.ulevel * 5);
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
@@ -400,8 +400,8 @@ struct obj *instr;
case FROST_HORN: /* Idem wand of cold */ case FROST_HORN: /* Idem wand of cold */
case FIRE_HORN: /* Idem wand of fire */ case FIRE_HORN: /* Idem wand of fire */
if (do_spec && instr->spe > 0) { if (do_spec && instr->spe > 0) {
check_unpaid(instr); consume_obj_charge(instr, TRUE);
instr->spe--;
if (!getdir((char *)0)) { if (!getdir((char *)0)) {
pline("%s.", Tobjnam(instr, "vibrate")); pline("%s.", Tobjnam(instr, "vibrate"));
break; break;
@@ -430,8 +430,8 @@ struct obj *instr;
break; break;
case MAGIC_HARP: /* Charm monsters */ case MAGIC_HARP: /* Charm monsters */
if (do_spec && instr->spe > 0) { if (do_spec && instr->spe > 0) {
check_unpaid(instr); consume_obj_charge(instr, TRUE);
instr->spe--;
pline("%s very attractive music.", Tobjnam(instr, "produce")); pline("%s very attractive music.", Tobjnam(instr, "produce"));
charm_monsters((u.ulevel - 1) / 3 + 1); charm_monsters((u.ulevel - 1) / 3 + 1);
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
@@ -446,8 +446,8 @@ struct obj *instr;
break; break;
case DRUM_OF_EARTHQUAKE: /* create several pits */ case DRUM_OF_EARTHQUAKE: /* create several pits */
if (do_spec && instr->spe > 0) { if (do_spec && instr->spe > 0) {
check_unpaid(instr); consume_obj_charge(instr, TRUE);
instr->spe--;
You("produce a heavy, thunderous rolling!"); You("produce a heavy, thunderous rolling!");
pline_The("entire dungeon is shaking around you!"); pline_The("entire dungeon is shaking around you!");
do_earthquake((u.ulevel - 1) / 3 + 1); do_earthquake((u.ulevel - 1) / 3 + 1);

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -2417,8 +2417,7 @@ dotip()
surface(u.ux, u.uy), buf); surface(u.ux, u.uy), buf);
/* shop usage message comes after the spill message */ /* shop usage message comes after the spill message */
if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) { if (cobj->otyp == CAN_OF_GREASE && cobj->spe > 0) {
check_unpaid(cobj); consume_obj_charge(cobj, TRUE);
cobj->spe--; /* doesn't affect cobj->owt */
} }
/* something [useless] happened */ /* something [useless] happened */
return 1; return 1;
@@ -2477,6 +2476,7 @@ struct obj *box; /* or bag */
} }
if (loss) if (loss)
You("owe %ld %s for lost merchandise.", loss, currency(loss)); You("owe %ld %s for lost merchandise.", loss, currency(loss));
if (held) (void)encumber_msg();
} }
} }

View 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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 */ /* successfully used oil or grease to fix squeaky board */
if (obj->otyp == CAN_OF_GREASE) { if (obj->otyp == CAN_OF_GREASE) {
check_unpaid(obj); consume_obj_charge(obj, TRUE);
obj->spe--;
update_inventory();
} else { } else {
useup(obj); /* oil */ useup(obj); /* oil */
makeknown(POT_OIL); makeknown(POT_OIL);