]> granicus.if.org Git - nethack/commitdiff
^G limit
authorPatR <rankin@nethack.org>
Sun, 8 Mar 2020 17:29:39 +0000 (10:29 -0700)
committerPatR <rankin@nethack.org>
Sun, 8 Mar 2020 17:29:39 +0000 (10:29 -0700)
Relax the count limit from 255 to ROWNO*(COLNO-1) so that it can
be big enough to fill an entire level yet remain small enough to
not churn away seemingly forever if an absurd amount is specified
for 'random' or for a class rather than a type.  (By-type already
gives up as soon as failure occurs, so is implicitly limited to a
count matching the available space on the level.)  Also impose the
same limit on 'count ^G monster' as '^G count monster'.

src/minion.c
src/read.c

index dac4430a0ad693bcce75600109c91d0955053edf..eb5697967e4dc308e679fecde39ba849ce2fabe5 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 minion.c        $NHDT-Date: 1575245071 2019/12/02 00:04:31 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.44 $ */
+/* NetHack 3.6 minion.c        $NHDT-Date: 1583688543 2020/03/08 17:29:03 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.53 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2008. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -39,6 +39,8 @@ boolean spotted; /* seen|sensed vs all */
     for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
         if (DEADMONSTER(mtmp))
             continue;
+        if (mtmp->isgd && mtmp->mx == 0)
+            continue;
         if (spotted && !canspotmon(mtmp))
             continue;
         ++count;
index a9feab136bb2263103f49463ce60b9adea5045d5..87320dca82532295dfd3c0f35a8841f5c0011866 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 read.c  $NHDT-Date: 1561485713 2019/06/25 18:01:53 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.172 $ */
+/* NetHack 3.6 read.c  $NHDT-Date: 1583688568 2020/03/08 17:29:28 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.190 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2012. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2464,17 +2464,25 @@ struct _create_particular_data *d;
     d->sleeping = d->saddled = d->invisible = d->hidden = FALSE;
 
     /* quantity */
-    if (digit(*bufp) && strcmp(bufp, "0")) {
-        d->quan = min(255, atoi(bufp));
+    if (digit(*bufp)) {
+        d->quan = atoi(bufp);
         while (digit(*bufp))
             bufp++;
         while (*bufp == ' ')
             bufp++;
     }
+#define QUAN_LIMIT (ROWNO * (COLNO - 1))
+    /* maximum possible quantity is one per cell: (0..ROWNO-1) x (1..COLNO-1)
+       [21*79==1659 for default map size; could subtract 1 for hero's spot] */
+    if (d->quan < 1 || d->quan > QUAN_LIMIT)
+        d->quan = QUAN_LIMIT - monster_census(FALSE);
+#undef QUAN_LIMIT
+    /* gear -- extremely limited number of possibilities supported */
     if ((tmpp = strstri(bufp, "saddled ")) != 0) {
         d->saddled = TRUE;
         (void) memset(tmpp, ' ', sizeof "saddled " - 1);
     }
+    /* state -- limited number of possibilitie supported */
     if ((tmpp = strstri(bufp, "sleeping ")) != 0) {
         d->sleeping = TRUE;
         (void) memset(tmpp, ' ', sizeof "sleeping " - 1);