]> granicus.if.org Git - nethack/commitdiff
^G (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 10 Apr 2007 04:24:17 +0000 (04:24 +0000)
committernethack.rankin <nethack.rankin>
Tue, 10 Apr 2007 04:24:17 +0000 (04:24 +0000)
     Change controlled monster creation to support specifying monster
by class name in addition to by class letter and the usual type name.

src/read.c

index ef85e13c6f4c094ed39ff041979fcbc3fc9d0ba9..8172cc152c4142f9af08bcde6d2ad58471f17033 100644 (file)
@@ -1971,16 +1971,17 @@ struct obj *from_obj;
 boolean
 create_particular()
 {
-       char buf[BUFSZ], *bufp, monclass = MAXMCLASSES;
-       int which, tries, i, firstchoice = NON_PM;
+       char buf[BUFSZ], *bufp, monclass;
+       int which, tryct, i, firstchoice = NON_PM;
        struct permonst *whichpm;
        struct monst *mtmp;
        boolean madeany = FALSE;
        boolean maketame, makepeaceful, makehostile;
        boolean randmonst = FALSE;
 
-       tries = 0;
+       tryct = 5;
        do {
+           monclass = MAXMCLASSES;
            which = urole.malenum;      /* an arbitrary index into mons[] */
            maketame = makepeaceful = makehostile = FALSE;
            getlin("Create what kind of monster? [type the name or symbol]",
@@ -1999,24 +2000,27 @@ create_particular()
                makehostile = TRUE;
            }
            /* decide whether a valid monster was chosen */
-           if (strlen(bufp) == 1) {
 #ifdef WIZARD
-               if (wizard && *bufp == '*') {
-                       randmonst = TRUE;
-                       break;
-               }
+           if (wizard && (!strcmp(bufp, "*") || !strcmp(bufp, "random"))) {
+               randmonst = TRUE;
+               break;
+           }
 #endif
-               monclass = def_char_to_monclass(*bufp);
-               if (monclass != MAXMCLASSES) break;     /* got one */
-           } else {
-               which = name_to_mon(bufp);
-               if (which >= LOW_PM) break;             /* got one */
+           which = name_to_mon(bufp);
+           if (which >= LOW_PM) break;         /* got one */
+           monclass = name_to_monclass(bufp, &which);
+           if (which >= LOW_PM) {
+               monclass = MAXMCLASSES; /* matters below */
+               break;
+           } else if (monclass > 0) {
+               which = urole.malenum;  /* reset from NON_PM */
+               break;
            }
            /* no good; try again... */
            pline("I've never heard of such monsters.");
-       } while (++tries < 5);
+       } while (--tryct > 0);
 
-       if (tries == 5) {
+       if (!tryct) {
            pline(thats_enough_tries);
        } else {
            if (!randmonst) {