]> granicus.if.org Git - nethack/commitdiff
Fix wish text matcher not allowing probability 0 objects
authorPasi Kallinen <paxed@alt.org>
Sat, 30 Apr 2016 19:41:41 +0000 (22:41 +0300)
committerPasi Kallinen <paxed@alt.org>
Sat, 30 Apr 2016 19:41:41 +0000 (22:41 +0300)
src/objnam.c

index d5e1f4b800bb92b0da479df905864a5f78eef462..e6f3569d51d2d8e0403ddcd97d066e4bf0719731 100644 (file)
@@ -2477,7 +2477,7 @@ char oclass;
         }
         if (otyp != STRANGE_OBJECT) {
             validobjs[n++] = otyp;
-            maxprob += objects[otyp].oc_prob;
+            maxprob += (objects[otyp].oc_prob + 1);
             otyp = STRANGE_OBJECT;
         }
         i++;
@@ -2486,7 +2486,7 @@ char oclass;
     if (n > 0 && maxprob) {
         long prob = rn2(maxprob);
         i = 0;
-        while ((i < (n-1)) && (prob -= objects[validobjs[i]].oc_prob) > 0)
+        while ((i < (n-1)) && (prob -= (objects[validobjs[i]].oc_prob + 1)) > 0)
             i++;
         return validobjs[i];
     }