hyphenated Unix user names
Fix for $USER, $LOGNAME, getlogin() values that have dashes in them: keep dash and whatever follows as part of the name instead of stripping it off for role/race/gender/alignment. Before: % USER=test-bar-fem ./nethack |Shall I pick your female Barbarian's race and alignment for you? and character ended up named 'test'. After: % USER=test-bar-fem ./nethack |Shall I pick character's race, role, gender and alignment for you? and character ends up named 'test-bar-fem'. However, % ./nethack -u test-bar-fem still behaves like the 'before' case. |Shall I pick your female Barbarian's race and alignment for you? Dash handling is only changed when the dash comes from user name (or from envionment overriding user name), not from direct player input or run-time config file.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 decl.c $NHDT-Date: 1586815084 2020/04/13 21:58:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.209 $ */
|
||||
/* NetHack 3.6 decl.c $NHDT-Date: 1589326673 2020/05/12 23:37:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.212 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2009. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -285,6 +285,7 @@ const struct instance_globals g_init = {
|
||||
0L, /* domove_succeeded */
|
||||
NULL, /* nomovemsg */
|
||||
DUMMY, /* plname */
|
||||
0, /* plnamelen */
|
||||
DUMMY, /* pl_character */
|
||||
'\0', /* pl_race */
|
||||
DUMMY, /* pl_fruit */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 options.c $NHDT-Date: 1584350350 2020/03/16 09:19:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.459 $ */
|
||||
/* NetHack 3.7 options.c $NHDT-Date: 1589326675 2020/05/12 23:37:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.464 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2008. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -8520,7 +8520,7 @@ set_playmode()
|
||||
{
|
||||
if (wizard) {
|
||||
if (authorize_wizard_mode())
|
||||
Strcpy(g.plname, "wizard");
|
||||
g.plnamelen = (int) strlen(strcpy(g.plname, "wizard"));
|
||||
else
|
||||
wizard = FALSE; /* not allowed or not available */
|
||||
/* force explore mode if we didn't make it into wizard mode */
|
||||
|
||||
19
src/role.c
19
src/role.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 role.c $NHDT-Date: 1583102142 2020/03/01 22:35:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.69 $ */
|
||||
/* NetHack 3.6 role.c $NHDT-Date: 1589326676 2020/05/12 23:37:56 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.70 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985-1999. */
|
||||
/*-Copyright (c) Robert Patrick Rankin, 2012. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1657,14 +1657,19 @@ plnamesuffix()
|
||||
&& (sptr[i] == ' ' || sptr[i] == '\0'))
|
||||
*g.plname = '\0'; /* call askname() */
|
||||
}
|
||||
if (!*g.plname)
|
||||
g.plnamelen = 0;
|
||||
}
|
||||
|
||||
do {
|
||||
if (!*g.plname)
|
||||
if (!*g.plname) {
|
||||
askname(); /* fill g.plname[] if necessary, or set defer_plname */
|
||||
g.plnamelen = 0; /* plname[] might have -role-race-&c attached */
|
||||
}
|
||||
|
||||
/* Look for tokens delimited by '-' */
|
||||
if ((eptr = index(g.plname, '-')) != (char *) 0)
|
||||
sptr = g.plname + g.plnamelen;
|
||||
if ((eptr = index(sptr, '-')) != (char *) 0)
|
||||
*eptr++ = '\0';
|
||||
while (eptr) {
|
||||
/* Isolate the next token */
|
||||
@@ -1685,10 +1690,7 @@ plnamesuffix()
|
||||
} while (!*g.plname && !iflags.defer_plname);
|
||||
|
||||
/* commas in the g.plname confuse the record file, convert to spaces */
|
||||
for (sptr = g.plname; *sptr; sptr++) {
|
||||
if (*sptr == ',')
|
||||
*sptr = ' ';
|
||||
}
|
||||
(void) strNsubst(g.plname, ",", " ", 0);
|
||||
}
|
||||
|
||||
/* show current settings for name, role, race, gender, and alignment
|
||||
@@ -1739,7 +1741,8 @@ winid where;
|
||||
to narrow something done to a single choice] */
|
||||
|
||||
Sprintf(buf, "%12s ", "name:");
|
||||
Strcat(buf, (which == RS_NAME) ? choosing : !*g.plname ? not_yet : g.plname);
|
||||
Strcat(buf, (which == RS_NAME) ? choosing
|
||||
: !*g.plname ? not_yet : g.plname);
|
||||
putstr(where, 0, buf);
|
||||
Sprintf(buf, "%12s ", "role:");
|
||||
Strcat(buf, (which == RS_ROLE) ? choosing : (r == ROLE_NONE)
|
||||
|
||||
Reference in New Issue
Block a user