X11: Fix renaming at player selection
Due to the new player selection dialog I did, it was possible to rename your character - but this didn't rename the lock files and tried to load a save from the wrong name. This is a bit of a hack, but seems to work and didn't seem to cause problems for the tty.
This commit is contained in:
@@ -1474,18 +1474,11 @@ X11_askname()
|
||||
{
|
||||
Widget popup, dialog;
|
||||
Arg args[1];
|
||||
char *defplname = (char *)0;
|
||||
|
||||
#ifdef UNIX
|
||||
defplname = get_login_name();
|
||||
#endif
|
||||
(void) strncpy(plname, defplname ? defplname : "Mumbles",
|
||||
sizeof plname - 1);
|
||||
plname[sizeof plname - 1] = '\0';
|
||||
|
||||
if (iflags.wc_player_selection == VIA_DIALOG) {
|
||||
/* X11_player_selection_dialog() handles name query */
|
||||
plsel_ask_name = TRUE;
|
||||
iflags.defer_plname = TRUE;
|
||||
return;
|
||||
} /* else iflags.wc_player_selection == VIA_PROMPTS */
|
||||
|
||||
|
||||
@@ -352,8 +352,13 @@ plsel_dialog_acceptvalues()
|
||||
|
||||
XtSetArg(args[0], nhStr(XtNstring), &s);
|
||||
XtGetValues(plsel_name_input, args, ONE);
|
||||
|
||||
(void) strncpy(plname, (char *) s, sizeof plname - 1);
|
||||
plname[sizeof plname - 1] = '\0';
|
||||
(void) mungspaces(plname);
|
||||
if (strlen(plname) < 1)
|
||||
(void) strcpy(plname, "Mumbles");
|
||||
iflags.renameinprogress = FALSE;
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
@@ -1553,6 +1558,17 @@ void
|
||||
X11_player_selection()
|
||||
{
|
||||
if (iflags.wc_player_selection == VIA_DIALOG) {
|
||||
if (!*plname) {
|
||||
#ifdef UNIX
|
||||
char *defplname = get_login_name();
|
||||
#else
|
||||
char *defplname = (char *)0;
|
||||
#endif
|
||||
(void) strncpy(plname, defplname ? defplname : "Mumbles",
|
||||
sizeof plname - 1);
|
||||
plname[sizeof plname - 1] = '\0';
|
||||
iflags.renameinprogress = TRUE;
|
||||
}
|
||||
X11_player_selection_dialog();
|
||||
} else { /* iflags.wc_player_selection == VIA_PROMPTS */
|
||||
X11_player_selection_prompts();
|
||||
|
||||
Reference in New Issue
Block a user