From: Willi Schinmeyer Date: Fri, 4 May 2012 08:02:31 +0000 (+0200) Subject: If the first argument ends in .map, try to load it as a map (instead of as a project) X-Git-Tag: xonotic-v0.7.0~16^2^2~3^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=22de3606a6b30e92ec1c61c50a5e28571fa4dad0;p=xonotic%2Fnetradiant.git If the first argument ends in .map, try to load it as a map (instead of as a project) --- diff --git a/radiant/main.cpp b/radiant/main.cpp index 2fa52214..ede1426f 100644 --- a/radiant/main.cpp +++ b/radiant/main.cpp @@ -894,7 +894,11 @@ int main( int argc, char* argv[] ) { g_pParentWnd = new MainFrame(); - if ( g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0 ) { + // If the first parameter is a .map, load that. + if( g_argc > 1 && IsMap( g_argv[1] ) ){ + Map_LoadFile( g_argv[1] ); + } + else if ( g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0 ) { Map_LoadFile( g_PrefsDlg.m_strLastMap.GetBuffer() ); } else { diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 9368292f..6d24c98b 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -3619,9 +3619,14 @@ void MainFrame::ShowMenuItemKeyBindings( GtkWidget* window ){ } } +// Checks whether a given filename ends in .map +const bool IsMap(const char* filename){ + return strlen(filename) >= 4 && strcmp(filename + strlen(filename) - 4, ".map") == 0; +} + void MainFrame::CreateQEChildren(){ - // load the project file - if ( g_argc > 1 ) { + // load the project file, if it is a project project file. (Or at least no .map) + if ( g_argc > 1 && !IsMap( g_argv[1] ) ) { Sys_Printf( "loading project file from the command line: %s\n", g_argv[1] ); if ( !QE_LoadProject( g_argv[1] ) ) { Error( "Unable to load project file %s\n", g_argv[1] ); diff --git a/radiant/mainframe.h b/radiant/mainframe.h index e72adc4c..3caf5840 100644 --- a/radiant/mainframe.h +++ b/radiant/mainframe.h @@ -908,4 +908,7 @@ int gdk_offset_y; // some C API to the mainframe functions void WINAPI QERApp_Sleep(); +// Checks whether a given filename ends in .map +const bool IsMap(const char* filename); + #endif // _MAINFRAME_H_