* behaviour of various NetHack functions and probably warrant
* a structure of their own elsewhere some day.
*/
+ boolean defer_plname; /* X11 hack: askname() might not set plname */
boolean herecmd_menu; /* use menu when mouseclick on yourself */
boolean invis_goldsym; /* gold symbol is ' '? */
int parse_config_file_src; /* hack for parse_config_line() */
do {
if (!*plname)
- askname(); /* fill plname[] if necessary */
+ askname(); /* fill plname[] if necessary, or set defer_plname */
/* Look for tokens delimited by '-' */
if ((eptr = index(plname, '-')) != (char *) 0)
else if ((i = str2align(sptr)) != ROLE_NONE)
flags.initalign = i;
}
- } while (!*plname);
+ } while (!*plname && !iflags.defer_plname);
/* commas in the plname confuse the record file, convert to spaces */
for (sptr = plname; *sptr; sptr++) {
POSTINSTALL= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; (cd $(INSTDIR); mkfontdir);
-CFLAGS=-O -I../include -DNOTPARMDECL
+CFLAGS=-g -O -I../include -DNOTPARMDECL
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\"
CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
CFLAGS+=-DX11_GRAPHICS -DDEFAULT_WINDOW_SYS=\"X11\" -DNOTTYGRAPHICS
#endif
boolean exact_username;
boolean resuming = FALSE; /* assume new game */
+ boolean plsel_once = FALSE;
sys_early_init();
(void) signal(SIGQUIT, SIG_IGN);
(void) signal(SIGINT, SIG_IGN);
}
- /*
- * getlock() complains and quits if there is already a game
- * in progress for current character name (when locknum == 0)
- * or if there are too many active games (when locknum > 0).
- * When proceeding, it creates an empty <lockname>.0 file to
- * designate the current game.
- * getlock() constructs <lockname> based on the character
- * name (for !locknum) or on first available of alock, block,
- * clock, &c not currently in use in the playground directory
- * (for locknum > 0).
- */
- getlock();
- program_state.preserve_locks = 0; /* after getlock() */
dlb_init(); /* must be before newgame() */
* We'll return here if new game player_selection() renames the hero.
*/
attempt_restore:
- if ((fd = restore_saved_game()) >= 0) {
+
+ /*
+ * getlock() complains and quits if there is already a game
+ * in progress for current character name (when locknum == 0)
+ * or if there are too many active games (when locknum > 0).
+ * When proceeding, it creates an empty <lockname>.0 file to
+ * designate the current game.
+ * getlock() constructs <lockname> based on the character
+ * name (for !locknum) or on first available of alock, block,
+ * clock, &c not currently in use in the playground directory
+ * (for locknum > 0).
+ */
+ if (*plname) {
+ getlock();
+ program_state.preserve_locks = 0; /* after getlock() */
+ }
+
+ if (*plname && (fd = restore_saved_game()) >= 0) {
const char *fq_save = fqname(SAVEF, SAVEPREFIX, 1);
(void) chmod(fq_save, 0); /* disallow parallel restores */
}
if (!resuming) {
+ boolean neednewlock = (!*plname);
/* new game: start by choosing role, race, etc;
player might change the hero's name while doing that,
in which case we try to restore under the new name
and skip selection this time if that didn't succeed */
- if (!iflags.renameinprogress) {
- player_selection();
+ if (!iflags.renameinprogress || iflags.defer_plname || neednewlock) {
+ if (!plsel_once)
+ player_selection();
+ plsel_once = TRUE;
+ if (neednewlock && *plname)
+ goto attempt_restore;
if (iflags.renameinprogress) {
/* player has renamed the hero while selecting role;
if locking alphabetically, the existing lock file
{
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 */
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 */
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();