Mercurial > hg > early-roguelike
diff arogue7/main.c @ 128:c697782a9b37
arogue7: implement the -n option.
author | John "Elwin" Edwards |
---|---|
date | Mon, 11 May 2015 16:46:00 -0400 |
parents | 8ae3ffd6c6e7 |
children | 796e2a10cd41 |
line wrap: on
line diff
--- a/arogue7/main.c Mon May 11 13:36:36 2015 -0400 +++ b/arogue7/main.c Mon May 11 16:46:00 2015 -0400 @@ -31,6 +31,8 @@ extern char oldtext[WTXTNUM][WTXTLEN]; #endif +#define SAVEDIR "." + main(argc, argv, envp) char **argv; char **envp; @@ -67,6 +69,22 @@ 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 @@ 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);