Added the capability to load a save file as a command line argument. Now you don...
authorMichael Anghelone <manghelone@mediamath.com>
Wed, 20 Jan 2016 03:01:32 +0000 (22:01 -0500)
committerMichael Anghelone <manghelone@mediamath.com>
Wed, 20 Jan 2016 15:22:39 +0000 (10:22 -0500)
I these changes are only going to effect the curses version for now. I do not have a proper enviroment setup to test out dos.

Example:
frotz file.zblorb -R save.qzl

ChangeLog
src/common/process.c
src/common/setup.h
src/curses/ux_init.c
src/curses/ux_input.c
src/dos/bcinit.c
src/dumb/dumb_init.c
src/sdl/sf_resource.c

index 8d3ace7dff5f215b4ccf502687925c6000e9fbb4..a7767b1165fac65bb8d816db34e9a208ad88078d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Summary of changes between Frotz 2.44 and Frotz 2.45:
+=====================================================
+
+Frotz 2.45 was released on Wednesday, January 20, 2016.
+
+NEW FEATURE
+
+- Added -R option for restoring save file directly from the command line.
+
+
 Summary of changes between Frotz 2.43 and Frotz 2.44:
 =====================================================
 
index 9847071ce3f0c49c0b69bc10e2b1758badbb9c92..6944ce33e42909ceced0f645617818869ffc83ef 100644 (file)
@@ -255,6 +255,12 @@ static void load_all_operands (zbyte specifier)
  */
 void interpret (void)
 {
+/*before we start lets load a save if one was given from the command line*/
+    if(f_setup.restore_mode==1)
+     {
+      z_restore();
+      f_setup.restore_mode=0;
+     } 
 
     do {
 
index 7fe3368f31eb67c6093e49013fd2de303d236614..206015d2cf4334163ae0a6b6370dda9e1936eb9a 100644 (file)
@@ -26,9 +26,11 @@ typedef struct frotz_setup_struct {
         char *script_name;
         char *command_name;
         char *save_name;
+        char *tmp_save_name;
         char *aux_name;
         char *story_path;
         char *zcode_path;
+       int restore_mode; /* for a save file passed from command line*/
 } f_setup_t;
 
 extern f_setup_t f_setup;
index 57f154d3518a7132a93ce1846970925a653fe90d..4887bedd4e4478b1fe8adb072e32e9bd83dcb0ba 100644 (file)
@@ -72,14 +72,14 @@ Syntax: frotz [options] story-file\n\
   -b # background color         \t -P   alter piracy opcode\n\
   -c # context lines            \t -q   quiet (disable sound effects)\n\
   -d   disable color            \t -r # right margin\n\
-  -e   enable sound             \t -s # random number seed value\n\
-  -f # foreground color         \t -S # transcript width\n\
-  -F   Force color mode         \t -t   set Tandy bit\n\
-  -h # screen height            \t -u # slots for multiple undo\n\
-  -i   ignore fatal errors      \t -w # screen width\n\
-  -l # left margin              \t -x   expand abbreviations g/x/z\n\
-  -o   watch object movement"
-
+  -e   enable sound             \t -R   load a save file directly from command line\n\
+  -f # foreground color         \t -s # random number seed value\n\
+  -F   Force color mode         \t -S # transcript width\n\
+  -h # screen height            \t -t   set Tandy bit\n\
+  -i   ignore fatal errors      \t -u # slots for multiple undo\n\
+  -l # left margin              \t -w # screen width\n\
+  -o   watch object movement   \t -x   expand abbreviations g/x/z\n"
+                                
 /*
 char stripped_story_name[FILENAME_MAX+1];
 char semi_stripped_story_name[FILENAME_MAX+1];
@@ -207,10 +207,12 @@ void os_process_arguments (int argc, char *argv[])
        getconfig(configfile);  /* we're not concerned if this fails */
     }
 
+    f_setup.tmp_save_name = malloc(FILENAME_MAX * sizeof(char)); /*needs to be initialized before we get to parsing our options*/
+
     /* Parse the options */
 
     do {
-       c = getopt(argc, argv, "aAb:c:def:Fh:il:oOpPqr:s:S:tu:w:xZ:");
+       c = getopt(argc, argv, "aAb:c:def:Fh:il:oOpPqrR:s:S:tu:w:xZ:");
        switch(c) {
          case 'a': f_setup.attribute_assignment = 1; break;
          case 'A': f_setup.attribute_testing = 1; break;
@@ -244,6 +246,7 @@ void os_process_arguments (int argc, char *argv[])
          case 'P': f_setup.piracy = 1; break;
          case 'q': f_setup.sound = 0; break;
          case 'r': f_setup.right_margin = atoi(optarg); break;
+         case 'R': f_setup.restore_mode = 1; strcpy(f_setup.tmp_save_name, optarg); break;
          case 's': u_setup.random_seed = atoi(optarg); break;
          case 'S': f_setup.script_cols = atoi(optarg); break;
          case 't': u_setup.tandy_bit = 1; break;
@@ -340,6 +343,7 @@ void os_process_arguments (int argc, char *argv[])
     strncpy(f_setup.command_name, f_setup.story_name, strlen(f_setup.story_name));
     strncat(f_setup.command_name, EXT_COMMAND, strlen(EXT_COMMAND));
 
+
     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));
@@ -347,6 +351,14 @@ void os_process_arguments (int argc, char *argv[])
     f_setup.aux_name = malloc(strlen(f_setup.story_name) * sizeof(char) + 5);
     strncpy(f_setup.aux_name, f_setup.story_name, strlen(f_setup.story_name));
     strncat(f_setup.aux_name, EXT_AUX, strlen(EXT_AUX));
+    
+    /*Set our auto load save as the name_save*/
+     if(f_setup.restore_mode == 1)
+       {
+        char * delete_me = f_setup.save_name;
+        f_setup.save_name=f_setup.tmp_save_name;
+       free(delete_me);
+        }
 
     switch (ux_init_blorb()) {
         case bb_err_Format:
@@ -1029,6 +1041,7 @@ void os_init_setup(void)
        f_setup.script_cols = 80;
        f_setup.sound = 1;
        f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
+       f_setup.restore_mode = 0;
 
        u_setup.use_blorb = 0;
        u_setup.exec_in_blorb = 0;
index a681742570ed2ebf14e52fc8d789ab119c506f3a..fd91c81eb42925c816d8c6cf98a2f2870fd09859 100644 (file)
@@ -633,7 +633,6 @@ zchar os_read_key (int timeout, int cursor)
 
 int os_read_file_name (char *file_name, const char *default_name, int flag)
 {
-
     int saved_replay = istream_replay;
     int saved_record = ostream_record;
 
@@ -641,12 +640,16 @@ int os_read_file_name (char *file_name, const char *default_name, int flag)
 
     istream_replay = 0;
     ostream_record = 0;
+    if(f_setup.restore_mode==0)
+       {
+        print_string ("Enter a file name.\nDefault is \"");
+        print_string (default_name);
+        print_string ("\": ");
 
-    print_string ("Enter a file name.\nDefault is \"");
-    print_string (default_name);
-    print_string ("\": ");
-
-    read_string (FILENAME_MAX, (zchar *)file_name);
+        read_string (FILENAME_MAX, (zchar *)file_name);
+       }
+       else
+       file_name[0]=0;//set to zero because we are not taking user input
 
     /* Use the default name if nothing was typed */
 
index d6f19cc5c74ab84799cbbb874b0346c7d0b07adc..a08e03a4d104d55da0af6678ebfb8655708fb1e3 100644 (file)
@@ -106,6 +106,7 @@ void os_init_setup(void)
        f_setup.script_cols = 80;\r
        f_setup.sound = 1;\r
        f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;\r
+       f_setup.restore_mode = 0;\r
 \r
 }/* os_init_setup */\r
 \r
index b3cc7c8187ea0d16d43f10e03949126228b61332..8f65399989ebccecdf8618d44089177f5d8de020 100644 (file)
@@ -211,5 +211,6 @@ void os_init_setup(void)
        f_setup.script_cols = 80;
        f_setup.sound = 1;
        f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
+       f_setup.restore_mode = 0;
 
 }
index d723c27400bdd2bb2014228dad1f8ac401c18e13..856bd27c61dda02ff3ec0cf4fc0b1d160871b03f 100644 (file)
@@ -1033,5 +1033,6 @@ void os_init_setup(void)
        f_setup.save_quetzal = 1;
        f_setup.sound = 1;
        f_setup.err_report_mode = ERR_DEFAULT_REPORT_MODE;
+       f_setup.restore_mode = 0;
 
 }