mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-21 02:01:03 +00:00
Output --help text to Console window on Windows
(that Console thing they wrote for the dedicated server which is also used by Sys_Error())
This commit is contained in:
parent
f5dfdead43
commit
4a94ec0ac0
2 changed files with 56 additions and 38 deletions
|
@ -231,6 +231,7 @@ elseif(MSVC)
|
|||
add_compile_options(/wd4714) # 'function' marked as __forceinline not inlined
|
||||
add_compile_options(/wd4996) # 'function': was declared deprecated
|
||||
add_compile_options(/wd4068) # unknown pragma
|
||||
add_compile_options(/wd4458) # declaration of 'variable' hides class member
|
||||
add_definitions(-D_ALLOW_KEYWORD_MACROS) # because of the "#define private public" and "#define protected public" in TypeInfo.cpp
|
||||
set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG /Od /Zi /MDd")
|
||||
set(CMAKE_C_FLAGS_RELEASE "/Ox /Oy /MD")
|
||||
|
|
|
@ -2759,6 +2759,10 @@ static unsigned int AsyncTimer(unsigned int interval, void *) {
|
|||
return tick - now;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "../sys/win32/win_local.h" // for Conbuf_AppendText()
|
||||
#endif // _WIN32
|
||||
|
||||
static bool checkForHelp(int argc, char **argv)
|
||||
{
|
||||
const char* helpArgs[] = { "--help", "-h", "-help", "-?", "/?" };
|
||||
|
@ -2771,48 +2775,56 @@ static bool checkForHelp(int argc, char **argv)
|
|||
{
|
||||
if (idStr::Icmp(arg, helpArgs[h]) == 0)
|
||||
{
|
||||
// TODO: use Printf() or sth instead?
|
||||
printf("%s - http://dhewm3.org\n", ENGINE_VERSION);
|
||||
printf("Commandline arguments:\n");
|
||||
printf("-h or --help: Show this help\n");
|
||||
printf("+<command> [command arguments]\n");
|
||||
printf(" executes a command (with optional arguments)\n");
|
||||
#ifdef _WIN32
|
||||
// write it to the Windows-only console window
|
||||
#define WriteString(s) Conbuf_AppendText(s)
|
||||
#else // not windows
|
||||
// write it to stdout
|
||||
#define WriteString(s) fputs(s, stdout);
|
||||
#endif // _WIN32
|
||||
WriteString(ENGINE_VERSION " - http://dhewm3.org\n");
|
||||
WriteString("Commandline arguments:\n");
|
||||
WriteString("-h or --help: Show this help\n");
|
||||
WriteString("+<command> [command arguments]\n");
|
||||
WriteString(" executes a command (with optional arguments)\n");
|
||||
|
||||
printf("\nSome interesting commands:\n");
|
||||
printf("+map <map>\n");
|
||||
printf(" directly loads the given level, e.g. +map game/hell1\n");
|
||||
printf("+exec <config>\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 <host>[: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 <cvarname> <value>\n");
|
||||
printf(" Set the given cvar to the given value, e.g. +set r_fullscreen 0\n");
|
||||
printf("+seta <cvarname> <value>\n");
|
||||
printf(" like +set, but also makes sure the changed cvar is saved (\"archived\") in a cfg\n");
|
||||
WriteString("\nSome interesting commands:\n");
|
||||
WriteString("+map <map>\n");
|
||||
WriteString(" directly loads the given level, e.g. +map game/hell1\n");
|
||||
WriteString("+exec <config>\n");
|
||||
WriteString(" execute the given config (mainly relevant for dedicated servers)\n");
|
||||
WriteString("+disconnect\n");
|
||||
WriteString(" starts the game, goes directly into main menu without showing\n logo video\n");
|
||||
WriteString("+connect <host>[:port]\n");
|
||||
WriteString(" directly connect to multiplayer server at given host/port\n");
|
||||
WriteString(" e.g. +connect d3.example.com\n");
|
||||
WriteString(" e.g. +connect d3.example.com:27667\n");
|
||||
WriteString(" e.g. +connect 192.168.0.42:27666\n");
|
||||
WriteString("+set <cvarname> <value>\n");
|
||||
WriteString(" Set the given cvar to the given value, e.g. +set r_fullscreen 0\n");
|
||||
WriteString("+seta <cvarname> <value>\n");
|
||||
WriteString(" like +set, but also makes sure the changed cvar is saved (\"archived\")\n in a cfg\n");
|
||||
|
||||
printf("\nSome interesting cvars:\n");
|
||||
printf("+set fs_basepath <gamedata path>\n");
|
||||
printf(" set path to your Doom3 game data (the directory base/ is in)\n");
|
||||
printf("+set fs_game <modname>\n");
|
||||
printf(" start the given addon/mod, e.g. +set fs_game d3xp\n");
|
||||
WriteString("\nSome interesting cvars:\n");
|
||||
WriteString("+set fs_basepath <gamedata path>\n");
|
||||
WriteString(" set path to your Doom3 game data (the directory base/ is in)\n");
|
||||
WriteString("+set fs_game <modname>\n");
|
||||
WriteString(" 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 <modenumber>\n");
|
||||
printf(" start game in resolution belonging to <modenumber>,\n");
|
||||
printf(" use -1 for custom resolutions:\n");
|
||||
printf("+set r_customWidth <size in pixels>\n");
|
||||
printf("+set r_customHeight <size in pixels>\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");
|
||||
WriteString("+set r_fullscreen <0 or 1>\n");
|
||||
WriteString(" start game in windowed (0) or fullscreen (1) mode\n");
|
||||
WriteString("+set r_mode <modenumber>\n");
|
||||
WriteString(" start game in resolution belonging to <modenumber>,\n");
|
||||
WriteString(" use -1 for custom resolutions:\n");
|
||||
WriteString("+set r_customWidth <size in pixels>\n");
|
||||
WriteString("+set r_customHeight <size in pixels>\n");
|
||||
WriteString(" if r_mode is set to -1, these cvars allow you to specify the\n");
|
||||
WriteString(" 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");
|
||||
WriteString("\nSee https://modwiki.xnet.fi/CVars_%%28Doom_3%%29 for more cvars\n");
|
||||
WriteString("See https://modwiki.xnet.fi/Commands_%%28Doom_3%%29 for more commands\n");
|
||||
|
||||
#undef WriteString
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2831,6 +2843,11 @@ 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
|
||||
#ifdef _WIN32
|
||||
// this enforces that the console window is shown until the user closes it
|
||||
// => checkForHelp() writes to the console window on Windows
|
||||
Sys_Error(".");
|
||||
#endif // _WIN32
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue