From 5118970c4107072ab9a03ec5b43e92e8ca81ba4c Mon Sep 17 00:00:00 2001 From: theoddone33 Date: Thu, 10 Jan 2002 05:05:34 +0000 Subject: [PATCH] Round 2: Added --help and --version, as well as HHEXEN_DATA environment variable to control data directory. Don't forget to change those title bars later. git-svn-id: svn://svn.icculus.org/hhexen/trunk@7 c79c8604-0f32-0410-912e-ea7021435596 --- base/i_linux.c | 37 +++++++++++++++++++++++++++++++++++-- base/w_wad.c | 13 ++++++++++--- include/h2def.h | 4 ++++ 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/base/i_linux.c b/base/i_linux.c index ff02262..237e3d8 100644 --- a/base/i_linux.c +++ b/base/i_linux.c @@ -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 \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(); diff --git a/base/w_wad.c b/base/w_wad.c index 24910b5..32d75b6 100644 --- a/base/w_wad.c +++ b/base/w_wad.c @@ -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")) diff --git a/include/h2def.h b/include/h2def.h index aca9aff..331dc7d 100644 --- a/include/h2def.h +++ b/include/h2def.h @@ -24,6 +24,10 @@ #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 -- 2.39.2