Round 2: Added --help and --version, as well as HHEXEN_DATA environment variable...
authortheoddone33 <theoddone33@c79c8604-0f32-0410-912e-ea7021435596>
Thu, 10 Jan 2002 05:05:34 +0000 (05:05 +0000)
committertheoddone33 <theoddone33@c79c8604-0f32-0410-912e-ea7021435596>
Thu, 10 Jan 2002 05:05:34 +0000 (05:05 +0000)
git-svn-id: svn://svn.icculus.org/hhexen/trunk@7 c79c8604-0f32-0410-912e-ea7021435596

base/i_linux.c
base/w_wad.c
include/h2def.h

index ff02262..237e3d8 100644 (file)
@@ -1686,14 +1686,47 @@ void I_CheckExternDriver(void)
        useexterndriver = true;
 }
 
+void PrintHelp(char *name)
+{
+       printf ("HHexen (%s %d.%d)\n", VERSION_PLATFORM,
+                       VERSION_MAJ,VERSION_MIN);
+       printf ("http://icculus.org/hast/\n");
+       printf ("Please send bug reports or patches to:\n");
+       printf ("             Dan Olson <theoddone33@icculus.org>\n");
+       printf ("\n");
+       printf ("Usage: %s [options]\n", name);
+       printf ("     [ -h | --help]           Display this help message\n");
+       printf ("     [ -v | --version]        Display the game version\n");
+       printf ("     [ -f | --fullscreen]     Run the game fullscreen\n");
+       printf ("     [ -w | --windowed]       Run the game windowed\n");
+       printf ("     [ -s | --nosound]        Run the game without sound\n");
+#ifdef RENDER3D
+       printf ("     [ -g | --gllibrary]      Select 3D rendering library\n");
+#endif
+       printf ("\n");
+       printf ("You can use the HHEXEN_DATA environment variable to force the\n");
+       printf ("HHexen data directory.\n");
+       printf ("\n");
+}
+
+void PrintVersion (void)
+{
+       printf ("HHexen (%s %d.%d)\n", VERSION_PLATFORM,
+                       VERSION_MAJ,VERSION_MIN);
+}
 
 int main( int argc, char** argv )
 {
        myargc = argc;
        myargv = argv;
-       if (M_CheckParm("--version"))
+       if (M_CheckParm("--help") || M_CheckParm("-h"))
+       {
+               PrintHelp (argv[0]);
+               return 0;
+       }
+       if (M_CheckParm("--version") || M_CheckParm("-v"))
        {
-               printf("HHexen version 1.3pre3\n");
+               PrintVersion ();
                return 0;
        }
        H2_Main();
index 24910b5..32d75b6 100644 (file)
@@ -130,14 +130,21 @@ void W_AddFile(char *filename)
        wadinfo_t header;
        lumpinfo_t *lump_p;
        unsigned i;
+       char path[128];
        int handle, length;
        int startlump;
        filelump_t *fileinfo, singleinfo;
        filelump_t *freeFileInfo;
 
-       if((handle = open(filename, O_RDONLY|O_BINARY)) == -1)
-       { // Didn't find file
-               return;
+       /* Add support for HHEXEN_DATA envirionment variable */
+       snprintf (path, 128, "%s/%s", getenv("HHEXEN_DATA"), filename);
+       if((handle = open(path, O_RDONLY|O_BINARY)) == -1)
+       {
+               /* Now try CWD */
+               if((handle = open(filename, O_RDONLY|O_BINARY)) == -1)
+               { // Didn't find file
+                       return;
+               }
        }
        startlump = numlumps;
        if(strcmpi(filename+strlen(filename)-3, "wad"))
index aca9aff..331dc7d 100644 (file)
 #define VERSION 110
 #define VERSION_TEXT "v1.1"
 
+#define VERSION_PLATFORM "Linux"
+#define VERSION_MAJ 1
+#define VERSION_MIN 4
+
 // Uncomment, to enable all timebomb stuff
 //#define TIMEBOMB
 #define TIMEBOMB_YEAR  95              // years since 1900