From bd1af399978a9756c8745ae5f748c817ebdb9ae3 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 19 Jun 2005 04:38:30 +0000 Subject: [PATCH] Stoning management (trunk only) Make petrification initiation or termination go through a new routine, make_stoned(), instead of manipulating its countdown timer and delayed killer directly. No change in behavior. There's no reason in terms of bug risk or game play or saved data why this shouldn't be done in the branch too, but so much of the surrounding context has already diverged between trunk and branch that it's trunk only. --- include/extern.h | 3 ++- src/eat.c | 21 +++++++++++---------- src/mhitu.c | 5 ++--- src/mthrowu.c | 5 ++--- src/polyself.c | 14 +++++--------- src/potion.c | 21 ++++++++++++++++++++- src/pray.c | 7 ++----- src/uhitm.c | 6 +++--- 8 files changed, 47 insertions(+), 35 deletions(-) diff --git a/include/extern.h b/include/extern.h index ded45696a..3ff15a588 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1615,7 +1615,8 @@ E void FDECL(make_confused, (long,BOOLEAN_P)); E void FDECL(make_stunned, (long,BOOLEAN_P)); E void FDECL(make_blinded, (long,BOOLEAN_P)); E void FDECL(make_sick, (long, const char *, BOOLEAN_P,int)); -E void FDECL(make_slimed, (long,const char*)); +E void FDECL(make_slimed, (long,const char *)); +E void FDECL(make_stoned, (long,const char *,int,const char *)); E void FDECL(make_vomiting, (long,BOOLEAN_P)); E boolean FDECL(make_hallucinated, (long,BOOLEAN_P,long)); E int NDECL(dodrink); diff --git a/src/eat.c b/src/eat.c index 28cad7fa5..968da1f3e 100644 --- a/src/eat.c +++ b/src/eat.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)eat.c 3.5 2005/06/02 */ +/* SCCS Id: @(#)eat.c 3.5 2005/06/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -514,13 +514,14 @@ register int pm; void fix_petrification() { - Stoned = 0; - dealloc_killer(find_delayed_killer(STONED)); - if (Hallucination) - pline("What a pity - you just ruined a future piece of %sart!", - ACURR(A_CHA) > 15 ? "fine " : ""); - else - You_feel("limber!"); + char buf[BUFSZ]; + + if (Hallucination) + Sprintf(buf, "What a pity--you just ruined a future piece of %sart!", + ACURR(A_CHA) > 15 ? "fine " : ""); + else + Strcpy(buf, "You feel limber!"); + make_stoned(0L, buf, 0, (char *)0); } /* @@ -1836,10 +1837,10 @@ register struct obj *otmp; !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) { if (!Stoned) { - Stoned = 5; Sprintf(killer.name, "%s egg", mons[otmp->corpsenm].mname); - delayed_killer(STONED, KILLED_BY_AN, killer.name); + make_stoned(5L, (char *)0, + KILLED_BY_AN, killer.name); } } /* note: no "tastes like chicken" message for eggs */ diff --git a/src/mhitu.c b/src/mhitu.c index 14476dd9a..2409935d2 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mhitu.c 3.5 2005/04/15 */ +/* SCCS Id: @(#)mhitu.c 3.5 2005/06/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1182,13 +1182,12 @@ dopois: int kformat = KILLED_BY_AN; const char *kname = mtmp->data->mname; - Stoned = 5; if (mtmp->data->geno & G_UNIQ) { if (!type_is_pname(mtmp->data)) kname = the(kname); kformat = KILLED_BY; } - delayed_killer(STONED, kformat, kname); + make_stoned(5L, (char *)0, kformat, kname); return(1); /* You("turn to stone..."); */ /* done_in_by(mtmp); */ diff --git a/src/mthrowu.c b/src/mthrowu.c index 5f2b9c63b..c9b635ded 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)mthrowu.c 3.5 2004/08/16 */ +/* SCCS Id: @(#)mthrowu.c 3.5 2005/06/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -404,8 +404,7 @@ struct obj *obj; /* missile (or stack providing it) */ if (!Stoned && !Stone_resistance && !(poly_when_stoned(youmonst.data) && polymon(PM_STONE_GOLEM))) { - Stoned = 5; - delayed_killer(STONED, KILLED_BY, nul); + make_stoned(5L, (char *)0, KILLED_BY, nul); } } stop_occupation(); diff --git a/src/polyself.c b/src/polyself.c index 58c171c4e..6787f43d8 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)polyself.c 3.5 2005/04/13 */ +/* SCCS Id: @(#)polyself.c 3.5 2005/06/21 */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ @@ -193,8 +193,7 @@ newman() redist_attr(); u.uhunger = rn1(500,500); if (Sick) make_sick(0L, (char *) 0, FALSE, SICK_ALL); - Stoned = 0; - dealloc_killer(find_delayed_killer(STONED)); + if (Stoned) make_stoned(0L, (char *)0, 0, (char *)0); if (u.uhp <= 0 || u.uhpmax <= 0) { if (Polymorph_control) { if (u.uhp <= 0) u.uhp = 1; @@ -407,10 +406,8 @@ int mntmp; } if (Stoned && poly_when_stoned(&mons[mntmp])) { /* poly_when_stoned already checked stone golem genocide */ - You("turn to stone!"); mntmp = PM_STONE_GOLEM; - Stoned = 0; - dealloc_killer(find_delayed_killer(STONED)); + make_stoned(0L, "You turn to stone!", 0, (char *)0); } u.mtimedone = rn1(500, 500); @@ -423,9 +420,8 @@ int mntmp; if(strongmonst(&mons[mntmp])) ABASE(A_STR) = AMAX(A_STR) = STR18(100); if (Stone_resistance && Stoned) { /* parnes@eniac.seas.upenn.edu */ - Stoned = 0; - dealloc_killer(find_delayed_killer(STONED)); - You("no longer seem to be petrifying."); + make_stoned(0L, "You no longer seem to be petrifying.", + 0, (char *)0); } if (Sick_resistance && Sick) { make_sick(0L, (char *) 0, FALSE, SICK_ALL); diff --git a/src/potion.c b/src/potion.c index f36852c75..7e4b3eae4 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)potion.c 3.5 2005/06/02 */ +/* SCCS Id: @(#)potion.c 3.5 2005/06/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -153,6 +153,25 @@ const char *msg; if (!Slimed) dealloc_killer(find_delayed_killer(SLIMED)); } +/* start or stop petrification */ +void +make_stoned(xtime, msg, killedby, killername) +long xtime; +const char *msg; +int killedby; +const char *killername; +{ + long old = Stoned; + + if ((!xtime && old) || (xtime && !old)) { + if (msg) pline("%s", msg); + /* context.botl = 1; --- Stoned is not a status line item */ + } + set_itimeout(&Stoned, xtime); + if (!Stoned) dealloc_killer(find_delayed_killer(STONED)); + else if (!old) delayed_killer(STONED, killedby, killername); +} + void make_vomiting(xtime, talk) long xtime; diff --git a/src/pray.c b/src/pray.c index e150a47cb..26b83c3db 100644 --- a/src/pray.c +++ b/src/pray.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)pray.c 3.5 2004/06/12 */ +/* SCCS Id: @(#)pray.c 3.5 2005/06/21 */ /* Copyright (c) Benson I. Margulies, Mike Stephenson, Steve Linhart, 1989. */ /* NetHack may be freely redistributed. See license for details. */ @@ -276,10 +276,7 @@ register int trouble; switch (trouble) { case TROUBLE_STONED: - You_feel("more limber."); - Stoned = 0; - context.botl = 1; - dealloc_killer(find_delayed_killer(STONED)); + make_stoned(0L, "You feel more limber.", 0, (char *)0); break; case TROUBLE_SLIMED: make_slimed(0L, "The slime disappears."); diff --git a/src/uhitm.c b/src/uhitm.c index 0d9a031b9..839495997 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)uhitm.c 3.5 2004/12/21 */ +/* SCCS Id: @(#)uhitm.c 3.5 2005/06/21 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1571,8 +1571,8 @@ register struct attack *mattk; You("eat %s brain!", s_suffix(mon_nam(mdef))); u.uconduct.food++; if (touch_petrifies(mdef->data) && !Stone_resistance && !Stoned) { - Stoned = 5; - delayed_killer(STONED, KILLED_BY_AN, mdef->data->mname); + make_stoned(5L, (char *)0, + KILLED_BY_AN, mdef->data->mname); } if (!vegan(mdef->data)) u.uconduct.unvegan++;