From: Rudolf Polzer Date: Sun, 10 Oct 2010 12:10:10 +0000 (+0200) Subject: clean up the reload-if-failed code X-Git-Tag: xonotic-v0.5.0~175 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e1ed914df2a6c48e814bc0bdb6b333e322b8d561;p=xonotic%2Fnetradiant.git clean up the reload-if-failed code --- diff --git a/radiant/map.cpp b/radiant/map.cpp index ece542bb..365c50b4 100644 --- a/radiant/map.cpp +++ b/radiant/map.cpp @@ -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());