]> granicus.if.org Git - nethack/commitdiff
filling antholes
authornethack.rankin <nethack.rankin>
Thu, 9 Mar 2006 05:39:38 +0000 (05:39 +0000)
committernethack.rankin <nethack.rankin>
Thu, 9 Mar 2006 05:39:38 +0000 (05:39 +0000)
     From a bug report:  when creating a
level, anthole rooms can be generated even when no ants are left, unlike
beehives which get suppressed once killer bees are gone.  Also, if some
ants are available but the type chosen for the current level isn't (in his
case, soldier ants had been genocided), the anthole was filled will random
monsters instead of picking another type of ant.  This fixes both issues.
Random monsters will only occur if the last type of ant gets used up while
filling an anthole that was started when some ants were available, same as
how monster generation for beehives and barracks works.

doc/fixes34.4
include/extern.h
src/mklev.c
src/mkroom.c

index 1020b45a3790a1bc074d3afae5cc31d6298acfd6..2bdfe73ca28985131312950595efa339d81a2390 100644 (file)
@@ -199,6 +199,7 @@ make baby long worms have lower level than full grown ones
 use "your kraken" instead of "a kraken" when searching reveals a tame
        hidden monster
 Magicbane should not produce "<something> are confused" message
+handle antholes more sensibly when ants aren't available
 
 
 Platform- and/or Interface-Specific Fixes
index 81546a0fb676c6e559f42fbe136d3c432d094814..8330cd989dfd56857509f11133a8e1b4a842be04 100644 (file)
@@ -1150,6 +1150,7 @@ E void NDECL(obj_sanity_check);
 
 E void FDECL(mkroom, (int));
 E void FDECL(fill_zoo, (struct mkroom *));
+E struct permonst *NDECL(antholemon);
 E boolean FDECL(nexttodoor, (int,int));
 E boolean FDECL(has_dnstairs, (struct mkroom *));
 E boolean FDECL(has_upstairs, (struct mkroom *));
index dcc87a3074c03f31b9e74cd43b36e02b84abf6db..e86596ff160978c5a45851b5b613d51c46444fa5 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mklev.c    3.5     2006/01/28      */
+/*     SCCS Id: @(#)mklev.c    3.5     2006/03/06      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -736,7 +736,7 @@ makelevel()
        else if (u_depth > 9 && !rn2(5) &&
           !(mvitals[PM_KILLER_BEE].mvflags & G_GONE)) mkroom(BEEHIVE);
        else if (u_depth > 11 && !rn2(6)) mkroom(MORGUE);
-       else if (u_depth > 12 && !rn2(8)) mkroom(ANTHOLE);
+       else if (u_depth > 12 && !rn2(8) && antholemon()) mkroom(ANTHOLE);
        else if (u_depth > 14 && !rn2(4) &&
           !(mvitals[PM_SOLDIER].mvflags & G_GONE)) mkroom(BARRACKS);
        else if (u_depth > 15 && !rn2(6)) mkroom(SWAMP);
index 1c1946bd614373574adf270ed10913756b9295ea..0d17f0a6decf221770da3c3b16f5abdd4c6aa207 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkroom.c   3.5     2006/01/28      */
+/*     SCCS Id: @(#)mkroom.c   3.5     2006/03/06      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -21,7 +21,6 @@ STATIC_DCL void NDECL(mkshop), FDECL(mkzoo,(int)), NDECL(mkswamp);
 STATIC_DCL void NDECL(mktemple);
 STATIC_DCL coord * FDECL(shrine_pos, (int));
 STATIC_DCL struct permonst * NDECL(morguemon);
-STATIC_DCL struct permonst * NDECL(antholemon);
 STATIC_DCL struct permonst * NDECL(squadmon);
 STATIC_DCL void FDECL(save_room, (int,struct mkroom *));
 STATIC_DCL void FDECL(rest_room, (int,struct mkroom *));
@@ -426,17 +425,23 @@ morguemon()
                        : (i < 40) ? &mons[PM_WRAITH] : mkclass(S_ZOMBIE,0));
 }
 
-STATIC_OVL struct permonst *
+struct permonst *
 antholemon()
 {
-       int mtyp;
+       int mtyp, indx, trycnt = 0;
 
+       /* casts are for dealing with time_t */
+       indx = (int)((long)u.ubirthday % 3L);
+       indx += level_difficulty();
        /* Same monsters within a level, different ones between levels */
-       switch ((level_difficulty() + ((long)u.ubirthday)) % 3) {
-       default:        mtyp = PM_GIANT_ANT; break;
-       case 0:         mtyp = PM_SOLDIER_ANT; break;
-       case 1:         mtyp = PM_FIRE_ANT; break;
-       }
+       do {
+           switch ((indx + trycnt) % 3) {
+           case 0:  mtyp = PM_SOLDIER_ANT; break;
+           case 1:  mtyp = PM_FIRE_ANT; break;
+           default: mtyp = PM_GIANT_ANT; break;
+           }
+           /* try again if chosen type has been genocided or used up */
+       } while (++trycnt < 3 && (mvitals[mtyp].mvflags & G_GONE));
        return ((mvitals[mtyp].mvflags & G_GONE) ?
                        (struct permonst *)0 : &mons[mtyp]);
 }