]> granicus.if.org Git - nethack/commitdiff
fix #H4476 - monster class via member of class
authorPatR <rankin@nethack.org>
Fri, 12 Aug 2016 01:53:52 +0000 (18:53 -0700)
committerPatR <rankin@nethack.org>
Fri, 12 Aug 2016 01:53:52 +0000 (18:53 -0700)
Blessed genocide of "titans" wiped out all quadrupeds because
"titan" is a prefix of "titanothere".  After class letters and
class descriptions have been rejected, Have name_to_monclass()
resort to name_to_mon() instead of doing its own less detailed
name matching.

doc/fixes36.1
src/mondata.c

index d827071aeb7338dbde375b3c81cae9ba2f35eb06..b574d4816f8ac0a11c0e0b40950cc97709e1bc49 100644 (file)
@@ -331,6 +331,9 @@ when escaping the dungeon, change "you were here" annotation in dungeon
 option parsing will crash if 'playmode' option is present without a value
 any item drained of enchantment was blamed on the player as far as shop
        billing was concerned, even if caused by disenchanter attack
+if user supplied a specific monster name when asked to choose a monster class,
+       first prefix match was picked rather than best match ("titan" yielded
+       S_quadruped due to being preceded by "titanothere" in mons[])
 
 
 Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
index 0e924f3fc371bdf9c5d29f3b959c034cf35468ff..a9d054f4cd2fa57f14c5d1f8d55bf727876f1a2d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mondata.c       $NHDT-Date: 1446604115 2015/11/04 02:28:35 $  $NHDT-Branch: master $:$NHDT-Revision: 1.58 $ */
+/* NetHack 3.6 mondata.c       $NHDT-Date: 1470966820 2016/08/12 01:53:40 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.61 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -855,16 +855,12 @@ int *mndx_p;
             if ((p = strstri(x, in_str)) != 0 && (p == x || *(p - 1) == ' '))
                 return i;
         }
-        /* check individual species names; not as thorough as mon_to_name()
-           but our caller can call that directly if desired */
-        for (i = LOW_PM; i < NUMMONS; i++) {
-            x = mons[i].mname;
-            if ((p = strstri(x, in_str)) != 0
-                && (p == x || *(p - 1) == ' ')) {
-                if (mndx_p)
-                    *mndx_p = i;
-                return mons[i].mlet;
-            }
+        /* check individual species names */
+        i = name_to_mon(in_str);
+        if (i != NON_PM) {
+            if (mndx_p)
+                *mndx_p = i;
+            return mons[i].mlet;
         }
     }
     return 0;