/* -help */
if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
|| !strcmp( argv[ i ], "-help" ) ) {
- HelpMain(argv[i+1]);
+ HelpMain( ( i + 1 < argc ) ? argv[ i + 1 ] : NULL );
return 0;
}
/* -connect */
if ( !strcmp( argv[ i ], "-connect" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No address specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
Broadcast_Setup( argv[ i ] );
argv[ i ] = NULL;
}
/* patch subdivisions */
else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
patchSubdivisions = atoi( argv[ i ] );
argv[ i ] = NULL;
if ( patchSubdivisions <= 0 ) {
/* threads */
else if ( !strcmp( argv[ i ], "-threads" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
numthreads = atoi( argv[ i ] );
argv[ i ] = NULL;
}
/* -game */
if ( strcmp( argv[ i ], "-game" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No game specified after %s", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_forbiddenpath */
else if ( strcmp( argv[ i ], "-fs_forbiddenpath" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_basepath */
else if ( strcmp( argv[ i ], "-fs_basepath" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_game */
else if ( strcmp( argv[ i ], "-fs_game" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_home */
else if ( strcmp( argv[ i ], "-fs_home" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_homebase */
else if ( strcmp( argv[ i ], "-fs_homebase" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_homepath - sets both of them */
else if ( strcmp( argv[ i ], "-fs_homepath" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;
/* -fs_pakpath */
else if ( strcmp( argv[ i ], "-fs_pakpath" ) == 0 ) {
- if ( ++i >= *argc ) {
+ if ( ++i >= *argc || !argv[ i ] ) {
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
}
argv[ i - 1 ] = NULL;