#levelchange fix

Using #levelchange to reduce experience level would put nethack
into an infinite loop if the character had life-drain resistance.
This commit is contained in:
nethack.rankin
2002-06-24 10:30:23 +00:00
parent 25f25a396d
commit 174dbea372
3 changed files with 16 additions and 6 deletions

View 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

View File

@@ -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.");

View 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;