From: nethack.rankin Date: Sat, 19 Jan 2002 04:15:46 +0000 (+0000) Subject: wiz_level_change cleanup X-Git-Tag: MOVE2GIT~3435 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6d28ddf14b65002cd1ead378f95e2b68bfa21160;p=nethack wiz_level_change cleanup The new routine needed to do something with u.ulevelmax (which controls whether lost levels can be regained via magic). This sets it to the new level rather than having it go up or down the same amount as the user specified in the level change, which yields a plausible reason for using this command to set experience level explicitly to its current value. The new code was using a mixture of spaces and tabs for indentation; I've totally reformatted it. --- diff --git a/src/cmd.c b/src/cmd.c index 89b3c2990..36daa8d7f 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)cmd.c 3.3 2000/05/05 */ +/* SCCS Id: @(#)cmd.c 3.3 2002/01/17 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -559,40 +559,49 @@ wiz_level_tele() STATIC_PTR int wiz_mon_polycontrol() { - iflags.mon_polycontrol = !iflags.mon_polycontrol; - pline("Monster polymorph control is %s.", iflags.mon_polycontrol ? "on" : "off"); - return 0; + iflags.mon_polycontrol = !iflags.mon_polycontrol; + pline("Monster polymorph control is %s.", + iflags.mon_polycontrol ? "on" : "off"); + return 0; } STATIC_PTR int wiz_level_change() { - char buf[BUFSZ]; - int newlevel; - int ret; - - getlin("To what experience level do you want to be raised?", buf); - ret = sscanf(buf, "%d", &newlevel); - if (ret < 1 || ret == EOF) - pline(Never_mind); - else if (newlevel == u.ulevel) - You("are already that experienced."); - else if (newlevel < u.ulevel) { - if (u.ulevel == 1) { - You("are already as inexperienced as you can get."); - return 0; - } - if (newlevel < 1) newlevel = 1; - while (u.ulevel > newlevel) losexp((const char *)0); - } else { - if (u.ulevel >= MAXULEV) { - You("are already as experienced as you can get."); - return 0; - } - if (newlevel > MAXULEV) newlevel = MAXULEV; - while (u.ulevel < newlevel) pluslvl(FALSE); - } - return 0; + char buf[BUFSZ]; + int newlevel; + int ret; + + getlin("To what experience level do you want to be raised?", buf); + (void)mungspaces(buf); + if (buf[0] == '\033' || buf[0] == '\0') ret = 0; + else ret = sscanf(buf, "%d", &newlevel); + + if (ret != 1) { + pline(Never_mind); + return 0; + } + if (newlevel == u.ulevel) { + You("are already that experienced."); + } else if (newlevel < u.ulevel) { + if (u.ulevel == 1) { + You("are already as inexperienced as you can get."); + return 0; + } + if (newlevel < 1) newlevel = 1; + while (u.ulevel > newlevel) + losexp((const char *)0); + } else { + if (u.ulevel >= MAXULEV) { + You("are already as experienced as you can get."); + return 0; + } + if (newlevel > MAXULEV) newlevel = MAXULEV; + while (u.ulevel < newlevel) + pluslvl(FALSE); + } + u.ulevelmax = u.ulevel; + return 0; } STATIC_PTR int @@ -1412,10 +1421,10 @@ struct ext_func_tab extcmdlist[] = { #if defined(WIZARD) static const struct ext_func_tab debug_extcmdlist[] = { - {"levelchange", "change experience level", wiz_level_change, TRUE}, + {"levelchange", "change experience level", wiz_level_change, TRUE}, {"light sources", "show mobile light sources", wiz_light_sources, TRUE}, {"monpoly_control", "control monster polymorphs", wiz_mon_polycontrol, TRUE}, - {"poly", "polymorph self", wiz_polyself, TRUE}, + {"poly", "polymorph self", wiz_polyself, TRUE}, {"seenv", "show seen vectors", wiz_show_seenv, TRUE}, {"stats", "show memory statistics", wiz_show_stats, TRUE}, {"timeout", "look at timeout queue", wiz_timeout_queue, TRUE},