EDIT_GETLIN when naming monsters and objects

Like #annotate, #name monster, #name individual object, and #name
object type are places where it makes some sense to have an existing
name be the default for the new name, in case taking off from the end
and/or adding to the end is more convenient than retyping everything.

When there is an existing name used as default, clearing that default
and hitting <return> is not enough to remove the name, you still need
to 'assign a new name' of <space> to do that.
This commit is contained in:
PatR
2019-06-15 08:19:32 -07:00
parent 747981d0c5
commit 820320ba55
2 changed files with 28 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.55 $ $NHDT-Date: 1560608320 2019/06/15 14:18:40 $
$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.56 $ $NHDT-Date: 1560611967 2019/06/15 15:19:27 $
This fixes36.3 file is here to capture information about updates in the 3.6.x
lineage following the release of 3.6.2 in May 2019. Please note, however,
@@ -100,6 +100,8 @@ Platform- and/or Interface-Specific Fixes or Features
EDIT_GETLIN: wizard mode 'monpolycontrol' was using the getlin() answer buffer
to format the coordinate portion of the "change <monster> @ <x,y> into
what kind of monster?" prompt, resulting in "<x,y>" as default answer
EDIT_GETLIN: when naming an object or a monster use the existing name, if
there is one, as the default answer
curses: very tall menus tried to use selector characters a-z, A-Z, and 0-9,
but 0-9 should be reserved for counts and if the display was tall
enough for more than 62 entries, arbitrary ASCII punctuation got used

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1560387831 2019/06/13 01:03:51 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.148 $ */
/* NetHack 3.6 do_name.c $NHDT-Date: 1560611967 2019/06/15 15:19:27 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Pasi Kallinen, 2018. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1159,6 +1159,11 @@ do_mname()
Sprintf(qbuf, "What do you want to call %s?",
distant_monnam(mtmp, ARTICLE_THE, monnambuf));
buf[0] = '\0';
#ifdef EDIT_GETLIN
/* if there's an existing name, make it be the default answer */
if (has_mname(mtmp))
Strcpy(buf, MNAME(mtmp));
#endif
getlin(qbuf, buf);
if (!*buf || *buf == '\033')
return;
@@ -1171,6 +1176,9 @@ do_mname()
*
* Don't say the name is being rejected if it happens to match
* the existing name.
*
* TODO: should have an alternate message when the attempt is to
* remove existing name without assigning a new one.
*/
if ((mtmp->data->geno & G_UNIQ) && !mtmp->ispriest) {
if (!alreadynamed(mtmp, monnambuf, buf))
@@ -1199,7 +1207,7 @@ void
do_oname(obj)
register struct obj *obj;
{
char *bufp, buf[BUFSZ] = DUMMY, bufcpy[BUFSZ], qbuf[QBUFSZ];
char *bufp, buf[BUFSZ], bufcpy[BUFSZ], qbuf[QBUFSZ];
const char *aname;
short objtyp;
@@ -1212,6 +1220,12 @@ register struct obj *obj;
Sprintf(qbuf, "What do you want to name %s ",
is_plural(obj) ? "these" : "this");
(void) safe_qbuf(qbuf, qbuf, "?", obj, xname, simpleonames, "item");
buf[0] = '\0';
#ifdef EDIT_GETLIN
/* if there's an existing name, make it be the default answer */
if (has_oname(obj))
Strcpy(buf, ONAME(obj));
#endif
getlin(qbuf, buf);
if (!*buf || *buf == '\033')
return;
@@ -1454,7 +1468,7 @@ void
docall(obj)
struct obj *obj;
{
char buf[BUFSZ] = DUMMY, qbuf[QBUFSZ];
char buf[BUFSZ], qbuf[QBUFSZ];
char **str1;
if (!obj->dknown)
@@ -1467,12 +1481,19 @@ struct obj *obj;
else
(void) safe_qbuf(qbuf, "Call ", ":", obj,
docall_xname, simpleonames, "thing");
/* pointer to old name */
str1 = &(objects[obj->otyp].oc_uname);
buf[0] = '\0';
#ifdef EDIT_GETLIN
/* if there's an existing name, make it be the default answer */
if (*str1)
Strcpy(buf, *str1);
#endif
getlin(qbuf, buf);
if (!*buf || *buf == '\033')
return;
/* clear old name */
str1 = &(objects[obj->otyp].oc_uname);
if (*str1)
free((genericptr_t) *str1);