----------------------------------------------------------------------------- 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. ----------------
| 77 | // appname: Keyname for the commandline arguments to be loaded - typically the exe name. |
| 78 | //----------------------------------------------------------------------------- |
| 79 | void 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 |
no test coverage detected