]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
clean up the reload-if-failed code
authorRudolf Polzer <divverent@alientrap.org>
Sun, 10 Oct 2010 12:10:10 +0000 (14:10 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Sun, 10 Oct 2010 12:10:10 +0000 (14:10 +0200)
radiant/map.cpp

index ece542bb1a25ca6cc6c1b0cff841e36370dbfbd8..365c50b475289cf3f789d2e08897be47fff5beb0 100644 (file)
@@ -1032,29 +1032,28 @@ void Map_LoadFile (const char *filename)
   globalOutputStream() << "Loading map from " << filename << "\n";
   ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Map");
 
-  g_map.m_name = filename;
-  Map_UpdateTitle(g_map);
-
   {
     ScopeTimer timer("map load");
 
-    g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str());
+    const MapFormat* format = NULL;
+    const char* moduleName = findModuleName(&GlobalFiletypes(), MapFormat::Name(), path_get_extension(filename));
+    if(string_not_empty(moduleName))
+      format = ReferenceAPI_getMapModules().findModule(moduleName);
 
-    const MapFormat* format = ReferenceAPI_getMapModules().findModule("mapq3");
-    format->wrongFormat = false;
-    g_map.m_resource->attach(g_map);
-    if(format->wrongFormat)
+    for(int i = 0; i < Brush_toggleFormatCount(); ++i)
     {
-      // try toggling BrushPrimitives
-      for(i = 1; i < Brush_toggleFormatCount(); ++i)
-      {
+      if(i)
        Map_Free();
-       Brush_toggleFormat(i);
-       g_map.m_name = filename;
-       Map_UpdateTitle(g_map);
-       g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str());
-       g_map.m_resource->attach(g_map);
-      }
+      Brush_toggleFormat(i);
+      g_map.m_name = filename;
+      Map_UpdateTitle(g_map);
+      g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str());
+      if(format)
+       format->wrongFormat = false;
+      g_map.m_resource->attach(g_map);
+      if(format)
+       if(!format->wrongFormat)
+         break;
     }
 
     Node_getTraversable(GlobalSceneGraph().root())->traverse(entity_updateworldspawn());