Added -L option to xfrotz - supply a Quetzal file to load on command line.
authorDavid Griffith <dave@661.org>
Fri, 28 Apr 2023 01:53:31 +0000 (18:53 -0700)
committerDavid Griffith <dave@661.org>
Fri, 28 Apr 2023 01:55:52 +0000 (18:55 -0700)
Also converted underlines for parameters in xfrotz.6 to <foobar>.

ChangeLog
doc/xfrotz.6
src/x11/x_init.c
src/x11/x_input.c

index b1f6bd6a03ed7ca4a9ff33deac1d07afb38fb289..f82cc82193e36a67d847ae05118fb324644b31ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,10 @@ Summary of changes between Frotz 2.55 and Frotz 2.55:
 
 Frotz 2.55 is currently in development.
 
+NEW FEATURES
+
+- Added -L option to xfrotz - supply a Quetzal file to load on command line.
+
 BUG FIXES
 
 - Fixed compile failure of the SDL interface for GCC 12 and maybe GCC 11.
index c163af16d1e467ab82ef11f7ff315e62d488c594..447900cdee8926d7a63e0a1e2c4c44ff750664ba 100644 (file)
@@ -38,7 +38,7 @@ Enables watching of attribute assignment.
 (class \fBWatchAttribute\fP, name \fBwatchAttrTest\fP)
 Enables watching of attribute testing.
 .TP
-.BI \-bg " color"
+.B \-bg <color>
 (class \fBBackground\fP, name \fBbackground\fP)
 Sets the default background color.  In addition to the standard X
 color specification formats,
@@ -46,7 +46,7 @@ color specification formats,
 supports the format \fBz:\fP\fInum\fP, which refers to a z-machine
 color from 2 to 9.
 .TP
-.BI \-c " number"
+.B \-c <number>
 (class \fBContextLines\fP, name \fBcontextLines\fP)
 Specifies the number of context lines used.  When scrolling large
 amounts of text,
@@ -56,11 +56,11 @@ specifies how many lines of a previous screen
 .I xfrotz
 will keep at the top of the next screen.
 .TP
-.BI \-fg " color"
+.B \-fg <color>
 (class \fBForeground\fP, name \fBforeground\fP)
 Sets the default foreground color.  See \fB\-bg\fP above.
 .TP
-.BI \-fn[\-z|[f][b][i]] " font name"
+.B \-fn[\-z|[f][b][i]] <font name>
 (class \fBFont\fP, name \fBfont[Z|[F][B][I]]\fP)
 Sets the fonts to be used for various styles.  For example,
 \fB\-fn\-fbi\fP sets the font for fixed, bold, italic text, and
@@ -73,10 +73,13 @@ Ignore runtime errors.  This can be useful when running
 .I xfrotz
 with buggy story files which cause fatal errors.
 .TP
-.BI \-lm " number"
+.B \-lm <number>
 (class \fBMargin\fP, name \fBleftMargin\fP)
 Sets the left margin.
 .TP
+.B \-L <filename>
+When the game starts, load this saved game file.
+.TP
 .B \-ol
 (class \fBWatchObject\fP, name \fBwatchObjLocating\fP)
 Enables watching of testing the location of objects.
@@ -91,18 +94,18 @@ Enable branching on the
 .I @piracy
 opcode.  This opcode is seldom used.
 .TP
-.BI \-rm " number"
+.B \-rm <number>
 (class \fBMargin\fP, name \fBrightMargin\fP)
 Sets the right margin.
 .TP
-.BI \-rs " number"
+.B \-rs <number>
 (class \fBRandomSeed\fP, name \fBrandomSeed\fP)
 Set the random seed.  By default, the random number generator is
 initialized based on the system clock; this allows you to make the
 random number generator predictable, for use in recorded scripts or
 debugging.
 .TP
-.BI \-sc " number"
+.B \-sc <number>
 (class \fBScriptColumns\fP, name \fBscriptColumns\fP)
 Set the transcript width (default 80).  Set to 0 to disable line
 splitting in transcripts.
