From 22de3606a6b30e92ec1c61c50a5e28571fa4dad0 Mon Sep 17 00:00:00 2001 From: Willi Schinmeyer Date: Fri, 4 May 2012 10:02:31 +0200 Subject: [PATCH 1/2] 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 2fa5221..ede1426 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 9368292..6d24c98 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 e72adc4..3caf584 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_ From ead68d88845bd55d0f67973a82fcb9c0717ad6f9 Mon Sep 17 00:00:00 2001 From: Willi Schinmeyer Date: Fri, 4 May 2012 10:07:28 +0200 Subject: [PATCH 2/2] Fixed spelling in a comment --- radiant/mainframe.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 6d24c98..70a5a1f 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -3625,7 +3625,7 @@ const bool IsMap(const char* filename){ } void MainFrame::CreateQEChildren(){ - // load the project file, if it is a project project file. (Or at least no .map) + // load the project file, if it is a 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] ) ) {