From d81ce8e1dc53e9ca395e8bb10a10e58121969b7c Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Tue, 1 Aug 2017 21:04:58 +0200 Subject: [PATCH] dpk vfs: now loads DEPS file from game pack - this way, there is no need to hardcode the loading of tex-common or res-buildables to get common textures and games buildables models, the game developers just have to provide a DEPS file with their game pack, and there is no need to enforce the name for this kind of stuff --- plugins/vfspk3/vfs.cpp | 52 ++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/plugins/vfspk3/vfs.cpp b/plugins/vfspk3/vfs.cpp index bb3b5dbf..23805ebc 100644 --- a/plugins/vfspk3/vfs.cpp +++ b/plugins/vfspk3/vfs.cpp @@ -377,23 +377,43 @@ static Archives g_loaded_dpk_paks; // actual pak adding on initialise, deferred from InitDirectory // Daemon DPK filesystem doesn't need load all paks it finds static void LoadDpkPakWithDeps( const char* pakname ){ - const char* und = strrchr( pakname, '_' ); - if ( !und ) pakname = GetLatestDpkPakVersion( pakname ); - if ( !pakname || g_loaded_dpk_paks.find( pakname ) != g_loaded_dpk_paks.end() ) return; - - PakfilePaths::iterator i = g_pakfile_paths.find( pakname ); - if ( i == g_pakfile_paths.end() ) return; - Archive* arc; - if ( i->second.is_pakfile ){ - arc = InitPakFile( FileSystemQ3API_getArchiveModules(), i->second.fullpath.c_str() ); + ArchiveTextFile* depsFile; + + if (pakname == NULL) { + // load DEPS from game pack + StringOutputStream baseDirectory( 256 ); + const char* basegame = GlobalRadiant().getRequiredGameDescriptionKeyValue( "basegame" ); + baseDirectory << GlobalRadiant().getGameToolsPath() << basegame << '/'; + arc = AddDpkDir( baseDirectory.c_str() ); + depsFile = arc->openTextFile( "DEPS" ); } else { - arc = AddDpkDir( i->second.fullpath.c_str() ); + const char* und = strrchr( pakname, '_' ); + if ( !und ) { + pakname = GetLatestDpkPakVersion( pakname ); + } + if ( !pakname || g_loaded_dpk_paks.find( pakname ) != g_loaded_dpk_paks.end() ) { + return; + } + + PakfilePaths::iterator i = g_pakfile_paths.find( pakname ); + if ( i == g_pakfile_paths.end() ) { + return; + } + + if ( i->second.is_pakfile ){ + arc = InitPakFile( FileSystemQ3API_getArchiveModules(), i->second.fullpath.c_str() ); + } else { + arc = AddDpkDir( i->second.fullpath.c_str() ); + } + g_loaded_dpk_paks.insert( pakname ); + + depsFile = arc->openTextFile( "DEPS" ); } - g_loaded_dpk_paks.insert( pakname ); - ArchiveTextFile* depsFile = arc->openTextFile( "DEPS" ); - if ( !depsFile ) return; + if ( !depsFile ) { + return; + } { TextLinesInputStream istream = depsFile->getInputStream(); @@ -790,10 +810,8 @@ void load(){ const char* pakname; g_loaded_dpk_paks.clear(); - pakname = GetLatestDpkPakVersion( "tex-common" ); - if (pakname != NULL) { - LoadDpkPakWithDeps( pakname ); - } + // Load DEPS from game pack + LoadDpkPakWithDeps( NULL ); // prevent VFS double start, for MapName="" and MapName="unnamed.map" if ( string_length( GlobalRadiant().getMapName() ) ){ -- 2.39.2