2008-07-25 07:31:37 +00:00
|
|
|
/* -------------------------------------------------------------------------------
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
----------------------------------------------------------------------------------
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This code has been altered significantly from its original form, to support
|
|
|
|
several games based on the Quake III Arena engine, in the form of "Q3Map2."
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
------------------------------------------------------------------------------- */
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* marker */
|
|
|
|
#define PATH_INIT_C
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* dependencies */
|
|
|
|
#include "q3map2.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* path support */
|
2012-03-17 20:01:54 +00:00
|
|
|
#define MAX_BASE_PATHS 10
|
|
|
|
#define MAX_GAME_PATHS 10
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char *homePath;
|
|
|
|
char installPath[ MAX_OS_PATH ];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
int numBasePaths;
|
|
|
|
char *basePaths[ MAX_BASE_PATHS ];
|
|
|
|
int numGamePaths;
|
|
|
|
char *gamePaths[ MAX_GAME_PATHS ];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
some of this code is based off the original q3map port from loki
|
|
|
|
and finds various paths. moved here from bsp.c for clarity.
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
PathLokiGetHomeDir()
|
|
|
|
gets the user's home dir (for ~/.q3a)
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char *LokiGetHomeDir( void ){
|
2007-11-04 03:34:51 +00:00
|
|
|
#ifndef Q_UNIX
|
2012-03-17 20:01:54 +00:00
|
|
|
return NULL;
|
2007-11-04 03:34:51 +00:00
|
|
|
#else
|
2012-03-17 23:26:28 +00:00
|
|
|
static char buf[ 4096 ];
|
|
|
|
struct passwd pw, *pwp;
|
2012-03-17 20:01:54 +00:00
|
|
|
char *home;
|
|
|
|
|
|
|
|
|
|
|
|
/* get the home environment variable */
|
|
|
|
home = getenv( "HOME" );
|
2012-03-17 23:26:28 +00:00
|
|
|
if ( home ) {
|
|
|
|
return Q_strncpyz( buf, home, sizeof( buf ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* look up home dir in password database */
|
|
|
|
if ( getpwuid_r( getuid(), &pw, buf, sizeof( buf ), &pwp ) == 0 ) {
|
|
|
|
return pw.pw_dir;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 23:26:28 +00:00
|
|
|
return NULL;
|
2007-11-04 03:34:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
PathLokiInitPaths()
|
|
|
|
initializes some paths on linux/os x
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void LokiInitPaths( char *argv0 ){
|
2007-11-04 03:34:51 +00:00
|
|
|
#ifndef Q_UNIX
|
2012-03-17 20:01:54 +00:00
|
|
|
/* this is kinda crap, but hey */
|
|
|
|
strcpy( installPath, "../" );
|
2007-11-04 03:34:51 +00:00
|
|
|
#else
|
2012-03-17 20:01:54 +00:00
|
|
|
char temp[ MAX_OS_PATH ];
|
|
|
|
char *home;
|
|
|
|
char *path;
|
|
|
|
char *last;
|
|
|
|
qboolean found;
|
|
|
|
|
|
|
|
|
|
|
|
/* get home dir */
|
|
|
|
home = LokiGetHomeDir();
|
|
|
|
if ( home == NULL ) {
|
|
|
|
home = ".";
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do some path divining */
|
|
|
|
strcpy( temp, argv0 );
|
|
|
|
if ( strrchr( temp, '/' ) ) {
|
|
|
|
argv0 = strrchr( argv0, '/' ) + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* get path environment variable */
|
|
|
|
path = getenv( "PATH" );
|
|
|
|
|
|
|
|
/* minor setup */
|
|
|
|
last[ 0 ] = path[ 0 ];
|
|
|
|
last[ 1 ] = '\0';
|
|
|
|
found = qfalse;
|
|
|
|
|
|
|
|
/* go through each : segment of path */
|
|
|
|
while ( last[ 0 ] != '\0' && found == qfalse )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
/* null out temp */
|
|
|
|
temp[ 0 ] = '\0';
|
|
|
|
|
|
|
|
/* find next chunk */
|
|
|
|
last = strchr( path, ':' );
|
|
|
|
if ( last == NULL ) {
|
|
|
|
last = path + strlen( path );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
|
|
|
/* found home dir candidate */
|
|
|
|
if ( *path == '~' ) {
|
|
|
|
strcpy( temp, home );
|
|
|
|
path++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* concatenate */
|
|
|
|
if ( last > ( path + 1 ) ) {
|
|
|
|
strncat( temp, path, ( last - path ) );
|
|
|
|
strcat( temp, "/" );
|
|
|
|
}
|
|
|
|
strcat( temp, "./" );
|
|
|
|
strcat( temp, argv0 );
|
|
|
|
|
|
|
|
/* verify the path */
|
|
|
|
if ( access( temp, X_OK ) == 0 ) {
|
|
|
|
found++;
|
|
|
|
}
|
|
|
|
path = last + 1;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* flake */
|
|
|
|
if ( realpath( temp, installPath ) ) {
|
|
|
|
/* q3map is in "tools/" */
|
|
|
|
*( strrchr( installPath, '/' ) ) = '\0';
|
|
|
|
*( strrchr( installPath, '/' ) + 1 ) = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set home path */
|
|
|
|
homePath = home;
|
2007-11-04 03:34:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
CleanPath() - ydnar
|
|
|
|
cleans a dos path \ -> /
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void CleanPath( char *path ){
|
|
|
|
while ( *path )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( *path == '\\' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
*path = '/';
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
path++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
GetGame() - ydnar
|
|
|
|
gets the game_t based on a -game argument
|
|
|
|
returns NULL if no match found
|
|
|
|
*/
|
|
|
|
|
|
|
|
game_t *GetGame( char *arg ){
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( arg == NULL || arg[ 0 ] == '\0' ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
return NULL;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* joke */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !Q_stricmp( arg, "quake1" ) ||
|
|
|
|
!Q_stricmp( arg, "quake2" ) ||
|
|
|
|
!Q_stricmp( arg, "unreal" ) ||
|
|
|
|
!Q_stricmp( arg, "ut2k3" ) ||
|
|
|
|
!Q_stricmp( arg, "dn3d" ) ||
|
|
|
|
!Q_stricmp( arg, "dnf" ) ||
|
|
|
|
!Q_stricmp( arg, "hl" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Sys_Printf( "April fools, silly rabbit!\n" );
|
|
|
|
exit( 0 );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* test it */
|
|
|
|
i = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( games[ i ].arg != NULL )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Q_stricmp( arg, games[ i ].arg ) == 0 ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
return &games[ i ];
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2008-07-25 07:31:37 +00:00
|
|
|
/* no matching game */
|
|
|
|
return NULL;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
AddBasePath() - ydnar
|
|
|
|
adds a base path to the list
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void AddBasePath( char *path ){
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( path == NULL || path[ 0 ] == '\0' || numBasePaths >= MAX_BASE_PATHS ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add it to the list */
|
|
|
|
basePaths[ numBasePaths ] = safe_malloc( strlen( path ) + 1 );
|
|
|
|
strcpy( basePaths[ numBasePaths ], path );
|
|
|
|
CleanPath( basePaths[ numBasePaths ] );
|
|
|
|
numBasePaths++;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
AddHomeBasePath() - ydnar
|
|
|
|
adds a base path to the beginning of the list, prefixed by ~/
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void AddHomeBasePath( char *path ){
|
2007-11-04 03:34:51 +00:00
|
|
|
#ifdef Q_UNIX
|
2012-03-17 20:01:54 +00:00
|
|
|
int i;
|
|
|
|
char temp[ MAX_OS_PATH ];
|
|
|
|
|
|
|
|
|
|
|
|
/* dummy check */
|
|
|
|
if ( path == NULL || path[ 0 ] == '\0' ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make a hole */
|
|
|
|
for ( i = 0; i < ( MAX_BASE_PATHS - 1 ); i++ )
|
|
|
|
basePaths[ i + 1 ] = basePaths[ i ];
|
|
|
|
|
|
|
|
/* concatenate home dir and path */
|
|
|
|
sprintf( temp, "%s/%s", homePath, path );
|
|
|
|
|
|
|
|
/* add it to the list */
|
|
|
|
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
|
|
|
strcpy( basePaths[ 0 ], temp );
|
|
|
|
CleanPath( basePaths[ 0 ] );
|
|
|
|
numBasePaths++;
|
2007-11-04 03:34:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
AddGamePath() - ydnar
|
|
|
|
adds a game path to the list
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void AddGamePath( char *path ){
|
|
|
|
int i;
|
2011-01-20 07:15:47 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* dummy check */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( path == NULL || path[ 0 ] == '\0' || numGamePaths >= MAX_GAME_PATHS ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add it to the list */
|
|
|
|
gamePaths[ numGamePaths ] = safe_malloc( strlen( path ) + 1 );
|
|
|
|
strcpy( gamePaths[ numGamePaths ], path );
|
|
|
|
CleanPath( gamePaths[ numGamePaths ] );
|
|
|
|
numGamePaths++;
|
2011-01-20 07:15:47 +00:00
|
|
|
|
|
|
|
/* don't add it if it's already there */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numGamePaths - 1; i++ )
|
2011-01-20 07:15:47 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strcmp( gamePaths[i], gamePaths[numGamePaths - 1] ) == 0 ) {
|
|
|
|
free( gamePaths[numGamePaths - 1] );
|
2011-01-20 07:15:47 +00:00
|
|
|
gamePaths[numGamePaths - 1] = NULL;
|
|
|
|
numGamePaths--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
InitPaths() - ydnar
|
|
|
|
cleaned up some of the path initialization code from bsp.c
|
|
|
|
will remove any arguments it uses
|
|
|
|
*/
|
|
|
|
|
|
|
|
void InitPaths( int *argc, char **argv ){
|
|
|
|
int i, j, k, len, len2;
|
|
|
|
char temp[ MAX_OS_PATH ];
|
|
|
|
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* note it */
|
|
|
|
Sys_FPrintf( SYS_VRB, "--- InitPaths ---\n" );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* get the install path for backup */
|
|
|
|
LokiInitPaths( argv[ 0 ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* set game to default (q3a) */
|
|
|
|
game = &games[ 0 ];
|
|
|
|
numBasePaths = 0;
|
|
|
|
numGamePaths = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* parse through the arguments and extract those relevant to paths */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < *argc; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* check for null */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( argv[ i ] == NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -game */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strcmp( argv[ i ], "-game" ) == 0 ) {
|
|
|
|
if ( ++i >= *argc ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Out of arguments: No game specified after %s", argv[ i - 1 ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
argv[ i - 1 ] = NULL;
|
2008-07-25 07:31:37 +00:00
|
|
|
game = GetGame( argv[ i ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( game == NULL ) {
|
2008-07-25 07:31:37 +00:00
|
|
|
game = &games[ 0 ];
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
argv[ i ] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -fs_basepath */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( strcmp( argv[ i ], "-fs_basepath" ) == 0 ) {
|
|
|
|
if ( ++i >= *argc ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
argv[ i - 1 ] = NULL;
|
|
|
|
AddBasePath( argv[ i ] );
|
|
|
|
argv[ i ] = NULL;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* -fs_game */
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( strcmp( argv[ i ], "-fs_game" ) == 0 ) {
|
|
|
|
if ( ++i >= *argc ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Out of arguments: No path specified after %s.", argv[ i - 1 ] );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
argv[ i - 1 ] = NULL;
|
|
|
|
AddGamePath( argv[ i ] );
|
|
|
|
argv[ i ] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* remove processed arguments */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0, j = 0, k = 0; i < *argc && j < *argc; i++, j++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( ; j < *argc && argv[ j ] == NULL; j++ ) ;
|
2007-11-04 03:34:51 +00:00
|
|
|
argv[ i ] = argv[ j ];
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( argv[ i ] != NULL ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
k++;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
*argc = k;
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add standard game path */
|
|
|
|
AddGamePath( game->gamePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* if there is no base path set, figure it out */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numBasePaths == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* this is another crappy replacement for SetQdirFromPath() */
|
|
|
|
len2 = strlen( game->magic );
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < *argc && numBasePaths == 0; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* extract the arg */
|
|
|
|
strcpy( temp, argv[ i ] );
|
|
|
|
CleanPath( temp );
|
|
|
|
len = strlen( temp );
|
|
|
|
Sys_FPrintf( SYS_VRB, "Searching for \"%s\" in \"%s\" (%d)...\n", game->magic, temp, i );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* this is slow, but only done once */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < ( len - len2 ); j++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* check for the game's magic word */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( Q_strncasecmp( &temp[ j ], game->magic, len2 ) == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
/* now find the next slash and nuke everything after it */
|
2012-03-17 20:01:54 +00:00
|
|
|
while ( temp[ ++j ] != '/' && temp[ j ] != '\0' ) ;
|
2007-11-04 03:34:51 +00:00
|
|
|
temp[ j ] = '\0';
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add this as a base path */
|
|
|
|
AddBasePath( temp );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* add install path */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numBasePaths == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
AddBasePath( installPath );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* check again */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numBasePaths == 0 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Error( "Failed to find a valid base path." );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* this only affects unix */
|
|
|
|
AddHomeBasePath( game->homeBasePath );
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* initialize vfs paths */
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numBasePaths > MAX_BASE_PATHS ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
numBasePaths = MAX_BASE_PATHS;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( numGamePaths > MAX_GAME_PATHS ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
numGamePaths = MAX_GAME_PATHS;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* walk the list of game paths */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( j = 0; j < numGamePaths; j++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* walk the list of base paths */
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0; i < numBasePaths; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
/* create a full path and initialize it */
|
|
|
|
sprintf( temp, "%s/%s/", basePaths[ i ], gamePaths[ j ] );
|
|
|
|
vfsInitDirectory( temp );
|
|
|
|
}
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
/* done */
|
|
|
|
Sys_Printf( "\n" );
|
|
|
|
}
|