summaryrefslogtreecommitdiff
path: root/src/qcommon/files.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/qcommon/files.c')
-rw-r--r--src/qcommon/files.c56
1 files changed, 44 insertions, 12 deletions
diff --git a/src/qcommon/files.c b/src/qcommon/files.c
index 87301441..bb1f3f15 100644
--- a/src/qcommon/files.c
+++ b/src/qcommon/files.c
@@ -249,7 +249,7 @@ static searchpath_t *fs_searchpaths;
static int fs_readCount; // total bytes read
static int fs_loadCount; // total files read
static int fs_loadStack; // total files in memory
-static int fs_packFiles; // total number of files in packs
+static int fs_packFiles = 0; // total number of files in packs
static int fs_checksumFeed;
@@ -281,7 +281,7 @@ static fileHandleData_t fsh[MAX_FILE_HANDLES];
static qboolean fs_reordered;
// never load anything from pk3 files that are not present at the server when pure
-static int fs_numServerPaks;
+static int fs_numServerPaks = 0;
static int fs_serverPaks[MAX_SEARCH_PATHS]; // checksums
static char *fs_serverPakNames[MAX_SEARCH_PATHS]; // pk3 names
@@ -438,10 +438,18 @@ Fix things up differently for win/unix/mac
*/
static void FS_ReplaceSeparators( char *path ) {
char *s;
+ qboolean lastCharWasSep = qfalse;
for ( s = path ; *s ; s++ ) {
if ( *s == '/' || *s == '\\' ) {
- *s = PATH_SEP;
+ if ( !lastCharWasSep ) {
+ *s = PATH_SEP;
+ lastCharWasSep = qtrue;
+ } else {
+ memmove (s, s + 1, strlen (s));
+ }
+ } else {
+ lastCharWasSep = qfalse;
}
}
}
@@ -465,7 +473,7 @@ char *FS_BuildOSPath( const char *base, const char *game, const char *qpath ) {
}
Com_sprintf( temp, sizeof(temp), "/%s/%s", game, qpath );
- FS_ReplaceSeparators( temp );
+ FS_ReplaceSeparators( temp );
Com_sprintf( ospath[toggle], sizeof( ospath[0] ), "%s%s", base, temp );
return ospath[toggle];
@@ -481,6 +489,7 @@ Creates any directories needed to store the given filename
*/
qboolean FS_CreatePath (char *OSPath) {
char *ofs;
+ char path[MAX_OSPATH];
// make absolutely sure that it can't back up the path
// FIXME: is c: allowed???
@@ -489,14 +498,25 @@ qboolean FS_CreatePath (char *OSPath) {
return qtrue;
}
- for (ofs = OSPath+1 ; *ofs ; ofs++) {
- if (*ofs == PATH_SEP) {
+ Q_strncpyz( path, OSPath, sizeof( path ) );
+ FS_ReplaceSeparators( path );
+
+ // Skip creation of the root directory as it will always be there
+ ofs = strchr( path, PATH_SEP );
+ ofs++;
+
+ for (; ofs != NULL && *ofs ; ofs++) {
+ if (*ofs == PATH_SEP) {
// create the directory
*ofs = 0;
- Sys_Mkdir (OSPath);
+ if (!Sys_Mkdir (path)) {
+ Com_Error( ERR_FATAL, "FS_CreatePath: failed to create path \"%s\"\n",
+ path );
+ }
*ofs = PATH_SEP;
}
}
+
return qfalse;
}
@@ -2839,6 +2859,8 @@ static void FS_Startup( const char *gameName )
Com_Printf( "----- FS_Startup -----\n" );
+ fs_packFiles = 0;
+
fs_debug = Cvar_Get( "fs_debug", "0", 0 );
fs_basepath = Cvar_Get ("fs_basepath", Sys_DefaultInstallPath(), CVAR_INIT );
fs_basegame = Cvar_Get ("fs_basegame", "", CVAR_INIT );
@@ -2864,11 +2886,12 @@ static void FS_Startup( const char *gameName )
// NOTE: same filtering below for mods and basegame
if (fs_homepath->string[0] && Q_stricmp(fs_homepath->string,fs_basepath->string)) {
+ FS_CreatePath ( fs_homepath->string );
FS_AddGameDirectory ( fs_homepath->string, gameName );
}
// check for additional base game so mods can be based upon other mods
- if ( fs_basegame->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_basegame->string, gameName ) ) {
+ if ( fs_basegame->string[0] && Q_stricmp( fs_basegame->string, gameName ) ) {
if (fs_basepath->string[0]) {
FS_AddGameDirectory(fs_basepath->string, fs_basegame->string);
}
@@ -2878,7 +2901,7 @@ static void FS_Startup( const char *gameName )
}
// check for additional game folder for mods
- if ( fs_gamedirvar->string[0] && !Q_stricmp( gameName, BASEGAME ) && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
+ if ( fs_gamedirvar->string[0] && Q_stricmp( fs_gamedirvar->string, gameName ) ) {
if (fs_basepath->string[0]) {
FS_AddGameDirectory(fs_basepath->string, fs_gamedirvar->string);
}
@@ -3348,11 +3371,20 @@ FS_ConditionalRestart
restart if necessary
=================
*/
-qboolean FS_ConditionalRestart( int checksumFeed ) {
- if( fs_gamedirvar->modified || checksumFeed != fs_checksumFeed ) {
- FS_Restart( checksumFeed );
+qboolean FS_ConditionalRestart(int checksumFeed)
+{
+ if(fs_gamedirvar->modified)
+ {
+ Com_GameRestart(checksumFeed, qfalse);
return qtrue;
}
+
+ else if(checksumFeed != fs_checksumFeed)
+ {
+ FS_Restart(checksumFeed);
+ return qtrue;
+ }
+
return qfalse;
}