From 9e2b73bff6df616cefa196d8b84561970b5068cf Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 3 Sep 2018 04:11:46 +0200 Subject: [PATCH] Implement --help cmdline arg, set version to 1.4.2pre if --help or -h or -help or -? or /? is passed as commandline argument, the help is printed (to stdout) and then the game quits. The help shows some helpful commandline arguments, including how to tell the engine where to find the game data, how to set the resolution and more --- neo/framework/Common.cpp | 69 ++++++++++++++++++++++++++++++++++++++++ neo/framework/Licensee.h | 5 ++- 2 files changed, 71 insertions(+), 3 deletions(-) diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 62e7e569..1cfeca43 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -2738,12 +2738,81 @@ static unsigned int AsyncTimer(unsigned int interval, void *) { return tick - now; } +static bool checkForHelp(int argc, char **argv) +{ + const char* helpArgs[] = { "--help", "-h", "-help", "-?", "/?" }; + const int numHelpArgs = sizeof(helpArgs)/sizeof(helpArgs[0]); + + for (int i=0; i [command arguments]\n"); + printf(" executes a command (with optional arguments)\n"); + + printf("\nSome interesting commands:\n"); + printf("+map \n"); + printf(" directly loads the given level, e.g. +map game/hell1\n"); + printf("+exec \n"); + printf(" execute the given config (mainly relevant for dedicated servers)\n"); + printf("+disconnect\n"); + printf(" starts the game, goes directly into main menu without showing logo video\n"); + printf("+connect [:port]\n"); + printf(" directly connect to multiplayer server at given host/port\n"); + printf(" e.g. +connect d3.example.com\n"); + printf(" e.g. +connect d3.example.com:27667\n"); + printf(" e.g. +connect 192.168.0.42:27666\n"); + printf("+set \n"); + printf(" Set the given cvar to the given value, e.g. +set r_fullscreen 0\n"); + printf("+seta \n"); + printf(" like +set, but also makes sure the changed cvar is saved (\"archived\") in a cfg\n"); + + printf("\nSome interesting cvars:\n"); + printf("+set fs_basepath \n"); + printf(" set path to your Doom3 game data (the directory base/ is in)\n"); + printf("+set fs_game \n"); + printf(" start the given addon/mod, e.g. +set fs_game d3xp\n"); +#ifndef ID_DEDICATED + printf("+set r_fullscreen <0 or 1>\n"); + printf(" start game in windowed (0) or fullscreen (1) mode\n"); + printf("+set r_mode \n"); + printf(" start game in resolution belonging to ,\n"); + printf(" use -1 for custom resolutions:\n"); + printf("+set r_customWidth \n"); + printf("+set r_customHeight \n"); + printf(" if r_mode is set to -1, these cvars allow you to specify the\n"); + printf(" width/height of your custom resolution\n"); +#endif // !ID_DEDICATED + printf("\nSee https://modwiki.xnet.fi/CVars_%%28Doom_3%%29 for more cvars\n"); + printf("See https://modwiki.xnet.fi/Commands_%%28Doom_3%%29 for more commands\n"); + + return true; + } + } + } + return false; +} + /* ================= idCommonLocal::Init ================= */ void idCommonLocal::Init( int argc, char **argv ) { + + if(checkForHelp(argc, argv)) + { + // game has been started with --help (or similar), usage message has been shown => quit + exit(1); + } + #ifdef ID_DEDICATED // we want to use the SDL event queue for dedicated servers. That // requires video to be initialized, so we just use the dummy diff --git a/neo/framework/Licensee.h b/neo/framework/Licensee.h index 45b19b5a..4bc03220 100644 --- a/neo/framework/Licensee.h +++ b/neo/framework/Licensee.h @@ -36,14 +36,13 @@ If you have questions concerning this license or the applicable additional terms #if defined(__AROS__) #define GAME_NAME "ADoom3" // appears on window titles and errors -#define ENGINE_VERSION "dhewm3 1.4.1" // printed in console #define CONFIG_FILE "adoom3.cfg" #else #define GAME_NAME "dhewm 3" // appears on window titles and errors - -#define ENGINE_VERSION "dhewm 3 1.4.1" // printed in console #endif +#define ENGINE_VERSION "dhewm 3 1.4.2pre" // printed in console + // paths #define BASE_GAMEDIR "base"