Mercurial > hg > early-roguelike
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 127:8ae3ffd6c6e7 | 128:c697782a9b37 |
|---|---|
| 29 #include <ctype.h> | 29 #include <ctype.h> |
| 30 extern struct uwdata wdata, oldwin; | 30 extern struct uwdata wdata, oldwin; |
| 31 extern char oldtext[WTXTNUM][WTXTLEN]; | 31 extern char oldtext[WTXTNUM][WTXTLEN]; |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 #define SAVEDIR "." | |
| 35 | |
| 34 main(argc, argv, envp) | 36 main(argc, argv, envp) |
| 35 char **argv; | 37 char **argv; |
| 36 char **envp; | 38 char **envp; |
| 37 { | 39 { |
| 38 register char *env; | 40 register char *env; |
| 63 | 65 |
| 64 if (*score_file) | 66 if (*score_file) |
| 65 strcat(score_file,"/"); | 67 strcat(score_file,"/"); |
| 66 | 68 |
| 67 strcat(score_file,"arogue77.scr"); | 69 strcat(score_file,"arogue77.scr"); |
| 70 #endif | |
| 71 | |
| 72 #ifdef SAVEDIR | |
| 73 /* Check for common save location */ | |
| 74 if (argc >= 3 && strcmp(argv[1], "-n") == 0) | |
| 75 { | |
| 76 strncpy(whoami, argv[2], 79); | |
| 77 whoami[79] = '\0'; | |
| 78 use_savedir = TRUE; | |
| 79 if (LINELEN <= snprintf(file_name, LINELEN, "%s/%d-%s.ar7sav", SAVEDIR, | |
| 80 md_getuid(), whoami)) | |
| 81 { | |
| 82 strcpy(file_name, "xrogue.sav"); | |
| 83 use_savedir = FALSE; | |
| 84 } | |
| 85 } | |
| 68 #endif | 86 #endif |
| 69 | 87 |
| 70 if ((env = getenv("ROGUEOPTS")) != NULL) | 88 if ((env = getenv("ROGUEOPTS")) != NULL) |
| 71 parse_opts(env); | 89 parse_opts(env); |
| 72 | 90 |
| 136 #if NICE | 154 #if NICE |
| 137 if (!wizard) | 155 if (!wizard) |
| 138 nice(19); /* nice the max amount */ | 156 nice(19); /* nice the max amount */ |
| 139 #endif | 157 #endif |
| 140 | 158 |
| 159 if (use_savedir) | |
| 160 { | |
| 161 if (!restore(file_name, envp)) | |
| 162 exit(1); | |
| 163 } | |
| 141 if (argc == 2) | 164 if (argc == 2) |
| 142 if (!restore(argv[1], envp)) /* Note: restore will never return */ | 165 if (!restore(argv[1], envp)) /* Note: restore will never return */ |
| 143 exit(1); | 166 exit(1); |
| 144 lowtime = (int) time(&now); | 167 lowtime = (int) time(&now); |
| 145 dnum = (wizard && getenv("SEED") != NULL ? | 168 dnum = (wizard && getenv("SEED") != NULL ? |
