]> granicus.if.org Git - nethack/commitdiff
Stoning management (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 19 Jun 2005 04:38:30 +0000 (04:38 +0000)
committernethack.rankin <nethack.rankin>
Sun, 19 Jun 2005 04:38:30 +0000 (04:38 +0000)
     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
src/eat.c
src/mhitu.c
src/mthrowu.c
src/polyself.c
src/potion.c
src/pray.c
src/uhitm.c

index ded45696ad1ebe5b9a866bbb9cc053ec2527f959..3ff15a588b95f50a87443a4c1a885d4e8baf83df 100644 (file)
@@ -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);
index 28cad7fa594859004c19e0dddeae646ee904e20b..968da1f3e5deb852872ddf23946a961cfef8cd03 100644 (file)
--- 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 */
index 14476dd9a956e7d58065893450a07a0a4cd07ccd..2409935d2dead0a1f8bccd07ffc0232029b00f1e 100644 (file)
@@ -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); */
index 5f2b9c63b3adaae02c78981fadcdad569a8a4c1b..c9b635ded4fcb6231470b7d919c409bba9d2643d 100644 (file)
@@ -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();
index 58c171c4e56bd5e0f8fe2fb9975fa88af8f150ff..6787f43d86c2cec49b2cd85fbf1b74711c31919c 100644 (file)
@@ -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);
index f36852c756b61a174b6b81b21b1ab693f85f74f9..7e4b3eae4d025e4c6429a63410477b2e6f55f5ae 100644 (file)
@@ -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;
index e150a47cb27df724e3eab50369a9829b446c05fd..26b83c3db97576aaba401c112dc522f8c3ea532d 100644 (file)
@@ -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.");
index 0d9a031b9861e401ea42d818c117e4a5b8ca8877..839495997597745806958df0a588a8766d02c9cf 100644 (file)
@@ -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++;