From 154b246a35569c2a63b8c00d1f3fb5cbfcc59c73 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 3 Mar 2011 10:23:47 +0000 Subject: [PATCH] #dip fix (trunk only) A post-3.4.3 dipping change (to make the dipping prompt mention the item that you've chosen to dip) formats a phrase for its eventual getobj() call in advance, but then was modifying it inappropriately if you were on a fountain or pool location. If you declined to dip into the fountain or pool, the prompt for carried potion to dip into was garbled: "What do you want to Dip into the fountain??". instead of "What do you want to dip into?". Fix to use a separate buffer in the case of a fountain or pool prompt so that the "dip into" phrase will be intact when calling getobj(). --- src/potion.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/potion.c b/src/potion.c index 29d6d76ab..ba5da82b1 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1744,11 +1744,10 @@ dodip() { register struct obj *potion, *obj; struct obj *singlepotion; - const char *tmp; uchar here; char allowall[2]; short mixture; - char qbuf[QBUFSZ]; + char qbuf[QBUFSZ], qtoo[QBUFSZ]; allowall[0] = ALL_CLASSES; allowall[1] = '\0'; if(!(obj = getobj(allowall, "dip"))) @@ -1759,17 +1758,20 @@ dodip() here = levl[u.ux][u.uy].typ; /* Is there a fountain to dip into here? */ if (IS_FOUNTAIN(here)) { - Strcat(qbuf, " the fountain?"); - if (yn(upstart(qbuf)) == 'y') { + /* "Dip into the fountain?" */ + Sprintf(qtoo, "%s the fountain?", qbuf); + if (yn(upstart(qtoo)) == 'y') { dipfountain(obj); return(1); } } else if (is_pool(u.ux,u.uy)) { - tmp = waterbody_name(u.ux,u.uy); - Sprintf(eos(qbuf), " the %s?", tmp); - if (yn(upstart(qbuf)) == 'y') { + const char *pooltype = waterbody_name(u.ux,u.uy); + + /* "Dip into the {pool, moat, &c}?" */ + Sprintf(qtoo, "%s the %s?", qbuf, pooltype); + if (yn(upstart(qtoo)) == 'y') { if (Levitation) { - floating_above(tmp); + floating_above(pooltype); #ifdef STEED } else if (u.usteed && !is_swimmer(u.usteed->data) && P_SKILL(P_RIDING) < P_BASIC) { @@ -1784,6 +1786,7 @@ dodip() } } + /* "What do you want to dip into?" */ potion = getobj(beverages, qbuf); /* "dip into" */ if (!potion) return 0; if (potion == obj && potion->quan == 1L) { -- 2.40.0