]> granicus.if.org Git - nethack/commitdiff
Formally block artifacts as random box contents
authorMichael Meyer <me@entrez.cc>
Thu, 30 Sep 2021 15:22:36 +0000 (11:22 -0400)
committerPatR <rankin@nethack.org>
Tue, 26 Oct 2021 18:55:00 +0000 (11:55 -0700)
Another (latent) case of an artifact possibly being generated and
immediately deleted: part of the process of a mimic disguising itself as
an item involves generating a random object, then deleting it.  If this
item is a box or sack, it will generate with random contents, which will
be deleted along with the container. If artifacts are allowed as random
box contents, this can silently remove an artifact from being available
in the game.

This is effectively blocked already, since none of the artifacts
eligible for random generation are items from classes marked as valid
box contents (see boxiprobs[] in mkobj.c).  Nonetheless, formally
preventing artifacts from generating as box contents will guarantee this
issue won't crop up if a randomly generated artifact tool, ring, etc, is
added in the future.

src/mkobj.c

index abe4c82619efd630dc8b9fbcee0fe2f28e60f04f..fb5fa1db2380378de2607eae6c172ab2e230d1e6 100644 (file)
@@ -273,7 +273,7 @@ mkbox_cnts(struct obj *box)
 
     for (n = rn2(n + 1); n > 0; n--) {
         if (box->otyp == ICE_BOX) {
-            otmp = mksobj(CORPSE, TRUE, TRUE);
+            otmp = mksobj(CORPSE, TRUE, FALSE);
             /* Note: setting age to 0 is correct.  Age has a different
              * from usual meaning for objects stored in ice boxes. -KAA
              */
@@ -288,7 +288,7 @@ mkbox_cnts(struct obj *box)
 
             for (tprob = rnd(100); (tprob -= iprobs->iprob) > 0; iprobs++)
                 ;
-            if (!(otmp = mkobj(iprobs->iclass, TRUE)))
+            if (!(otmp = mkobj(iprobs->iclass, FALSE)))
                 continue;
 
             /* handle a couple of special cases */