From: cloudwalk Date: Tue, 8 Sep 2020 13:19:25 +0000 (+0000) Subject: Rename COM_CheckParm to Sys_CheckParm and move it to sys_shared.c X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ca9ce4420b332de3fa6f2d6beaa437f171ab97c;p=xonotic%2Fdarkplaces.git Rename COM_CheckParm to Sys_CheckParm and move it to sys_shared.c git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12912 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cd_shared.c b/cd_shared.c index 3eee8510..8c4566c4 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -549,7 +549,7 @@ int CDAudio_Init (void) return -1; // COMMANDLINEOPTION: Sound: -nocdaudio disables CD audio support - if (COM_CheckParm("-nocdaudio")) + if (Sys_CheckParm("-nocdaudio")) return -1; #ifdef MAXTRACKS @@ -577,7 +577,7 @@ int CDAudio_Init (void) int CDAudio_Startup (void) { - if (COM_CheckParm("-nocdaudio")) + if (Sys_CheckParm("-nocdaudio")) return -1; initialized = true; diff --git a/cl_demo.c b/cl_demo.c index 31a1f470..bc8fd7e9 100644 --- a/cl_demo.c +++ b/cl_demo.c @@ -97,7 +97,7 @@ void CL_StopPlayback (void) CL_FinishTimeDemo (); if (!cls.demostarting) // only quit if not starting another demo - if (COM_CheckParm("-demo") || COM_CheckParm("-capturedemo")) + if (Sys_CheckParm("-demo") || Sys_CheckParm("-capturedemo")) Host_Quit_f(&cmd_client); } @@ -510,10 +510,10 @@ static void CL_FinishTimeDemo (void) // LadyHavoc: timedemo now prints out 7 digits of fraction, and min/avg/max Con_Printf("%i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); Log_Printf("benchmark.log", "date %s | enginedate %s | demo %s | commandline %s | run %d | result %i frames %5.7f seconds %5.7f fps, one-second fps min/avg/max: %.0f %.0f %.0f (%i seconds)\n", Sys_TimeString("%Y-%m-%d %H:%M:%S"), buildstring, cls.demoname, cmdline.string, benchmark_runs + 1, frames, time, totalfpsavg, fpsmin, fpsavg, fpsmax, cls.td_onesecondavgcount); - if (COM_CheckParm("-benchmark")) + if (Sys_CheckParm("-benchmark")) { ++benchmark_runs; - i = COM_CheckParm("-benchmarkruns"); + i = Sys_CheckParm("-benchmarkruns"); if(i && i + 1 < sys.argc) { static benchmarkhistory_t *history = NULL; @@ -536,7 +536,7 @@ static void CL_FinishTimeDemo (void) else { // print statistics - int first = COM_CheckParm("-benchmarkruns_skipfirst") ? 1 : 0; + int first = Sys_CheckParm("-benchmarkruns_skipfirst") ? 1 : 0; if(benchmark_runs > first) { #define DO_MIN(f) \ @@ -637,7 +637,7 @@ static void CL_Startdemos_f(cmd_state_t *cmd) { int i, c; - if (cls.state == ca_dedicated || COM_CheckParm("-listen") || COM_CheckParm("-benchmark") || COM_CheckParm("-demo") || COM_CheckParm("-capturedemo")) + if (cls.state == ca_dedicated || Sys_CheckParm("-listen") || Sys_CheckParm("-benchmark") || Sys_CheckParm("-demo") || Sys_CheckParm("-capturedemo")) return; c = Cmd_Argc(cmd) - 1; diff --git a/cl_main.c b/cl_main.c index de454ffe..73fb6986 100644 --- a/cl_main.c +++ b/cl_main.c @@ -355,7 +355,7 @@ void CL_Disconnect(void) if (cls.state == ca_dedicated) return; - if (COM_CheckParm("-profilegameonly")) + if (Sys_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); Curl_Clear_forthismap(); @@ -521,7 +521,7 @@ void CL_EstablishConnection(const char *address, int firstarg) return; // don't connect to a server if we're benchmarking a demo - if (COM_CheckParm("-benchmark")) + if (Sys_CheckParm("-benchmark")) return; // clear menu's connect error message diff --git a/cl_parse.c b/cl_parse.c index 45a2b989..bc79dd0f 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -1657,7 +1657,7 @@ static void CL_SignonReply (void) S_PurgeUnused(); Con_ClearNotify(); - if (COM_CheckParm("-profilegameonly")) + if (Sys_CheckParm("-profilegameonly")) Sys_AllowProfiling(true); break; } diff --git a/cl_screen.c b/cl_screen.c index 67a9609d..8238ff62 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1368,7 +1368,7 @@ void CL_Screen_Init(void) Cvar_RegisterVariable(&r_speeds_graph_maxdefault); // if we want no console, turn it off here too - if (COM_CheckParm ("-noconsole")) + if (Sys_CheckParm ("-noconsole")) Cvar_SetQuick(&scr_conforcewhiledisconnected, "0"); Cmd_AddCommand(CMD_CLIENT, "sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)"); diff --git a/cl_video.c b/cl_video.c index e9d5e21b..db97d1cd 100644 --- a/cl_video.c +++ b/cl_video.c @@ -617,7 +617,7 @@ static void CL_PlayVideo_f(cmd_state_t *cmd) Host_StartVideo(); - if (COM_CheckParm("-benchmark")) + if (Sys_CheckParm("-benchmark")) return; if (Cmd_Argc(cmd) < 2) diff --git a/cl_video_libavw.c b/cl_video_libavw.c index abdc2e2c..c3662213 100644 --- a/cl_video_libavw.c +++ b/cl_video_libavw.c @@ -360,7 +360,7 @@ qboolean LibAvW_OpenLibrary(void) int errorcode; // COMMANDLINEOPTION: Video: -nolibavw disables libavcodec wrapper support - if (COM_CheckParm("-nolibavw")) + if (Sys_CheckParm("-nolibavw")) return false; // load DLL's diff --git a/cmd.c b/cmd.c index a62d05a8..bc0f465d 100644 --- a/cmd.c +++ b/cmd.c @@ -576,7 +576,7 @@ static void Cmd_Exec(cmd_state_t *cmd, const char *filename) if (!strcmp(filename, "config.cfg")) { filename = CONFIGFILENAME; - if (COM_CheckParm("-noconfig")) + if (Sys_CheckParm("-noconfig")) return; // don't execute config.cfg } diff --git a/com_game.c b/com_game.c index a40f5c40..29446b9c 100644 --- a/com_game.c +++ b/com_game.c @@ -109,7 +109,7 @@ void COM_InitGameType (void) // check commandline options for keywords for (i = 0;i < (int)(sizeof (gamemode_info) / sizeof (gamemode_info[0]));i++) - if (COM_CheckParm (gamemode_info[i].cmdline)) + if (Sys_CheckParm (gamemode_info[i].cmdline)) index = i; com_startupgamemode = gamemode_info[index].mode; @@ -164,17 +164,17 @@ static void COM_SetGameType(int index) if (gamemode == com_startupgamemode) { - if((t = COM_CheckParm("-customgamename")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgamename")) && t + 1 < sys.argc) gamename = gamenetworkfiltername = sys.argv[t+1]; - if((t = COM_CheckParm("-customgamenetworkfiltername")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgamenetworkfiltername")) && t + 1 < sys.argc) gamenetworkfiltername = sys.argv[t+1]; - if((t = COM_CheckParm("-customgamedirname1")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgamedirname1")) && t + 1 < sys.argc) gamedirname1 = sys.argv[t+1]; - if((t = COM_CheckParm("-customgamedirname2")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgamedirname2")) && t + 1 < sys.argc) gamedirname2 = *sys.argv[t+1] ? sys.argv[t+1] : NULL; - if((t = COM_CheckParm("-customgamescreenshotname")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgamescreenshotname")) && t + 1 < sys.argc) gamescreenshotname = sys.argv[t+1]; - if((t = COM_CheckParm("-customgameuserdirname")) && t + 1 < sys.argc) + if((t = Sys_CheckParm("-customgameuserdirname")) && t + 1 < sys.argc) gameuserdirname = sys.argv[t+1]; } diff --git a/common.c b/common.c index 03b7087e..72713840 100644 --- a/common.c +++ b/common.c @@ -860,30 +860,6 @@ skipwhite: return true; } - -/* -================ -COM_CheckParm - -Returns the position (1 to argc-1) in the program's argument list -where the given parameter apears, or 0 if not present -================ -*/ -int COM_CheckParm (const char *parm) -{ - int i; - - for (i=1 ; i // Overrides the system supplied base directory (under GAMENAME) // COMMANDLINEOPTION: Filesystem: -basedir chooses what base directory the game data is in, inside this there should be a data directory for the game (for example id1) - i = COM_CheckParm ("-basedir"); + i = Sys_CheckParm ("-basedir"); if (i && i < sys.argc-1) { strlcpy (fs_basedir, sys.argv[i+1], sizeof (fs_basedir)); @@ -2041,9 +2041,9 @@ static void FS_Init_Dir (void) strlcat(fs_basedir, "/", sizeof(fs_basedir)); // Add the personal game directory - if((i = COM_CheckParm("-userdir")) && i < sys.argc - 1) + if((i = Sys_CheckParm("-userdir")) && i < sys.argc - 1) dpsnprintf(fs_userdir, sizeof(fs_userdir), "%s/", sys.argv[i+1]); - else if (COM_CheckParm("-nohome")) + else if (Sys_CheckParm("-nohome")) *fs_userdir = 0; // user wants roaming installation, no userdir else { @@ -2060,9 +2060,9 @@ static void FS_Init_Dir (void) preferreduserdirmode = USERDIRMODE_NOHOME; # endif // check what limitations the user wants to impose - if (COM_CheckParm("-home")) preferreduserdirmode = USERDIRMODE_HOME; - if (COM_CheckParm("-mygames")) preferreduserdirmode = USERDIRMODE_MYGAMES; - if (COM_CheckParm("-savedgames")) preferreduserdirmode = USERDIRMODE_SAVEDGAMES; + if (Sys_CheckParm("-home")) preferreduserdirmode = USERDIRMODE_HOME; + if (Sys_CheckParm("-mygames")) preferreduserdirmode = USERDIRMODE_MYGAMES; + if (Sys_CheckParm("-savedgames")) preferreduserdirmode = USERDIRMODE_SAVEDGAMES; // gather the status of the possible userdirs for (dirmode = 0;dirmode < USERDIRMODE_COUNT;dirmode++) { @@ -2148,7 +2148,7 @@ void FS_Init_SelfPack (void) char *buf; // Load darkplaces.opt from the FS. - if (!COM_CheckParm("-noopt")) + if (!Sys_CheckParm("-noopt")) { buf = (char *) FS_SysLoadFile("darkplaces.opt", tempmempool, true, NULL); if(buf) @@ -2160,13 +2160,13 @@ void FS_Init_SelfPack (void) #ifndef USE_RWOPS // Provide the SelfPack. - if (!COM_CheckParm("-noselfpack") && sys.selffd >= 0) + if (!Sys_CheckParm("-noselfpack") && sys.selffd >= 0) { fs_selfpack = FS_LoadPackPK3FromFD(sys.argv[0], sys.selffd, true); if(fs_selfpack) { FS_AddSelfPack(); - if (!COM_CheckParm("-noopt")) + if (!Sys_CheckParm("-noopt")) { buf = (char *) FS_LoadFile("darkplaces.opt", tempmempool, true, NULL); if(buf) @@ -2275,7 +2275,7 @@ static filedesc_t FS_SysOpenFiledesc(const char *filepath, const char *mode, qbo if (nonblocking) opt |= O_NONBLOCK; - if(COM_CheckParm("-readonly") && mod != O_RDONLY) + if(Sys_CheckParm("-readonly") && mod != O_RDONLY) return FILEDESC_INVALID; #if USE_RWOPS diff --git a/host.c b/host.c index 793fd0eb..55b0c5f3 100644 --- a/host.c +++ b/host.c @@ -160,14 +160,14 @@ static void Host_ServerOptions (void) // COMMANDLINEOPTION: Server: -listen [playerlimit] starts a multiplayer server with graphical client, like singleplayer but other players can connect, default playerlimit is 8 // if no client is in the executable or -dedicated is specified on // commandline, start a dedicated server - i = COM_CheckParm ("-dedicated"); + i = Sys_CheckParm ("-dedicated"); if (i || !cl_available) { cls.state = ca_dedicated; // check for -dedicated specifying how many players if (i && i + 1 < sys.argc && atoi (sys.argv[i+1]) >= 1) svs.maxclients = atoi (sys.argv[i+1]); - if (COM_CheckParm ("-listen")) + if (Sys_CheckParm ("-listen")) Con_Printf ("Only one of -dedicated or -listen can be specified\n"); // default sv_public on for dedicated servers (often hosted by serious administrators), off for listen servers (often hosted by clueless users) Cvar_SetValue(&cvars_all, "sv_public", 1); @@ -176,7 +176,7 @@ static void Host_ServerOptions (void) { // client exists and not dedicated, check if -listen is specified cls.state = ca_disconnected; - i = COM_CheckParm ("-listen"); + i = Sys_CheckParm ("-listen"); if (i) { // default players unless specified @@ -273,7 +273,7 @@ static void Host_SaveConfig_to(const char *file) // dedicated servers initialize the host but don't parse and set the // config.cfg cvars // LadyHavoc: don't save a config if it crashed in startup - if (host.framecount >= 3 && cls.state != ca_dedicated && !COM_CheckParm("-benchmark") && !COM_CheckParm("-capturedemo")) + if (host.framecount >= 3 && cls.state != ca_dedicated && !Sys_CheckParm("-benchmark") && !Sys_CheckParm("-capturedemo")) { f = FS_OpenRealFile(file, "wb", false); if (!f) @@ -549,7 +549,7 @@ static void Host_InitSession(void) Cvar_RegisterVariable(&locksession); // load the session ID into the read-only cvar - if ((i = COM_CheckParm("-sessionid")) && (i + 1 < sys.argc)) + if ((i = Sys_CheckParm("-sessionid")) && (i + 1 < sys.argc)) { if(sys.argv[i+1][0] == '.') Cvar_SetQuick(&sessionid, sys.argv[i+1]); @@ -566,7 +566,7 @@ void Host_LockSession(void) if(locksession_run) return; locksession_run = true; - if(locksession.integer != 0 && !COM_CheckParm("-readonly")) + if(locksession.integer != 0 && !Sys_CheckParm("-readonly")) { char vabuf[1024]; char *p = va(vabuf, sizeof(vabuf), "%slock%s", *fs_userdir ? fs_userdir : fs_basedir, sessionid.string); @@ -616,11 +616,11 @@ static void Host_Init (void) host.state = host_init; - if (COM_CheckParm("-profilegameonly")) + if (Sys_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); // LadyHavoc: quake never seeded the random number generator before... heh - if (COM_CheckParm("-benchmark")) + if (Sys_CheckParm("-benchmark")) srand(0); // predictable random sequence for -benchmark else srand((unsigned int)time(NULL)); @@ -629,13 +629,13 @@ static void Host_Init (void) // LadyHavoc: doesn't seem very temporary... // LadyHavoc: made this a saved cvar // COMMANDLINEOPTION: Console: -developer enables warnings and other notices (RECOMMENDED for mod developers) - if (COM_CheckParm("-developer")) + if (Sys_CheckParm("-developer")) { developer.value = developer.integer = 1; developer.string = "1"; } - if (COM_CheckParm("-developer2") || COM_CheckParm("-developer3")) + if (Sys_CheckParm("-developer2") || Sys_CheckParm("-developer3")) { developer.value = developer.integer = 1; developer.string = "1"; @@ -649,14 +649,14 @@ static void Host_Init (void) developer_memorydebug.string = "1"; } - if (COM_CheckParm("-developer3")) + if (Sys_CheckParm("-developer3")) { gl_paranoid.integer = 1;gl_paranoid.string = "1"; gl_printcheckerror.integer = 1;gl_printcheckerror.string = "1"; } // COMMANDLINEOPTION: Console: -nostdout disables text output to the terminal the game was launched from - if (COM_CheckParm("-nostdout")) + if (Sys_CheckParm("-nostdout")) sys_nostdout = 1; // initialize console command/cvar/alias/command execution systems @@ -745,7 +745,7 @@ static void Host_Init (void) // check for special benchmark mode // COMMANDLINEOPTION: Client: -benchmark runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log) - i = COM_CheckParm("-benchmark"); + i = Sys_CheckParm("-benchmark"); if (i && i + 1 < sys.argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { @@ -755,7 +755,7 @@ static void Host_Init (void) // check for special demo mode // COMMANDLINEOPTION: Client: -demo runs a playdemo and quits - i = COM_CheckParm("-demo"); + i = Sys_CheckParm("-demo"); if (i && i + 1 < sys.argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { @@ -765,7 +765,7 @@ static void Host_Init (void) #ifdef CONFIG_VIDEO_CAPTURE // COMMANDLINEOPTION: Client: -capturedemo captures a playdemo and quits - i = COM_CheckParm("-capturedemo"); + i = Sys_CheckParm("-capturedemo"); if (i && i + 1 < sys.argc) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { @@ -774,7 +774,7 @@ static void Host_Init (void) } #endif - if (cls.state == ca_dedicated || COM_CheckParm("-listen")) + if (cls.state == ca_dedicated || Sys_CheckParm("-listen")) if (!sv.active && !cls.demoplayback && !cls.connect_trying) { Cbuf_AddText(&cmd_client, "startmap_dm\n"); diff --git a/keys.c b/keys.c index 5a67502f..cceec519 100644 --- a/keys.c +++ b/keys.c @@ -1996,7 +1996,7 @@ Key_Event (int key, int ascii, qboolean down) return; } - if (COM_CheckParm ("-noconsole")) + if (Sys_CheckParm ("-noconsole")) return; // only allow the key bind to turn off console Key_Console (cmd, key, ascii); diff --git a/menu.c b/menu.c index 6308f480..6c4830d0 100644 --- a/menu.c +++ b/menu.c @@ -5620,12 +5620,12 @@ void MR_Init(void) // use -forceqmenu to use always the normal quake menu (it sets forceqmenu to 1) // COMMANDLINEOPTION: Client: -forceqmenu disables menu.dat (same as +forceqmenu 1) - if(COM_CheckParm("-forceqmenu")) + if(Sys_CheckParm("-forceqmenu")) Cvar_SetValueQuick(&forceqmenu,1); // use -useqmenu for debugging proposes, cause it starts // the normal quake menu only the first time // COMMANDLINEOPTION: Client: -useqmenu causes the first time you open the menu to use the quake menu, then reverts to menu.dat (if forceqmenu is 0) - if(COM_CheckParm("-useqmenu")) + if(Sys_CheckParm("-useqmenu")) MR_SetRouting (true); else MR_SetRouting (false); diff --git a/netconn.c b/netconn.c index 867c6162..b53877d7 100755 --- a/netconn.c +++ b/netconn.c @@ -3921,7 +3921,7 @@ void NetConn_Init(void) Cvar_RegisterVariable(&gameversion_min); Cvar_RegisterVariable(&gameversion_max); // COMMANDLINEOPTION: Server: -ip sets the ip address of this machine for purposes of networking (default 0.0.0.0 also known as INADDR_ANY), use only if you have multiple network adapters and need to choose one specifically. - if ((i = COM_CheckParm("-ip")) && i + 1 < sys.argc) + if ((i = Sys_CheckParm("-ip")) && i + 1 < sys.argc) { if (LHNETADDRESS_FromString(&tempaddress, sys.argv[i + 1], 0) == 1) { @@ -3932,7 +3932,7 @@ void NetConn_Init(void) Con_Printf(CON_ERROR "-ip option used, but unable to parse the address \"%s\"\n", sys.argv[i + 1]); } // COMMANDLINEOPTION: Server: -port sets the port to use for a server (default 26000, the same port as QUAKE itself), useful if you host multiple servers on your machine - if (((i = COM_CheckParm("-port")) || (i = COM_CheckParm("-ipport")) || (i = COM_CheckParm("-udpport"))) && i + 1 < sys.argc) + if (((i = Sys_CheckParm("-port")) || (i = Sys_CheckParm("-ipport")) || (i = Sys_CheckParm("-udpport"))) && i + 1 < sys.argc) { i = atoi(sys.argv[i + 1]); if (i >= 0 && i < 65536) diff --git a/palette.c b/palette.c index 5b874342..9e348b19 100644 --- a/palette.c +++ b/palette.c @@ -281,15 +281,15 @@ static void Palette_Load(void) scale = 1; base = 0; // COMMANDLINEOPTION: Client: -texgamma sets the quake palette gamma, allowing you to make quake textures brighter/darker, not recommended - i = COM_CheckParm("-texgamma"); + i = Sys_CheckParm("-texgamma"); if (i) gamma = atof(sys.argv[i + 1]); // COMMANDLINEOPTION: Client: -texcontrast sets the quake palette contrast, allowing you to make quake textures brighter/darker, not recommended - i = COM_CheckParm("-texcontrast"); + i = Sys_CheckParm("-texcontrast"); if (i) scale = atof(sys.argv[i + 1]); // COMMANDLINEOPTION: Client: -texbrightness sets the quake palette brightness (brightness of black), allowing you to make quake textures brighter/darker, not recommended - i = COM_CheckParm("-texbrightness"); + i = Sys_CheckParm("-texbrightness"); if (i) base = atof(sys.argv[i + 1]); gamma = bound(0.01, gamma, 10.0); diff --git a/prvm_edict.c b/prvm_edict.c index 8b3a645e..cccc66df 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -3179,7 +3179,7 @@ void PRVM_Init (void) Cvar_RegisterVariable (&prvm_stringdebug); // COMMANDLINEOPTION: PRVM: -norunaway disables the runaway loop check (it might be impossible to exit DarkPlaces if used!) - prvm_runawaycheck = !COM_CheckParm("-norunaway"); + prvm_runawaycheck = !Sys_CheckParm("-norunaway"); //VM_Cmd_Init(); } diff --git a/snd_main.c b/snd_main.c index 33c3a08b..c76e503d 100644 --- a/snd_main.c +++ b/snd_main.c @@ -530,28 +530,28 @@ void S_Startup (void) // Parse the command line to see if the player wants a particular sound format // COMMANDLINEOPTION: Sound: -sndquad sets sound output to 4 channel surround - if (COM_CheckParm ("-sndquad") != 0) + if (Sys_CheckParm ("-sndquad") != 0) { chosen_fmt.channels = 4; } // COMMANDLINEOPTION: Sound: -sndstereo sets sound output to stereo - else if (COM_CheckParm ("-sndstereo") != 0) + else if (Sys_CheckParm ("-sndstereo") != 0) { chosen_fmt.channels = 2; } // COMMANDLINEOPTION: Sound: -sndmono sets sound output to mono - else if (COM_CheckParm ("-sndmono") != 0) + else if (Sys_CheckParm ("-sndmono") != 0) { chosen_fmt.channels = 1; } // COMMANDLINEOPTION: Sound: -sndspeed chooses sound output rate (supported values are 48000, 44100, 32000, 24000, 22050, 16000, 11025 (quake), 8000) - i = COM_CheckParm ("-sndspeed"); + i = Sys_CheckParm ("-sndspeed"); if (0 < i && i < sys.argc - 1) { chosen_fmt.speed = atoi (sys.argv[i + 1]); } // COMMANDLINEOPTION: Sound: -sndbits chooses 8 bit or 16 bit or 32bit float sound output - i = COM_CheckParm ("-sndbits"); + i = Sys_CheckParm ("-sndbits"); if (0 < i && i < sys.argc - 1) { chosen_fmt.width = atoi (sys.argv[i + 1]) / 8; @@ -775,7 +775,7 @@ void S_Init(void) Cvar_RegisterVariable(&snd_identicalsoundrandomization_tics); // COMMANDLINEOPTION: Sound: -nosound disables sound (including CD audio) - if (COM_CheckParm("-nosound")) + if (Sys_CheckParm("-nosound")) { // dummy out Play and Play2 because mods stuffcmd that Cmd_AddCommand(CMD_CLIENT, "play", Host_NoOperation_f, "does nothing because -nosound was specified"); @@ -786,7 +786,7 @@ void S_Init(void) snd_mempool = Mem_AllocPool("sound", 0, NULL); // COMMANDLINEOPTION: Sound: -simsound runs sound mixing but with no output - if (COM_CheckParm("-simsound")) + if (Sys_CheckParm("-simsound")) simsound = true; Cmd_AddCommand(CMD_CLIENT, "play", S_Play_f, "play a sound at your current location (not heard by anyone else)"); diff --git a/snd_ogg.c b/snd_ogg.c index 2a1cb148..d91b8232 100644 --- a/snd_ogg.c +++ b/snd_ogg.c @@ -305,7 +305,7 @@ qboolean OGG_OpenLibrary (void) return true; // COMMANDLINEOPTION: Sound: -novorbis disables ogg vorbis sound support - if (COM_CheckParm("-novorbis")) + if (Sys_CheckParm("-novorbis")) return false; // Load the DLLs diff --git a/snd_xmp.c b/snd_xmp.c index e963e18e..2985112b 100644 --- a/snd_xmp.c +++ b/snd_xmp.c @@ -366,7 +366,7 @@ qboolean XMP_OpenLibrary (void) return true; // COMMANDLINEOPTION: Sound: -noxmp disables xmp module sound support - if (COM_CheckParm("-noxmp")) + if (Sys_CheckParm("-noxmp")) return false; // Load the DLL @@ -606,7 +606,7 @@ qboolean XMP_LoadModFile(const char *filename, sfx_t *sfx) #endif // COMMANDLINEOPTION: Sound: -noxmp disables xmp module sound support - if (COM_CheckParm("-noxmp")) + if (Sys_CheckParm("-noxmp")) return false; // Return if already loaded diff --git a/sys.h b/sys.h index ee3b7773..1dd5ae76 100644 --- a/sys.h +++ b/sys.h @@ -67,6 +67,8 @@ qboolean Sys_LoadLibrary (const char** dllnames, dllhandle_t* handle, const dllf void Sys_UnloadLibrary (dllhandle_t* handle); void* Sys_GetProcAddress (dllhandle_t handle, const char* name); +int Sys_CheckParm (const char *parm); + /// called early in Host_Init void Sys_InitConsole (void); /// called after command system is initialized but before first Con_Print diff --git a/sys_sdl.c b/sys_sdl.c index 50186991..3adfb980 100644 --- a/sys_sdl.c +++ b/sys_sdl.c @@ -202,13 +202,13 @@ int main (int argc, char *argv[]) Sys_ProvideSelfFD(); // COMMANDLINEOPTION: -nocrashdialog disables "Engine Error" crash dialog boxes - if(!COM_CheckParm("-nocrashdialog")) + if(!Sys_CheckParm("-nocrashdialog")) nocrashdialog = false; // COMMANDLINEOPTION: sdl: -noterminal disables console output on stdout - if(COM_CheckParm("-noterminal")) + if(Sys_CheckParm("-noterminal")) sys.outfd = -1; // COMMANDLINEOPTION: sdl: -stderr moves console output to stderr - else if(COM_CheckParm("-stderr")) + else if(Sys_CheckParm("-stderr")) sys.outfd = 2; else sys.outfd = 1; diff --git a/sys_shared.c b/sys_shared.c index 468037be..b7ea5d5a 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -55,7 +55,7 @@ void Sys_Quit (int returnvalue) SV_UnlockThreadMutex(); TaskQueue_Frame(true); - if (COM_CheckParm("-profilegameonly")) + if (Sys_CheckParm("-profilegameonly")) Sys_AllowProfiling(false); host.state = host_shutdown; Host_Shutdown(); @@ -283,6 +283,29 @@ static cvar_t sys_useclockgettime = {CVAR_CLIENT | CVAR_SERVER | CVAR_SAVE, "sys static double benchmark_time; // actually always contains an integer amount of milliseconds, will eventually "overflow" +/* +================ +Sys_CheckParm + +Returns the position (1 to argc-1) in the program's argument list +where the given parameter apears, or 0 if not present +================ +*/ +int Sys_CheckParm (const char *parm) +{ + int i; + + for (i=1 ; i 0) + if ((t = Sys_CheckParm ("-HFILE")) > 0) { if (t < sys.argc) hFile = (HANDLE)atoi (sys.argv[t+1]); } - if ((t = COM_CheckParm ("-HPARENT")) > 0) + if ((t = Sys_CheckParm ("-HPARENT")) > 0) { if (t < sys.argc) heventParent = (HANDLE)atoi (sys.argv[t+1]); } - if ((t = COM_CheckParm ("-HCHILD")) > 0) + if ((t = Sys_CheckParm ("-HCHILD")) > 0) { if (t < sys.argc) heventChild = (HANDLE)atoi (sys.argv[t+1]); diff --git a/vid_sdl.c b/vid_sdl.c index 9b258079..de693c42 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -1493,7 +1493,7 @@ static qboolean VID_InitModeGL(viddef_mode_t *mode) drivername = NULL; // COMMANDLINEOPTION: SDL GL: -gl_driver selects a GL driver library, default is whatever SDL recommends, useful only for 3dfxogl.dll/3dfxvgl.dll or fxmesa or similar, if you don't know what this is for, you don't need it - i = COM_CheckParm("-gl_driver"); + i = Sys_CheckParm("-gl_driver"); if (i && i < sys.argc - 1) drivername = sys.argv[i + 1]; if (SDL_GL_LoadLibrary(drivername) < 0) diff --git a/vid_shared.c b/vid_shared.c index 0e523ed5..661fb0a6 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -643,7 +643,7 @@ qboolean GL_CheckExtension(const char *name, const char *disableparm, int silent Con_DPrintf("checking for %s... ", name); - if (disableparm && (COM_CheckParm(disableparm) || COM_CheckParm("-safe"))) + if (disableparm && (Sys_CheckParm(disableparm) || Sys_CheckParm("-safe"))) { Con_DPrint("disabled by commandline\n"); return false; @@ -1511,24 +1511,24 @@ void VID_Start(void) // interpret command-line parameters vid_commandlinecheck = false; // COMMANDLINEOPTION: Video: -window performs +vid_fullscreen 0 - if (COM_CheckParm("-window") || COM_CheckParm("-safe") || ((i = COM_CheckParm("+vid_fullscreen")) != 0 && atoi(sys.argv[i+1]) == 0)) + if (Sys_CheckParm("-window") || Sys_CheckParm("-safe") || ((i = Sys_CheckParm("+vid_fullscreen")) != 0 && atoi(sys.argv[i+1]) == 0)) Cvar_SetValueQuick(&vid_fullscreen, false); // COMMANDLINEOPTION: Video: -borderless performs +vid_borderless 1 - if (COM_CheckParm("-borderless") || ((i = COM_CheckParm("+vid_borderless")) != 0 && atoi(sys.argv[i+1]) == 1)) + if (Sys_CheckParm("-borderless") || ((i = Sys_CheckParm("+vid_borderless")) != 0 && atoi(sys.argv[i+1]) == 1)) { Cvar_SetValueQuick(&vid_borderless, true); Cvar_SetValueQuick(&vid_fullscreen, false); } // COMMANDLINEOPTION: Video: -fullscreen performs +vid_fullscreen 1 - if (COM_CheckParm("-fullscreen") || ((i = COM_CheckParm("+vid_fullscreen")) != 0 && atoi(sys.argv[i+1]) == 1)) + if (Sys_CheckParm("-fullscreen") || ((i = Sys_CheckParm("+vid_fullscreen")) != 0 && atoi(sys.argv[i+1]) == 1)) Cvar_SetValueQuick(&vid_fullscreen, true); width = 0; height = 0; // COMMANDLINEOPTION: Video: -width performs +vid_width and also +vid_height if only -width is specified (example: -width 1024 sets 1024x768 mode) - if ((i = COM_CheckParm("-width")) != 0 || ((i = COM_CheckParm("+vid_width")) != 0)) + if ((i = Sys_CheckParm("-width")) != 0 || ((i = Sys_CheckParm("+vid_width")) != 0)) width = atoi(sys.argv[i+1]); // COMMANDLINEOPTION: Video: -height performs +vid_height and also +vid_width if only -height is specified (example: -height 768 sets 1024x768 mode) - if ((i = COM_CheckParm("-height")) != 0 || ((i = COM_CheckParm("+vid_height")) != 0)) + if ((i = Sys_CheckParm("-height")) != 0 || ((i = Sys_CheckParm("+vid_height")) != 0)) height = atoi(sys.argv[i+1]); if (width == 0) width = height * 4 / 3; @@ -1539,13 +1539,13 @@ void VID_Start(void) if (height) Cvar_SetValueQuick(&vid_height, height); // COMMANDLINEOPTION: Video: -density performs +vid_touchscreen_density (example -density 1 or -density 1.5) - if ((i = COM_CheckParm("-density")) != 0) + if ((i = Sys_CheckParm("-density")) != 0) Cvar_SetQuick(&vid_touchscreen_density, sys.argv[i+1]); // COMMANDLINEOPTION: Video: -xdpi performs +vid_touchscreen_xdpi (example -xdpi 160 or -xdpi 320) - if ((i = COM_CheckParm("-touchscreen_xdpi")) != 0) + if ((i = Sys_CheckParm("-touchscreen_xdpi")) != 0) Cvar_SetQuick(&vid_touchscreen_xdpi, sys.argv[i+1]); // COMMANDLINEOPTION: Video: -ydpi performs +vid_touchscreen_ydpi (example -ydpi 160 or -ydpi 320) - if ((i = COM_CheckParm("-touchscreen_ydpi")) != 0) + if ((i = Sys_CheckParm("-touchscreen_ydpi")) != 0) Cvar_SetQuick(&vid_touchscreen_ydpi, sys.argv[i+1]); }