]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/main.cpp
Disable wayland backend on Linux and BSD
[xonotic/netradiant.git] / radiant / main.cpp
index 386f7106c2dacbd8e5e5b7e88b1481052b3aa7c7..3df10170085eddb32f17e53830fa55b3495ad5dc 100644 (file)
@@ -64,8 +64,6 @@
 #include "main.h"
 #include "globaldefs.h"
 
-#include "version.h"
-
 #include "debugging/debugging.h"
 
 #include "iundo.h"
@@ -329,6 +327,7 @@ void paths_init(){
 
        Q_mkdir( g_strSettingsPath.c_str() );
 
+       g_strAppFilePath = environment_get_app_filepath();
        g_strAppPath = environment_get_app_path();
        g_strLibPath = environment_get_lib_path();
        g_strDataPath = environment_get_data_path();
@@ -408,7 +407,7 @@ void create_global_pid(){
                // set without saving, the class is not in a coherent state yet
                // just do the value change and call to start logging, CGamesDialog will pickup when relevant
                g_GamesDialog.m_bForceLogConsole = true;
-               Sys_LogFile( true );
+               Sys_EnableLogFile( true );
        }
 
        // create a primary .pid for global init run
@@ -467,7 +466,7 @@ void create_local_pid(){
 
                // force console logging on! (will go in prefs too)
                g_GamesDialog.m_bForceLogConsole = true;
-               Sys_LogFile( true );
+               Sys_EnableLogFile( true );
        }
        else
        {
@@ -504,6 +503,13 @@ void user_shortcuts_save(){
 }
 
 int main( int argc, char* argv[] ){
+#if GTK_TARGET == 3
+       // HACK: force legacy GL backend as we don't support GL3 yet
+       setenv("GDK_GL", "LEGACY", 0);
+#if GDEF_OS_LINUX || GDEF_OS_BSD
+       setenv("GDK_BACKEND", "x11", 0);
+#endif
+#endif // GTK_TARGET == 3
        crt_init();
 
        streams_init();
@@ -521,29 +527,40 @@ int main( int argc, char* argv[] ){
 #endif
 
        const char* mapname = NULL;
+
+#if GDEF_OS_WINDOWS
+       StringOutputStream mapname_buffer( 256 );
+#endif
+
     char const *error = NULL;
+
        if ( !ui::init( &argc, &argv, "<filename.map>", &error) ) {
                g_print( "%s\n", error );
                return -1;
        }
 
        // Gtk already removed parsed `--options`
-       if (argc == 2) {
-               if ( strlen( argv[1] ) > 1 ) {
-                       if ( g_str_has_suffix( argv[1], ".map" ) ) {
-                               if ( g_path_is_absolute( argv[1] ) ) {
-                                       mapname = argv[1];
-                               }
-                               else {
-                                       mapname = g_build_filename( g_get_current_dir(), argv[1], NULL );
+       if ( argc == 2 ) {
+               if ( strlen( argv[ 1 ] ) > 1 ) {
+                       mapname = argv[ 1 ];
+
+                       if ( g_str_has_suffix( mapname, ".map" ) ) {
+                               if ( !g_path_is_absolute( mapname ) ) {
+                                       mapname = g_build_filename( g_get_current_dir(), mapname, NULL );
                                }
+
+#if GDEF_OS_WINDOWS
+                               mapname_buffer << PathCleaned( mapname );
+                               mapname = mapname_buffer.c_str();
+#endif
                        }
                        else {
-                               g_print( "bad file name, will not load: %s\n", argv[1] );
+                               g_print( "bad file name, will not load: %s\n", mapname );
+                               mapname = NULL;
                        }
                }
        }
-       else if (argc > 2) {
+       else if ( argc > 2 ) {
                g_print ( "%s\n", "too many arguments" );
                return -1;
        }
@@ -586,7 +603,7 @@ int main( int argc, char* argv[] ){
        // we may have the console turned on and want to keep it that way
        // so we use a latching system
        if ( g_GamesDialog.m_bForceLogConsole ) {
-               Sys_LogFile( true );
+               Sys_EnableLogFile( true );
                g_Console_enableLogging = true;
                g_GamesDialog.m_bForceLogConsole = false;
        }
@@ -640,7 +657,7 @@ int main( int argc, char* argv[] ){
        Radiant_Shutdown();
 
        // close the log file if any
-       Sys_LogFile( false );
+       Sys_EnableLogFile( false );
 
        return EXIT_SUCCESS;
 }