]> granicus.if.org Git - nethack/commitdiff
#levelchange fix
authornethack.rankin <nethack.rankin>
Mon, 24 Jun 2002 10:30:23 +0000 (10:30 +0000)
committernethack.rankin <nethack.rankin>
Mon, 24 Jun 2002 10:30:23 +0000 (10:30 +0000)
     Using #levelchange to reduce experience level would put nethack
into an infinite loop if the character had life-drain resistance.

doc/fixes34.1
src/cmd.c
src/exper.c

index 507d6fcadb4f24933b9d35fa74c7d3b6121be1c2..31a1ed1331b042a5c21037ca7688e8bf473d03fb 100644 (file)
@@ -120,6 +120,8 @@ prevent "remove_object: obj not on floor" panic for iron ball placement if
 specifying -D (or -X) to enter explore mode while restarting from a save
        file was lost in the restore process
 fix crash when using lookat on an known invisible monster with monster syms set
+prevent getting stuck in infinite loop when using wizard mode #levelchange
+       command to reduce level while having level-drain resistance
 
 
 Platform- and/or Interface-Specific Fixes
index b90f60f00633b7ad14eb9c9e97ec29197693afa2..d303a04da7a37024599e3e2d38be8bb7a72e60ff 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)cmd.c      3.4     2002/01/17      */
+/*     SCCS Id: @(#)cmd.c      3.4     2002/06/23      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -566,6 +566,7 @@ wiz_mon_polycontrol()
     return 0;
 }
 
+/* #levelchange command */
 STATIC_PTR int
 wiz_level_change()
 {
@@ -591,7 +592,7 @@ wiz_level_change()
        }
        if (newlevel < 1) newlevel = 1;
        while (u.ulevel > newlevel)
-           losexp((const char *)0);
+           losexp("#levelchange");
     } else {
        if (u.ulevel >= MAXULEV) {
            You("are already as experienced as you can get.");
index a310a6369b50baf39de8c5f4dc57c22c12df7ff8..37771a8bb77e3849346233cc43677cfec26450f1 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)exper.c    3.4     2002/01/15      */
+/*     SCCS Id: @(#)exper.c    3.4     2002/06/23      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -115,7 +115,14 @@ const char *drainer;       /* cause of death, if drain should be fatal */
 {
        register int num;
 
-       if (resists_drli(&youmonst)) return;
+#ifdef WIZARD
+       /* override life-drain resistance when handling an explicit
+          wizard mode request to reduce level; never fatal though */
+       if (drainer && !strcmp(drainer, "#levelchange"))
+           drainer = 0;
+       else
+#endif
+           if (resists_drli(&youmonst)) return;
 
        if (u.ulevel > 1) {
                pline("%s level %d.", Goodbye(), u.ulevel--);
@@ -140,10 +147,10 @@ const char *drainer;      /* cause of death, if drain should be fatal */
 
        if (u.ulevel < urole.xlev)
            num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.lornd + urace.enadv.lornd,
-                       urole.enadv.lofix + urace.enadv.lofix);
+                       urole.enadv.lofix + urace.enadv.lofix);
        else
            num = rn1((int)ACURR(A_WIS)/2 + urole.enadv.hirnd + urace.enadv.hirnd,
-                       urole.enadv.hifix + urace.enadv.hifix);
+                       urole.enadv.hifix + urace.enadv.hifix);
        num = enermod(num);             /* M. Stephenson */
        u.uenmax -= num;
        if (u.uenmax < 0) u.uenmax = 0;