]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/map.cpp
[dpkdir] restart VFS only for Map_Free() and Map_LoadFile(), refresh others
[xonotic/netradiant.git] / radiant / map.cpp
index 0c0fd5f73136a59472c32f7c4b7b9846b3d37979..18d25c096c17784ffbef248310e271eadb90f858 100644 (file)
@@ -39,7 +39,6 @@ MapModules& ReferenceAPI_getMapModules();
 #include "ifilesystem.h"
 #include "namespace.h"
 #include "moduleobserver.h"
-#include "moduleobservers.h"
 
 #include <set>
 
@@ -406,29 +405,6 @@ float g_MinWorldCoord = -64 * 1024;
 void AddRegionBrushes( void );
 void RemoveRegionBrushes( void );
 
-/* Map open/close observers */
-
-ModuleObservers g_mapPathObservers;
-
-class MapFileObserver : public ModuleObserver
-{
-void realise() {
-               // Restart VFS to apply new pak filtering based on mapname
-               // needed for daemon dpk vfs
-               VFS_Restart();
-}
-void unrealise() { }
-};
-
-MapFileObserver g_mapFileObserver;
-
-void BindMapFileObservers(){
-       g_mapPathObservers.attach( g_mapFileObserver );
-}
-
-void UnBindMapFileObservers(){
-       g_mapPathObservers.detach( g_mapFileObserver );
-}
 
 
 /*
@@ -448,7 +424,6 @@ void Map_Free(){
 
        g_currentMap = 0;
        Brush_unlatchPreferences();
-       g_mapPathObservers.unrealise();
 }
 
 class EntityFindByClassname : public scene::Graph::Walker
@@ -973,7 +948,6 @@ void Map_LoadFile( const char *filename ){
                        }
                        Brush_toggleFormat( i );
                        g_map.m_name = filename;
-                       g_mapPathObservers.realise();
                        Map_UpdateTitle( g_map );
                        g_map.m_resource = GlobalReferenceCache().capture( g_map.m_name.c_str() );
                        if ( format ) {
@@ -1004,6 +978,10 @@ void Map_LoadFile( const char *filename ){
        Map_StartPosition();
 
        g_currentMap = &g_map;
+
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
 }
 
 class Excluder
@@ -1205,15 +1183,16 @@ void Map_RenameAbsolute( const char* absolute ){
 
        g_map.m_resource->detach( g_map );
        GlobalReferenceCache().release( g_map.m_name.c_str() );
-       g_mapPathObservers.unrealise();
 
        g_map.m_resource = resource;
 
        g_map.m_name = absolute;
-       g_mapPathObservers.realise();
        Map_UpdateTitle( g_map );
 
        g_map.m_resource->attach( g_map );
+       // refresh VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Refresh();
 }
 
 void Map_Rename( const char* filename ){
@@ -1248,7 +1227,6 @@ void Map_New(){
        //globalOutputStream() << "Map_New\n";
 
        g_map.m_name = "unnamed.map";
-       g_mapPathObservers.realise();
        Map_UpdateTitle( g_map );
 
        {
@@ -1262,6 +1240,10 @@ void Map_New(){
        FocusViews( g_vector3_identity, 0 );
 
        g_currentMap = &g_map;
+
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
 }
 
 extern void ConstructRegionBrushes( scene::Node * brushes[6], const Vector3 &region_mins, const Vector3 &region_maxs );
@@ -1612,7 +1594,13 @@ tryDecompile:
  */
 bool Map_SaveFile( const char* filename ){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" );
-       return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       bool success = MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       if ( success ) {
+               // refresh VFS to apply new pak filtering based on mapname
+               // needed for daemon DPK VFS
+               VFS_Refresh();
+       }
+       return success;
 }
 
 //