diff --git a/code/qcommon/files.cpp b/code/qcommon/files.cpp index 953e59f..480966f 100644 --- a/code/qcommon/files.cpp +++ b/code/qcommon/files.cpp @@ -228,6 +228,10 @@ static int fs_packFiles; // total number of files in packs static int fs_checksumFeed; +static char fs_savedGamedir[MAX_OSPATH]; +static qbool fs_cnq3folderEnabled; +static qbool fs_cnq3folderWritesEnabled; + typedef union { FILE* o; unzFile z; @@ -2362,7 +2366,9 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) } } - Q_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) ); + if ( Q_stricmp( dir, "cnq3" ) != 0 ) { + Q_strncpyz( fs_gamedir, dir, sizeof( fs_gamedir ) ); + } // add the directory to the search path searchpath_t* search = Z_New(); @@ -2747,6 +2753,10 @@ static void FS_Startup( const char *gameName ) } } + if ( fs_basepath->string[0] && fs_cnq3folderEnabled ) { + FS_AddGameDirectory( fs_basepath->string, "cnq3" ); + } + Com_ReadCDKey(BASEGAME); if (fs_gamedirvar && fs_gamedirvar->string[0] != 0) { Com_AppendCDKey( fs_gamedirvar->string ); @@ -3318,3 +3328,28 @@ qbool FS_GetPakPath( char *name, int nameSize, int pakChecksum ) { return qfalse; } + +void FS_EnableCNQ3Folder( qbool enable ) +{ + if ( enable != fs_cnq3folderEnabled ) { + fs_cnq3folderEnabled = enable; + FS_Restart( fs_checksumFeed ); + } +} + +void FS_EnableCNQ3FolderWrites( qbool enable ) +{ + Q_assert( fs_cnq3folderEnabled && enable != fs_cnq3folderWritesEnabled ); + + if ( !fs_cnq3folderEnabled || enable == fs_cnq3folderWritesEnabled ) { + return; + } + + fs_cnq3folderWritesEnabled = enable; + if ( enable ) { + Q_strncpyz( fs_savedGamedir, fs_gamedir, sizeof( fs_savedGamedir ) ); + Q_strncpyz( fs_gamedir, "cnq3", sizeof( fs_gamedir ) ); + } else { + Q_strncpyz( fs_gamedir, fs_savedGamedir, sizeof( fs_gamedir ) ); + } +} diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index ffff7b2..8375c20 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -795,6 +795,9 @@ void FS_FilenameCompletion( const char *dir, const char *ext, qbool stripExt, qbool FS_GetPakPath( char *name, int nameSize, int pakChecksum ); +void FS_EnableCNQ3Folder( qbool enable ); +void FS_EnableCNQ3FolderWrites( qbool enable ); + /* ============================================================== diff --git a/code/renderer/srp_main.cpp b/code/renderer/srp_main.cpp index 7123593..1d69d47 100644 --- a/code/renderer/srp_main.cpp +++ b/code/renderer/srp_main.cpp @@ -227,10 +227,12 @@ void R_SelectRenderPipeline() if(r_pipeline->integer == 0) { renderPipeline = grpp; + FS_EnableCNQ3Folder(qfalse); } else { renderPipeline = crpp; + FS_EnableCNQ3Folder(qtrue); } }