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 *));
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));

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. */
/* 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 {

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. */
/* 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);

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. */
/* 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

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. */
/* 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))

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 */
/* 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);

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. */
/* 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();
}
}

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. */
/* 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);