From 22de3606a6b30e92ec1c61c50a5e28571fa4dad0 Mon Sep 17 00:00:00 2001 From: Willi Schinmeyer Date: Fri, 4 May 2012 10:02:31 +0200 Subject: [PATCH] If the first argument ends in .map, try to load it as a map (instead of as a project) --- radiant/main.cpp | 6 +++++- radiant/mainframe.cpp | 9 +++++++-- radiant/mainframe.h | 3 +++ 3 files changed, 15 insertions(+), 3 deletions(-) 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_