]> granicus.if.org Git - nethack/commitdiff
fix github issue #515 - grappling hook internals
authorPatR <rankin@nethack.org>
Fri, 21 May 2021 01:56:03 +0000 (18:56 -0700)
committerPatR <rankin@nethack.org>
Fri, 21 May 2021 01:56:03 +0000 (18:56 -0700)
Grappling hook used to have an undiscovered description of "iron hook"
and when that was removed, the oc_name_known flag was left set as if
for something that could become discovered.  I'm not sure whether that
made any difference anywhere.

Gold piece was in a similar situation, except that it wasn't because
an alternate description had been present and then removed.  That one
definitely didn't make any difference anywhere.

Fixes #515

src/o_init.c
src/objects.c

index 3ebd7edc73be4e130939bcde5b2d3ba6e685af30..22dcab4453908f14187b1ab3ac9d98cc7526c6c6 100644 (file)
@@ -167,14 +167,14 @@ init_objects(void)
                 break;
             }
         }
   check:
checkprob:
         sum = 0;
         for (i = first; i < last; i++)
             sum += objects[i].oc_prob;
         if (sum == 0) {
             for (i = first; i < last; i++)
                 objects[i].oc_prob = (1000 + i - first) / (last - first);
-            goto check;
+            goto checkprob;
         }
         if (sum != 1000)
             error("init-prob error for class %d (%d%%)", oclass, sum);
@@ -191,6 +191,23 @@ init_objects(void)
         if (!g.bases[last])
             g.bases[last] = g.bases[last + 1];
 
+    /* check objects[].oc_name_known */
+    for (i = 0; i < NUM_OBJECTS; ++i) {
+        int nmkn = objects[i].oc_name_known != 0;
+
+        if (!OBJ_DESCR(objects[i]) ^ nmkn) {
+            if (iflags.sanity_check) {
+                impossible(
+                    "obj #%d (%s) name is %s despite%s alternate description",
+                           i, OBJ_NAME(objects[i]),
+                           nmkn ? "pre-known" : "not known",
+                           nmkn ? "" : " no");
+            }
+            /* repair the mistake and keep going */
+            objects[i].oc_name_known = nmkn ? 0 : 1;
+        }
+    }
+
     /* shuffle descriptions */
     shuffle_all();
 #ifdef USE_TILES
index 69db1268959cc9b7d3a4518411910565f24803dc..738b69825514bc4707c12616d74024e5164580aa 100644 (file)
@@ -709,7 +709,7 @@ TOOL("drum of earthquake","drum", 0, 0, 1, 1,  2, 25, 25, LEATHER, HI_LEATHER),
 WEPTOOL("pick-axe", None,
         1, 0, 0, 20, 100,  50,  6,  3, WHACK,  P_PICK_AXE, IRON, HI_METAL),
 WEPTOOL("grappling hook", None,
-        0, 0, 0,  5,  30,  50,  2,  6, WHACK,  P_FLAIL,    IRON, HI_METAL),
+        1, 0, 0,  5,  30,  50,  2,  6, WHACK,  P_FLAIL,    IRON, HI_METAL),
 WEPTOOL("unicorn horn", None,
         1, 1, 1,  0,  20, 100, 12, 12, PIERCE, P_UNICORN_HORN,
                                                            BONE, CLR_WHITE),
@@ -1054,8 +1054,8 @@ WAND(None,            "jeweled",  0, 150, 1, 0, IRON, HI_MINERAL),
 
 /* coins ... - so far, gold is all there is */
 #define COIN(name,prob,metal,worth) \
-    OBJECT(OBJ(name, None),                                        \
-           BITS(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, P_NONE, metal),    \
+    OBJECT(OBJ(name, None),                                         \
+           BITS(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, P_NONE, metal),    \
            0, COIN_CLASS, prob, 0, 1, worth, 0, 0, 0, 0, 0, HI_GOLD)
 COIN("gold piece", 1000, GOLD, 1),
 #undef COIN