From 3d9c482eaee016ffe7932cc2eb49805ae147de6d Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Wed, 4 Mar 2020 08:55:22 +0300 Subject: [PATCH] host: add -help, fix #136 --- engine/common/host.c | 103 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/engine/common/host.c b/engine/common/host.c index d1619ad9..9f1b043e 100644 --- a/engine/common/host.c +++ b/engine/common/host.c @@ -61,6 +61,101 @@ convar_t *host_sleeptime; convar_t *con_gamemaps; convar_t *build, *ver; +void Sys_PrintUsage( void ) +{ + const char *usage_str; + +#define O(x,y) " "x" "y"\n" + + usage_str = "" +#if XASH_MESSAGEBOX == MSGBOX_STDERR + "\n" // dirty hack to not have Xash Error: Usage: on same line +#endif // XASH_MESSAGEBOX == MSGBOX_STDERR + "Usage:\n" +#if !XASH_MOBILE_PLATFORM + #if XASH_WIN32 + O(".exe [options] [+command1] [+command2 arg]","") + #else // XASH_WIN32 + O(" [options] [+command1] [+command2 arg]","") + #endif // !XASH_WIN32 +#endif // !XASH_MOBILE_PLATFORM + "Options:\n" + O("-dev [level] ","set log verbosity 0-2") + O("-log ","write log to \"engine.log\"") + O("-nowriteconfig ","disable config save") +#if !XASH_WIN32 + O("-casesensitive ","disable case-insensitive FS emulation") +#endif // !XASH_WIN32 +#if !XASH_MOBILE_PLATFORM + O("-daemonize ","run engine in background, dedicated only") +#endif // !XASH_MOBILE_PLATFORM + +#if !XASH_DEDICATED + O("-toconsole ","run engine witn console open") + O("-width ","set window width") + O("-height ","set window height") + O("-oldfont ","enable unused Quake font in Half-Life") + + #if !XASH_MOBILE_PLATFORM + O("-fullscreen ","run engine in fullscreen mode") + O("-windowed ","run engine in windowed mode") + O("-dedicated ","run engine in dedicated server mode") + #endif // XASH_MOBILE_PLATFORM + + #if XASH_ANDROID + O("-nativeegl ","use native egl implementation. Use if screen does not update or black") + #endif // XASH_ANDROID + + #if XASH_WIN32 + O("-noavi ","disable AVI support") + O("-nointro ","disable intro video") + #endif // XASH_WIN32 + + #if XASH_DOS + O("-novesa ","disable vesa") + #endif // XASH_DOS + + #if XASH_VIDEO == VIDEO_FBDEV + O("-fbdev ","open selected framebuffer") + O("-ttygfx ","set graphics mode in tty") + O("-doublebuffer ","enable doublebuffering") + #endif // XASH_VIDEO == VIDEO_FBDEV + + #if XASH_SOUND == SOUND_ALSA + O("-alsadev ","open selected ALSA device") + #endif // XASH_SOUND == SOUND_ALSA + + O("-nojoy ","disable joystick support") + #ifdef XASH_SDL + O("-sdl_joy_old_api ","use SDL legacy joystick API") + O("-sdl_renderer ","use alternative SDL_Renderer for software") + #endif // XASH_SDL + O("-nosound ","disable sound") + O("-noenginemouse ","disable mouse completely") + + O("-ref ","use selected renderer dll") + O("-gldebug ","enable OpenGL debug log") + +#endif // XASH_DEDICATED + + O("-noip ","disable TCP/IP") + O("-noch ","disable crashhandler") + O("-disablehelp ","disable this message") + O("-dll ","override server DLL path") +#ifndef XASH_DEDICATED + O("-clientlib ","override client DLL path") +#endif + O("-rodir ","set read-only base directory, experimental") + + O("-ip ","set custom ip") + O("-port ","set custom host port") + O("-clockwindow ","adjust clockwindow") + ; +#undef O + + Sys_Error( "%s", usage_str ); +} + int Host_CompareFileTime( int ft1, int ft2 ) { if( ft1 < ft2 ) @@ -674,6 +769,14 @@ void Host_InitCommon( int argc, char **argv, const char *progname, qboolean bCha // so we clear all cmd_args, but leave dbg states as well Sys_ParseCommandLine( argc, argv ); + if( !Sys_CheckParm( "-disablehelp" ) ) + { + if( Sys_CheckParm( "-help" ) || Sys_CheckParm( "-h" ) || Sys_CheckParm( "--help" ) ) + { + Sys_PrintUsage(); + } + } + if( !Sys_CheckParm( "-noch" ) ) Sys_SetupCrashHandler();