]> granicus.if.org Git - nethack/commitdiff
B05003 - tree kicking object grammar
authorcohrs <cohrs>
Wed, 30 Jul 2003 05:12:27 +0000 (05:12 +0000)
committercohrs <cohrs>
Wed, 30 Jul 2003 05:12:27 +0000 (05:12 +0000)
<Someone> thought the incorrect grammar in the messages was due to scatter()
changing the quan of treefruit, but in fact, it was due to treefruit
referring to the wrong object (there is also a theoretical possibility that
treefruit can refer to a merged object with the wrong count).  Create a temp
object for use in the message to avoid these possibilities.

src/dokick.c

index 6ca89c08a4c961ac667e6f50bcb06ee046ef85fb..7c146256d614665687bf134c337584f327d92597 100644 (file)
@@ -892,16 +892,21 @@ dokick()
                    if (rn2(15) && !(maploc->looted & TREE_LOOTED) &&
                          (treefruit = rnd_treefruit_at(x, y))) {
                        long nfruit = 8L-rnl(7), nfall;
+                       short frtype = treefruit->otyp;
                        treefruit->quan = nfruit;
                        if (is_plural(treefruit))
                            pline("Some %s fall from the tree!", xname(treefruit));
                        else
                            pline("%s falls from the tree!", An(xname(treefruit)));
                        nfall = scatter(x,y,2,MAY_HIT,treefruit);
-                       if ( nfall != nfruit ) {
-                           /* scatter left some in the tree */
+                       if (nfall != nfruit) {
+                           /* scatter left some in the tree, but treefruit
+                            * may not refer to the correct object */
+                           treefruit = mksobj(frtype, TRUE, FALSE);
+                           treefruit->quan = nfruit-nfall;
                            pline("%ld %s got caught in the branches.",
                                nfruit-nfall, xname(treefruit));
+                           dealloc_obj(treefruit);
                        }
                        exercise(A_DEX, TRUE);
                        exercise(A_WIS, TRUE);  /* discovered a new food source! */