Complies with standard 1.0 of Graham Nelson's specification.\n\
\n\
Syntax: dfrotz [options] story-file\n\
- -a watch attribute setting \t R xxx do runtime setting \\xxx\n\
+ -a watch attribute setting \t -r xxx do runtime setting \\xxx\n\
-A watch attribute testing \t before starting (can be used repeatedly)\n\
- -h # screen height \t -s # random number seed value\n\
- -i ignore fatal errors \t -S # transcript width\n\
- -I # interpreter number \t -t set Tandy bit\n\
- -o watch object movement \t -u # slots for multiple undo\n\
- -O watch object locating \t -w # screen width\n\
- -p plain ASCII output only \t -x expand abbreviations g/x/z\n\
- -P alter piracy opcode"
-
+ -h # screen height \t -R <filename> load this save file\n\
+ -i ignore fatal errors \t -s # random number seed value\n\
+ -I # interpreter number \t -S # transcript width\n\
+ -o watch object movement \t -t set Tandy bit\n\
+ -O watch object locating \t -u # slots for multiple undo\n\
+ -p plain ASCII output only \t -w # screen width\n\
+ -P alter piracy opcode \t -x expand abbreviations g/x/z"
/* A unix-like getopt, but with the names changed to avoid any problems. */
static int zoptind = 1;
do_more_prompts = TRUE;
/* Parse the options */
do {
- c = zgetopt(argc, argv, "aAh:iI:moOpPs:R:S:tu:w:xZ:");
+ c = zgetopt(argc, argv, "aAh:iI:moOpPs:r:R:S:tu:w:xZ:");
switch(c) {
case 'a': f_setup.attribute_assignment = 1; break;
case 'A': f_setup.attribute_testing = 1; break;
case 'O': f_setup.object_locating = 1; break;
case 'P': f_setup.piracy = 1; break;
case 'p': plain_ascii = 1; break;
- case 'R': dumb_handle_setting(zoptarg, FALSE, TRUE); break;
+ case 'R': f_setup.restore_mode = 1;
+ f_setup.tmp_save_name = my_strdup(zoptarg);
+ break;
+ case 'r': dumb_handle_setting(zoptarg, FALSE, TRUE); break;
case 's': user_random_seed = atoi(zoptarg); break;
case 'S': f_setup.script_cols = atoi(zoptarg); break;
case 't': user_tandy_bit = 1; break;
p = strrchr(f_setup.story_name, '.');
*p = '\0'; /* extension removed */
- f_setup.save_name = malloc(strlen(f_setup.story_name) * sizeof(char) + 5);
- strncpy(f_setup.save_name, f_setup.story_name, strlen(f_setup.story_name));
- strncat(f_setup.save_name, EXT_SAVE, strlen(EXT_SAVE));
+
+ if (!f_setup.restore_mode) {
+ f_setup.save_name = malloc(strlen(f_setup.story_name) * sizeof(char) + 5);
+ strncpy(f_setup.save_name, f_setup.story_name, strlen(f_setup.story_name));
+ strncat(f_setup.save_name, EXT_SAVE, strlen(EXT_SAVE));
+ } else { /* Set our auto load save as the name save */
+ f_setup.save_name = malloc(strlen(f_setup.tmp_save_name) * sizeof(char) + 5);
+ strncpy(f_setup.save_name, f_setup.tmp_save_name, strlen(f_setup.tmp_save_name));
+ free(f_setup.tmp_save_name);
+ }
f_setup.script_name = malloc(strlen(f_setup.story_name) * sizeof(char) + 5);
strncpy(f_setup.script_name, f_setup.story_name, strlen(f_setup.story_name));
char buf[INPUT_BUFFER_SIZE], prompt[INPUT_BUFFER_SIZE];
FILE *fp;
- sprintf(prompt, "Please enter a filename [%s]: ", default_name);
- dumb_read_misc_line(buf, prompt);
- if (strlen(buf) > MAX_FILE_NAME) {
- printf("Filename too long\n");
- return FALSE;
+ /* If we're restoring a game before the interpreter starts,
+ * our filename is already provided. Just go ahead silently.
+ */
+ if (f_setup.restore_mode) {
+ strcpy(file_name, default_name);
+ return TRUE;
+ } else {
+ sprintf(prompt, "Please enter a filename [%s]: ", default_name);
+ dumb_read_misc_line(buf, prompt);
+ if (strlen(buf) > MAX_FILE_NAME) {
+ printf("Filename too long\n");
+ return FALSE;
+ }
}
strcpy (file_name, buf[0] ? buf : default_name);