arogue7: implement the -n option.

This commit is contained in:
John "Elwin" Edwards 2015-05-11 16:46:00 -04:00
parent 7da765d616
commit 7824f79164
4 changed files with 43 additions and 1 deletions

View file

@ -31,6 +31,8 @@ extern struct uwdata wdata, oldwin;
extern char oldtext[WTXTNUM][WTXTLEN];
#endif
#define SAVEDIR "."
main(argc, argv, envp)
char **argv;
char **envp;
@ -67,6 +69,22 @@ char **envp;
strcat(score_file,"arogue77.scr");
#endif
#ifdef SAVEDIR
/* Check for common save location */
if (argc >= 3 && strcmp(argv[1], "-n") == 0)
{
strncpy(whoami, argv[2], 79);
whoami[79] = '\0';
use_savedir = TRUE;
if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.ar7sav", SAVEDIR,
md_getuid(), whoami))
{
strcpy(file_name, "xrogue.sav");
use_savedir = FALSE;
}
}
#endif
if ((env = getenv("ROGUEOPTS")) != NULL)
parse_opts(env);
@ -138,6 +156,11 @@ char **envp;
nice(19); /* nice the max amount */
#endif
if (use_savedir)
{
if (!restore(file_name, envp))
exit(1);
}
if (argc == 2)
if (!restore(argv[1], envp)) /* Note: restore will never return */
exit(1);