From: cohrs Date: Wed, 30 Jul 2003 05:12:27 +0000 (+0000) Subject: B05003 - tree kicking object grammar X-Git-Tag: MOVE2GIT~1877 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3300cfc7376a9e2b5bfe9029e31fae32121cfc1b;p=nethack B05003 - tree kicking object grammar 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. --- diff --git a/src/dokick.c b/src/dokick.c index 6ca89c08a..7c146256d 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -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! */