Skip to content

Commit

Permalink
Remove fs_cdpath and related vars/functions since they are no longer …
Browse files Browse the repository at this point in the history
…required.

git-svn-id: https://svn.thedarkmod.com/svn/darkmod_src/trunk@5808 49c82d7f-2e2a-0410-a16f-ae8f201b507f
  • Loading branch information
taaaki committed Jun 9, 2013
1 parent 89ae10e commit aa824f0
Show file tree
Hide file tree
Showing 15 changed files with 19 additions and 175 deletions.
5 changes: 0 additions & 5 deletions TypeInfo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ const char *Sys_Cwd( void ) {
return cwd;
}

const char *Sys_DefaultCDPath( void ) {
return "";
}

const char *Sys_DefaultBasePath( void ) {
return Sys_Cwd();
}
Expand Down Expand Up @@ -194,7 +190,6 @@ int Sys_ListFiles( const char *directory, const char *extension, idStrList &list

#else

const char * Sys_DefaultCDPath( void ) { return ""; }
const char * Sys_DefaultBasePath( void ) { return ""; }
const char * Sys_DefaultSavePath( void ) { return ""; }
int Sys_ListFiles( const char *directory, const char *extension, idStrList &list ) { return 0; }
Expand Down
1 change: 0 additions & 1 deletion cm/CollisionModel_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ void idCollisionModelManagerLocal::WriteCollisionModelsToFile( const char *filen
name.SetFileExtension( CM_FILE_EXT );

common->Printf( "writing %s\n", name.c_str() );
// _D3XP was saving to fs_cdpath TODO: Check this is still relevant
fp = fileSystem->OpenFileWrite( name, "fs_devpath", "" );
if ( !fp ) {
common->Warning( "idCollisionModelManagerLocal::WriteCollisionModelsToFile: Error opening file %s", name.c_str() );
Expand Down
6 changes: 0 additions & 6 deletions framework/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,6 @@ void idCommonLocal::Error( const char *fmt, ... ) {
// always turn this off after an error
com_refreshOnPrint = false;

// when we are running automated scripts, make sure we
// know if anything failed
if ( cvarSystem->GetCVarInteger( "fs_copyfiles" ) ) {
code = ERP_FATAL;
}

// if we don't have GL running, make it a fatal error
if ( !renderSystem->IsOpenGLRunning() ) {
code = ERP_FATAL;
Expand Down
137 changes: 13 additions & 124 deletions framework/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ to the base path, but can be overridden with a "+set fs_savepath c:\doom" on the
command line. Any files that are created during the game (demos, screenshots, etc.) will
be created reletive to the save path.
The "cd path" is the path to an alternate hierarchy that will be searched if a file
is not located in the base path. A user can do a partial install that copies some
data to a base path created on their hard drive and leave the rest on the cd. It defaults
to the current directory, but it can be overridden with "+set fs_cdpath g:\doom" on the
command line.
The "dev path" is the path to an alternate hierarchy where the editors and tools used
during development (Radiant, AF editor, dmap, runAAS) will write files to. It defaults to
the cd path, but can be overridden with a "+set fs_devpath c:\doom" on the command line.
Expand All @@ -93,24 +87,6 @@ files of the form "pak0.pk4", "pak1.pk4", etc. Zip files are searched in decendi
from the highest number to the lowest, and will always take precedence over the filesystem.
This allows a pk4 distributed as a patch to override all existing data.
If the "fs_copyfiles" cvar is set to 1, then every time a file is sourced from the cd
path, it will be copied over to the save path. This is a development aid to help build
test releases and to copy working sets of files.
If the "fs_copyfiles" cvar is set to 2, any file found in fs_cdpath that is newer than
it's fs_savepath version will be copied to fs_savepath (in addition to the fs_copyfiles 1
behaviour).
If the "fs_copyfiles" cvar is set to 3, files from both basepath and cdpath will be copied
over to the save path. This is useful when copying working sets of files mainly from base
path with an additional cd path (which can be a slower network drive for instance).
If the "fs_copyfiles" cvar is set to 4, files that exist in the cd path but NOT the base path
will be copied to the save path
NOTE: fs_copyfiles and case sensitivity. On fs_caseSensitiveOS 0 filesystems ( win32 ), the
copied files may change casing when copied over.
The relative path "sound/newstuff/test.wav" would be searched for in the following places:
for save path, dev path, base path, cd path:
Expand Down Expand Up @@ -197,7 +173,7 @@ typedef struct searchpath_s {
#define FSFLAG_BINARY_ONLY ( 1 << 2 )
#define FSFLAG_SEARCH_ADDONS ( 1 << 3 )

// 3 search path (fs_savepath fs_basepath fs_cdpath)
// 2 search path (fs_savepath fs_basepath)
// + .jpg and .tga
#define MAX_CACHED_DIRS 6

Expand Down Expand Up @@ -229,7 +205,6 @@ class idFileSystemLocal : public idFileSystem {
virtual void Restart( void );
virtual void Shutdown( bool reloading );
virtual bool IsInitialized( void ) const;
virtual bool PerformingCopyFiles( void ) const;
virtual idModList * ListMods( void );
virtual void FreeModList( idModList *modList );
virtual idFileList * ListFiles( const char *relativePath, const char *extension, bool sort = false, bool fullRelativePath = false, const char* gamedir = NULL );
Expand All @@ -246,8 +221,8 @@ class idFileSystemLocal : public idFileSystem {
virtual void FreeFile( void *buffer );
virtual int WriteFile( const char *relativePath, const void *buffer, int size, const char *basePath = "fs_modSavePath", const char *gamedir = NULL);
virtual void RemoveFile( const char *relativePath );
virtual idFile * OpenFileReadFlags( const char *relativePath, int searchFlags, pack_t **foundInPak = NULL, bool allowCopyFiles = true, const char* gamedir = NULL );
virtual idFile * OpenFileRead( const char *relativePath, bool allowCopyFiles = true, const char* gamedir = NULL );
virtual idFile * OpenFileReadFlags( const char *relativePath, int searchFlags, pack_t **foundInPak = NULL, const char* gamedir = NULL );
virtual idFile * OpenFileRead( const char *relativePath, const char* gamedir = NULL );
virtual idFile * OpenFileWrite( const char *relativePath, const char *basePath = "fs_modSavePath", const char *gamedir = NULL );
virtual idFile * OpenFileAppend( const char *relativePath, bool sync = false, const char *basePath = "fs_modSavePath", const char *gamedir = NULL );
virtual idFile * OpenFileByMode( const char *relativePath, fsMode_t mode );
Expand Down Expand Up @@ -292,10 +267,8 @@ class idFileSystemLocal : public idFileSystem {
idDict mapDict; // for GetMapDecl

static idCVar fs_debug;
static idCVar fs_copyfiles;
static idCVar fs_basepath;
static idCVar fs_savepath;
static idCVar fs_cdpath;
static idCVar fs_devpath;
static idCVar fs_caseSensitiveOS;
static idCVar fs_searchAddons;
Expand Down Expand Up @@ -362,10 +335,8 @@ class idFileSystemLocal : public idFileSystem {
};

idCVar idFileSystemLocal::fs_debug( "fs_debug", "0", CVAR_SYSTEM | CVAR_INTEGER, "", 0, 2, idCmdSystem::ArgCompletion_Integer<0,2> );
idCVar idFileSystemLocal::fs_copyfiles( "fs_copyfiles", "0", CVAR_SYSTEM | CVAR_INIT | CVAR_INTEGER, "", 0, 4, idCmdSystem::ArgCompletion_Integer<0,3> );
idCVar idFileSystemLocal::fs_basepath( "fs_basepath", "", CVAR_SYSTEM | CVAR_INIT, "" );
idCVar idFileSystemLocal::fs_savepath( "fs_savepath", "", CVAR_SYSTEM | CVAR_INIT, "" );
idCVar idFileSystemLocal::fs_cdpath( "fs_cdpath", "", CVAR_SYSTEM | CVAR_INIT, "" );
idCVar idFileSystemLocal::fs_devpath( "fs_devpath", "", CVAR_SYSTEM | CVAR_INIT, "" );

// taaaki: Removed fs_game and fs_game_base and replaced with fs_mod and fs_currentfm
Expand Down Expand Up @@ -953,7 +924,7 @@ int idFileSystemLocal::ReadFile( const char *relativePath, void **buffer, ID_TIM
}

// look for it in the filesystem or pack files
f = OpenFileRead( relativePath, ( buffer != NULL ) );
f = OpenFileRead( relativePath );
if ( f == NULL ) {
if ( buffer ) {
*buffer = NULL;
Expand Down Expand Up @@ -1554,14 +1525,13 @@ idModList *idFileSystemLocal::ListMods( void ) {

idModList *list = new idModList;

const char *search[ 4 ];
const char *search[ 3 ];

search[0] = fs_savepath.GetString();
search[1] = fs_devpath.GetString();
search[2] = fs_basepath.GetString();
search[3] = fs_cdpath.GetString();

for ( int isearch = 0; isearch < 4; isearch++ ) {
for ( int isearch = 0; isearch < 3; isearch++ ) {

dirs.Clear();
pk4s.Clear();
Expand Down Expand Up @@ -1590,7 +1560,7 @@ idModList *idFileSystemLocal::ListMods( void ) {
int isearch;
// read the descriptions for each mod - search all paths
for ( int i = 0; i < list->mods.Num(); i++ ) {
for ( isearch = 0; isearch < 4; isearch++ ) {
for ( isearch = 0; isearch < 3; isearch++ ) {

idStr descfile = BuildOSPath( search[ isearch ], list->mods[ i ], "description.txt" );
FILE *f = OpenOSFile( descfile, "r" );
Expand All @@ -1607,7 +1577,7 @@ idModList *idFileSystemLocal::ListMods( void ) {
}
}

if ( isearch == 4 ) {
if ( isearch == 3 ) {
list->descriptions.Append( list->mods[ i ] );
}
}
Expand Down Expand Up @@ -1883,7 +1853,7 @@ int idFileSystemLocal::GetOSMask( void ) {
idFileSystemLocal::TouchFile_f
The only purpose of this function is to allow game script files to copy
arbitrary files furing an "fs_copyfiles 1" run.
arbitrary files furing an "fs_copyfiles 1" run. taaaki - TODO : check if I need to remove this
============
*/
void idFileSystemLocal::TouchFile_f( const idCmdArgs &args ) {
Expand Down Expand Up @@ -2007,15 +1977,6 @@ idFileSystemLocal::SetupGameDirectories
================
*/
void idFileSystemLocal::SetupGameDirectories( const char *gameName ) {
// taaaki: TODO - after 1.08, ::Startup and ::SetupGameDirectories need
// to be looked at. We can probably get rid of fs_cdpath
// and simplify the searchpaths

// setup cdpath
if ( fs_cdpath.GetString()[0] ) {
AddGameDirectory( fs_cdpath.GetString(), gameName );
}

// setup basepath
if ( fs_basepath.GetString()[0] ) {
AddGameDirectory( fs_basepath.GetString(), gameName );
Expand Down Expand Up @@ -2349,7 +2310,6 @@ int idFileSystemLocal::ValidateDownloadPakForChecksum( int checksum, char path[
testList.Append( fs_savepath.GetString() );
testList.Append( fs_devpath.GetString() );
testList.Append( fs_basepath.GetString() );
testList.Append( fs_cdpath.GetString() );

for ( i = 0; i < testList.Num(); i ++ ) {
if ( testList[ i ].Length() && !testList[ i ].Icmpn( pak->pakFilename, testList[ i ].Length() ) ) {
Expand Down Expand Up @@ -2382,9 +2342,7 @@ void idFileSystemLocal::Init( void ) {
// has already been initialized
common->StartupVariable( "fs_basepath", false );
common->StartupVariable( "fs_savepath", false );
common->StartupVariable( "fs_cdpath", false );
common->StartupVariable( "fs_devpath", false );
common->StartupVariable( "fs_copyfiles", false );
common->StartupVariable( "fs_searchAddons", false );

// taaaki: we have replaced fs_game and fs_game_base with these
Expand All @@ -2400,9 +2358,6 @@ void idFileSystemLocal::Init( void ) {
if ( fs_savepath.GetString()[0] == '\0' ) {
fs_savepath.SetString( Sys_DefaultSavePath() );
}
if ( fs_cdpath.GetString()[0] == '\0' ) {
fs_cdpath.SetString( Sys_DefaultCDPath() );
}

if ( fs_devpath.GetString()[0] == '\0' ) {
fs_devpath.SetString( Sys_DefaultSavePath() );
Expand Down Expand Up @@ -2622,7 +2577,7 @@ Used for streaming data out of either a
separate file or a ZIP file.
===========
*/
idFile *idFileSystemLocal::OpenFileReadFlags( const char *relativePath, int searchFlags, pack_t **foundInPak, bool allowCopyFiles, const char* gamedir ) {
idFile *idFileSystemLocal::OpenFileReadFlags( const char *relativePath, int searchFlags, pack_t **foundInPak, const char* gamedir ) {
searchpath_t * search;
idStr netpath;
pack_t * pak;
Expand Down Expand Up @@ -2667,7 +2622,7 @@ idFile *idFileSystemLocal::OpenFileReadFlags( const char *relativePath, int sear
if ( !FileAllowedFromDir( relativePath ) ) {
continue;
}
}
}

dir = search->dir;

Expand All @@ -2693,63 +2648,6 @@ idFile *idFileSystemLocal::OpenFileReadFlags( const char *relativePath, int sear
common->Printf( "idFileSystem::OpenFileRead: %s (found in '%s/%s')\n", relativePath, dir->path.c_str(), dir->gamedir.c_str() );
}

// if fs_copyfiles is set
if ( allowCopyFiles && fs_copyfiles.GetInteger() ) {

idStr copypath;
idStr name;
copypath = BuildOSPath( fs_savepath.GetString(), dir->gamedir, relativePath );
netpath.ExtractFileName( name );
copypath.StripFilename( );
copypath += PATHSEPERATOR_STR;
copypath += name;

bool isFromCDPath = !dir->path.Cmp( fs_cdpath.GetString() );
bool isFromSavePath = !dir->path.Cmp( fs_savepath.GetString() );
bool isFromBasePath = !dir->path.Cmp( fs_basepath.GetString() );

switch ( fs_copyfiles.GetInteger() ) {
case 1:
// copy from cd path only
if ( isFromCDPath ) {
CopyFile( netpath, copypath );
}
break;
case 2:
// from cd path + timestamps
if ( isFromCDPath ) {
CopyFile( netpath, copypath );
} else if ( isFromSavePath || isFromBasePath ) {
idStr sourcepath;
sourcepath = BuildOSPath( fs_cdpath.GetString(), dir->gamedir, relativePath );
FILE *f1 = OpenOSFile( sourcepath, "r" );
if ( f1 ) {
ID_TIME_T t1 = Sys_FileTimeStamp( f1 );
fclose( f1 );
FILE *f2 = OpenOSFile( copypath, "r" );
if ( f2 ) {
ID_TIME_T t2 = Sys_FileTimeStamp( f2 );
fclose( f2 );
if ( t1 > t2 ) {
CopyFile( sourcepath, copypath );
}
}
}
}
break;
case 3:
if ( isFromCDPath || isFromBasePath ) {
CopyFile( netpath, copypath );
}
break;
case 4:
if ( isFromCDPath && !isFromBasePath ) {
CopyFile( netpath, copypath );
}
break;
}
}

return file;
} else if ( search->pack && ( searchFlags & FSFLAG_SEARCH_PAKS ) ) {

Expand Down Expand Up @@ -2837,8 +2735,8 @@ idFile *idFileSystemLocal::OpenFileReadFlags( const char *relativePath, int sear
idFileSystemLocal::OpenFileRead
===========
*/
idFile *idFileSystemLocal::OpenFileRead( const char *relativePath, bool allowCopyFiles, const char* gamedir ) {
return OpenFileReadFlags( relativePath, FSFLAG_SEARCH_DIRS | FSFLAG_SEARCH_PAKS, NULL, allowCopyFiles, gamedir );
idFile *idFileSystemLocal::OpenFileRead( const char *relativePath, const char* gamedir ) {
return OpenFileReadFlags( relativePath, FSFLAG_SEARCH_DIRS | FSFLAG_SEARCH_PAKS, NULL, gamedir );
}

/*
Expand Down Expand Up @@ -3239,15 +3137,6 @@ void idFileSystemLocal::BackgroundDownload( backgroundDownload_t *bgl ) {
}
}

/*
=================
idFileSystemLocal::PerformingCopyFiles
=================
*/
bool idFileSystemLocal::PerformingCopyFiles( void ) const {
return fs_copyfiles.GetInteger() > 0;
}

/*
=================
idFileSystemLocal::FindPakForFileChecksum
Expand Down
5 changes: 1 addition & 4 deletions framework/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"fs_basepath" path to local install, read-only
"fs_savepath" path to config, save game, etc. files, read & write
"fs_cdpath" path to cd, read-only
"fs_devpath" path to files created during development, read & write
The base path for file saving can be set to "fs_savepath" or "fs_devpath".
Expand Down Expand Up @@ -140,8 +139,6 @@ class idFileSystem {
virtual void Shutdown( bool reloading ) = 0;
// Returns true if the file system is initialized.
virtual bool IsInitialized( void ) const = 0;
// Returns true if we are doing an fs_copyfiles.
virtual bool PerformingCopyFiles( void ) const = 0;
// Returns a list of mods found along with descriptions
// 'mods' contains the directory names to be passed to fs_mod
// 'descriptions' contains a free form string to be used in the UI
Expand Down Expand Up @@ -190,7 +187,7 @@ class idFileSystem {
// Removes the given file.
virtual void RemoveFile( const char *relativePath ) = 0;
// Opens a file for reading.
virtual idFile * OpenFileRead( const char *relativePath, bool allowCopyFiles = true, const char* gamedir = NULL ) = 0;
virtual idFile * OpenFileRead( const char *relativePath, const char* gamedir = NULL ) = 0;
// Opens a file for writing, will create any needed subdirectories.
virtual idFile * OpenFileWrite( const char *relativePath, const char *basePath = "fs_modSavePath", const char *gamedir = NULL ) = 0;
// Opens a file for writing at the end.
Expand Down
2 changes: 1 addition & 1 deletion framework/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1856,7 +1856,7 @@ bool idSessionLocal::LoadGame( const char *saveName ) {
// Open savegame file
// only allow loads from the game directory because we don't want a base game to load
idStr game = cvarSystem->GetCVarString( "fs_currentfm" );
savegameFile = fileSystem->OpenFileRead( in, true, game.Length() ? game : NULL );
savegameFile = fileSystem->OpenFileRead( in, game.Length() ? game : NULL );

if ( savegameFile == NULL ) {
common->Warning( "Couldn't open savegame file %s", in.c_str() );
Expand Down
2 changes: 1 addition & 1 deletion framework/Session_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ bool idSessionLocal::HandleSaveGameMenuCommand( idCmdArgs &args, int &icmd ) {
idStr game = cvarSystem->GetCVarString( "fs_currentfm" );
idFile *file;
if(game.Length()) {
file = fileSystem->OpenFileRead( saveFileName, true, game );
file = fileSystem->OpenFileRead( saveFileName, game );
} else {
file = fileSystem->OpenFileRead( saveFileName );
}
Expand Down
Loading

0 comments on commit aa824f0

Please sign in to comment.