MCPcopy Create free account
hub / github.com/BSVino/DoubleAction / LoadCmdLineFromFile

Function LoadCmdLineFromFile

mp/src/public/loadcmdline.cpp:79–107  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: Loads additional commandline arguments from a config file for an app. Filesystem must be initialized before calling this function. keyname: Name of the block containing the key/args pairs (ie map or model name) appname: Keyname for the commandline arguments to be loaded - typically the exe name. ----------------

Source from the content-addressed store, hash-verified

77// appname: Keyname for the commandline arguments to be loaded - typically the exe name.
78//-----------------------------------------------------------------------------
79void LoadCmdLineFromFile( int &argc, char **&argv, const char *keyname, const char *appname )
80{
81 sFoundConfigArgs = false;
82
83 assert( g_pFileSystem );
84 if( !g_pFileSystem )
85 return;
86
87 // Load the cfg file, and find the keyname
88 KeyValues *kv = new KeyValues( "CommandLine" );
89
90 char filename[512];
91 Q_snprintf( filename, sizeof( filename ), "%s/cfg/commandline.cfg", gamedir );
92
93 if ( kv->LoadFromFile( g_pFileSystem, filename ) )
94 {
95 // Load the commandline arguments for this app
96 KeyValues *appKey = kv->FindKey( keyname );
97 if( appKey )
98 {
99 const char *str = appKey->GetString( appname );
100 Msg( "Command Line found: %s\n", str );
101
102 AddArguments( argc, argv, str );
103 }
104 }
105
106 kv->deleteThis();
107}
108
109//-----------------------------------------------------------------------------
110// Purpose: Cleans up any memory allocated for the new argv. Pass in the app's

Callers 3

VRAD_MainFunction · 0.85
RunVBSPFunction · 0.85
RunVVisFunction · 0.85

Calls 6

MsgFunction · 0.85
AddArgumentsFunction · 0.85
LoadFromFileMethod · 0.45
FindKeyMethod · 0.45
GetStringMethod · 0.45
deleteThisMethod · 0.45

Tested by

no test coverage detected