]> granicus.if.org Git - nethack/commitdiff
corpse gender
authorPatR <rankin@nethack.org>
Thu, 21 Apr 2022 10:31:32 +0000 (03:31 -0700)
committerPatR <rankin@nethack.org>
Thu, 21 Apr 2022 10:31:32 +0000 (03:31 -0700)
Reported by entrez.  Don't make 50% of neuter monsters be flagged as
female.  It doesn't matter for live monsters but gets inherited by
their corpses, where female and non-female corpses stack separately.

doc/fixes3-7-0.txt
src/makemon.c

index c6a924ea442a698cbf8053b1afa68548d592fbb6..2d1993d04a5711ffe79436d69a97912aa35b8d20 100644 (file)
@@ -1158,6 +1158,8 @@ the change for repeat after prefix+command would result in a crash if repeat
        was attempted after an unassigned key
 items obtained via wishing while blind were erroneously being marked as 'seen
        up close' so behaving differently from items picked up off the floor
+corpses of neuter monsters had random chance to be flagged as female so would
+       only stack with others that made the same random choice
 
 curses: 'msg_window' option wasn't functional for curses unless the binary
        also included tty support
index 691476a6bcef0e02e765b5806bcedcfe8b2c24f7..f65019df7a28b2764b7c220f7cc939f626b378eb 100644 (file)
@@ -1127,7 +1127,8 @@ makemon(
     struct monst fakemon;
     coord cc;
     int mndx, mcham, ct, mitem;
-    boolean anymon = !ptr,
+    boolean femaleok, maleok,
+            anymon = !ptr,
             byyou = u_at(x, y),
             allow_minvent = ((mmflags & NO_MINVENT) == 0),
             countbirth = ((mmflags & MM_NOCOUNTBIRTH) == 0),
@@ -1230,10 +1231,13 @@ makemon(
     /* set up level and hit points */
     newmonhp(mtmp, mndx);
 
-    if (is_female(ptr) || ((mmflags & MM_FEMALE) && !is_male(ptr)))
-        mtmp->female = TRUE;
-    else if (is_male(ptr) || ((mmflags & MM_MALE) && !is_female(ptr)))
-        mtmp->female = FALSE;
+    femaleok = (!is_male(ptr) && !is_neuter(ptr));
+    maleok = (!is_female(ptr) && !is_neuter(ptr));
+    if (is_female(ptr) || ((mmflags & MM_FEMALE) != 0 && femaleok))
+        mtmp->female = 1;
+    else if (is_male(ptr) || ((mmflags & MM_MALE) != 0 && maleok))
+        mtmp->female = 0;
+
     /* leader and nemesis gender is usually hardcoded in mons[],
        but for ones which can be random, it has already been chosen
        (in role_init(), for possible use by the quest pager code) */
@@ -1241,8 +1245,12 @@ makemon(
         mtmp->female = g.quest_status.ldrgend;
     else if (ptr->msound == MS_NEMESIS && quest_info(MS_NEMESIS) == mndx)
         mtmp->female = g.quest_status.nemgend;
+
+    /* female used to be set randomly here even for neuters on the
+       grounds that it was ignored, but after corpses were changed to
+       retain gender it matters because it affects stacking of corpses */
     else
-        mtmp->female = rn2(2); /* ignored for neuters */
+        mtmp->female = femaleok ? rn2(2) : 0;
 
     if (In_sokoban(&u.uz) && !mindless(ptr)) /* know about traps here */
         mtmp->mtrapseen = (1L << (PIT - 1)) | (1L << (HOLE - 1));