@@ -113,7 +116,7 @@ Set the z-machine's Tandy bit, which affects the behavior of certain
 Infocom games.  For example, \fIZork I\fP pretends not to have
 sequels, and \fIWitness\fP has its language censored.
 .TP
-.BI \-u " number"
+.B \-u <number>
 (class \fBUndoSlots\fP, name \fBundoSlots\fP)
 Set the number of undo slots available.  The default number is 25.
 Note that many Infocom games do not support an ``undo'' command, and
@@ -129,10 +132,10 @@ expands ``x'' to ``examine,'' ``o'' to ``oops,'' and ``g'' to
 ``again.''  This is convenient when running certain Infocom games
 which do not implement these abbreviations.
 .TP
-.BI \-xrm " resources"
+.B \-xrm <resources>
 This allows setting resources on the command line.
 .TP
-.BI \-zs " level"
+.B \-zs <level>
 (class \fBZStrict\fP, name \fBzStrict\fP)
 Set the reporting level of ``Vile Zero Error From Hell'' bugs.  The
 possible levels are: 0 to print no error messages, 1 to print just one
index a4c3a8d6a974aa9aad8959d7ba444f230ae89a55..74f5bdf0280ab481afe652e6f31cebfeaccd19c8 100644 (file)
@@ -209,7 +209,8 @@ void os_process_arguments(int argc, char *argv[])
                {"-fn-fb", ".fontFB", XrmoptionSepArg, (void *)NULL},
                {"-fn-fi", ".fontFI", XrmoptionSepArg, (void *)NULL},
                {"-fn-fbi", ".fontFBI", XrmoptionSepArg, (void *)NULL},
-               {"-fn-z", ".fontZ", XrmoptionSepArg, (void *)NULL}
+               {"-fn-z", ".fontZ", XrmoptionSepArg, (void *)NULL},
+               {"-L", ".loadthis", XrmoptionSepArg, (void *)NULL}
        };
        static struct {
                char *class;
@@ -270,7 +271,9 @@ void os_process_arguments(int argc, char *argv[])
                {".Font", ".fontFBI", parse_string,
                 &font_names[7]},
                {".Font", ".fontZ", parse_string,
-                &font_names[8]}
+                &font_names[8]},
+               {".Loadthis", ".loadthis", parse_string,
+                &f_setup.tmp_save_name}
        };
        XtAppContext app_context;
        char *str_type_return;
@@ -328,6 +331,9 @@ void os_process_arguments(int argc, char *argv[])
                os_quit(EXIT_SUCCESS);
        }
 
+       if (f_setup.tmp_save_name != NULL)
+               f_setup.restore_mode = 1;
+
        f_setup.story_file = strdup(argv[1]);
        f_setup.story_name = strdup(basename(argv[1]));
 
@@ -371,7 +377,7 @@ void os_process_arguments(int argc, char *argv[])
                memcpy(f_setup.save_name, f_setup.tmp_save_name,
                       (strlen(f_setup.tmp_save_name) +
                        strlen(EXT_SAVE)) * sizeof(char));
-               free(f_setup.tmp_save_name);
+               /* No need to free f_setup.tmp_save_name */
        }
 
        f_setup.aux_name =
@@ -627,6 +633,7 @@ int os_random_seed(void)
 
 void os_init_setup(void)
 {
+       memset(&f_setup, 0, sizeof(x_setup));
        return;
 }
 
index 5ae33f22f2a6ae3f24343a55167f04251493f116..b7e4506eb314d262ea739bdd80f89ced64f766e2 100644 (file)
@@ -245,11 +245,15 @@ char *os_read_file_name(const char *default_name, int flag)
        istream_replay = 0;
        ostream_record = 0;
 
-       print_string("Enter a file name.\nDefault is \"");
-       print_string(default_name);
-       print_string("\": ");
+       if (f_setup.restore_mode) {
+               file_name[0] = 0;
+       } else {
+               print_string("Enter a file name.\nDefault is \"");
+               print_string(default_name);
+               print_string("\": ");
 
-       read_string(MAX_FILE_NAME, (zchar *) file_name);
+               read_string(MAX_FILE_NAME, (zchar *) file_name);
+       }
 
        /* Use the default name if nothing was typed */
        if (file_name[0] == 0)