]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/vfspk3/vfs.cpp
refresh DPK VFS before refreshing textures
[xonotic/netradiant.git] / plugins / vfspk3 / vfs.cpp
index 7851210aac1e019b8a96cf0133d81faa17c0367a..bee7403beb75ae81f5168581d6315668ef808cde 100644 (file)
@@ -660,7 +660,7 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                for ( Archives::iterator i = archives.begin(); i != archives.end(); ++i ) {
                                        const char* name = i->c_str();
                                        const char* ext = strrchr( name, '.' );
-                                       if ( !string_compare_nocase_upper( ext, "dpk" ) ) {
+                                       if ( !string_compare_nocase_upper( ext, ".dpk" ) ) {
                                                CopiedString name_final = CopiedString( StringRange( name, ext ) );
                                                fullpath = string_new_concat( path, name );
                                                AddDpkPak( name_final.c_str(), fullpath, true );
@@ -673,8 +673,8 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                {
                                        const char* name = i->c_str();
                                        const char* ext = strrchr( name, '.' );
-                                       if ( !string_compare_nocase_upper( ext, "pk3" )
-                                               || !string_compare_nocase_upper( ext, "pk4" ) ) {
+                                       if ( !string_compare_nocase_upper( ext, ".pk3" )
+                                               || !string_compare_nocase_upper( ext, ".pk4" ) ) {
                                                fullpath = string_new_concat( path, i->c_str() );
                                                InitPakFile( archiveModules, fullpath );
                                                string_release( fullpath, string_length( fullpath ) );
@@ -684,8 +684,8 @@ void InitDirectory( const char* directory, ArchiveModules& archiveModules ){
                                {
                                        const char* name = i->c_str();
                                        const char* ext = strrchr( name, '.' );
-                                       if ( !string_compare_nocase_upper( ext, "pk3" )
-                                               || !string_compare_nocase_upper( ext, "pk4" ) ) {
+                                       if ( !string_compare_nocase_upper( ext, ".pk3" )
+                                               || !string_compare_nocase_upper( ext, ".pk4" ) ) {
                                                fullpath = string_new_concat( path, i->c_str() );
                                                InitPakFile( archiveModules, fullpath );
                                                string_release( fullpath, string_length( fullpath ) );
@@ -848,6 +848,12 @@ void initDirectory( const char *path ){
        InitDirectory( path, FileSystemQ3API_getArchiveModules() );
 }
 void initialise(){
+       load();
+       globalOutputStream() << "filesystem initialised\n";
+       g_observers.realise();
+}
+
+void load(){
        ArchiveModules& archiveModules = FileSystemQ3API_getArchiveModules();
        bool is_dpk_vfs = GetArchiveTable( archiveModules, "dpk" );
 
@@ -862,37 +868,30 @@ void initialise(){
 
                // prevent VFS double start, for MapName="" and MapName="unnamed.map"
                if ( string_length( GlobalRadiant().getMapName() ) ){
-                       // map's tex-* paks have precedence over any other tex-* paks
+                       // load map's paks from DEPS
                        char* mappakname = GetCurrentMapDpkPakName();
                        if ( mappakname != NULL ) {
                                LoadDpkPakWithDeps( mappakname );
                                string_release( mappakname, string_length( mappakname ) );
                        }
-
-                       for ( PakfilePaths::iterator i = g_pakfile_paths.begin(); i != g_pakfile_paths.end(); ++i ) {
-                               if ( strncmp( i->first.c_str(), "tex-", 4 ) != 0 ) continue;
-                               // firstly load latest version of pak
-                               const char *paknamever = i->first.c_str();
-                               const char *c = strchr( paknamever, '_' );
-                               char *paknameonly;
-                               if ( c ) paknameonly = string_clone_range( StringRange( paknamever, c ) );
-                               pakname = GetLatestDpkPakVersion( paknameonly );
-                               if (pakname != NULL) {
-                                       LoadDpkPakWithDeps( pakname );
-                               }
-                               if ( c ) string_release( paknameonly, string_length( paknameonly ) );
-                               // then load this specific version
-                               LoadDpkPakWithDeps( paknamever );
-                       }
                }
 
                g_pakfile_paths.clear();
                g_loaded_dpk_paks.clear();
        }
+}
 
-       globalOutputStream() << "filesystem initialised\n";
-       g_observers.realise();
+void clear() {
+       // like shutdown() but does not unrealise (keep map etc.)
+       Shutdown();
 }
+
+void refresh(){
+       // like initialise() but does not realise (keep map etc.)
+       load();
+       globalOutputStream() << "filesystem refreshed\n";
+}
+
 void shutdown(){
        g_observers.unrealise();
        globalOutputStream() << "filesystem shutdown\n";