]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/environment.cpp
Centralise compile checks
[xonotic/netradiant.git] / radiant / environment.cpp
index 954847eba3bbb0a6e8ca0f582a579676e440f483..1c297f03b353531708a78ab8b5264903d16c5450 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "environment.h"
+#include "globaldefs.h"
 
 #include "stream/textstream.h"
 #include "string/string.h"
@@ -30,9 +31,9 @@
 #include "cmdlib.h"
 
 int g_argc;
-char** g_argv;
+char const** g_argv;
 
-void args_init( int argc, char* argv[] ){
+void args_init( int argc, char const* argv[] ){
        int i, j, k;
 
        for ( i = 1; i < argc; i++ )
@@ -54,8 +55,8 @@ void args_init( int argc, char* argv[] ){
        g_argv = argv;
 }
 
-char *gamedetect_argv_buffer[1024];
-void gamedetect_found_game( char *game, char *path ){
+char const *gamedetect_argv_buffer[1024];
+void gamedetect_found_game( char const *game, char *path ){
        int argc;
        static char buf[128];
 
@@ -79,7 +80,7 @@ void gamedetect_found_game( char *game, char *path ){
        g_argv = gamedetect_argv_buffer;
 }
 
-bool gamedetect_check_game( char *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){
+bool gamedetect_check_game( char const *gamefile, const char *checkfile1, const char *checkfile2, char *buf /* must have 64 bytes free after bufpos */, int bufpos ){
        buf[bufpos] = '/';
 
        strcpy( buf + bufpos + 1, checkfile1 );
@@ -127,9 +128,9 @@ void gamedetect(){
                        // TODO add more games to this
 
                        // try to detect Nexuiz installs
-#if defined( WIN32 )
+#if GDEF_OS_WINDOWS
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz.exe", buf, p - buf ) )
-#elif defined( __APPLE__ )
+#elif GDEF_OS_MACOS
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "Nexuiz.app/Contents/Info.plist", buf, p - buf ) )
 #else
                        if ( gamedetect_check_game( "nexuiz.game", "data/common-spog.pk3", "nexuiz-linux-glx.sh", buf, p - buf ) )
@@ -179,7 +180,7 @@ bool portable_app_setup(){
        return false;
 }
 
-#if defined( POSIX )
+#if GDEF_OS_POSIX
 
 #include <stdlib.h>
 #include <pwd.h>
@@ -188,7 +189,7 @@ bool portable_app_setup(){
 #include <glib.h>
 
 const char* LINK_NAME =
-#if defined ( __linux__ )
+#if GDEF_OS_LINUX
        "/proc/self/exe"
 #else // FreeBSD and OSX
        "/proc/curproc/file"
@@ -196,7 +197,7 @@ const char* LINK_NAME =
 ;
 
 /// brief Returns the filename of the executable belonging to the current process, or 0 if not found.
-char* getexename( char *buf ){
+char const* getexename( char *buf ){
        /* Now read the symbolic link */
        int ret = readlink( LINK_NAME, buf, PATH_MAX );
 
@@ -224,7 +225,7 @@ char* getexename( char *buf ){
        return buf;
 }
 
-void environment_init( int argc, char* argv[] ){
+void environment_init( int argc, char const* argv[] ){
        // Give away unnecessary root privileges.
        // Important: must be done before calling gtk_init().
        char *loginname;
@@ -245,18 +246,18 @@ void environment_init( int argc, char* argv[] ){
 
        if ( !portable_app_setup() ) {
                StringOutputStream home( 256 );
-               home << DirectoryCleaned( g_get_home_dir() ) << ".netradiant/";
+               home << DirectoryCleaned( g_get_user_config_dir() ) << "netradiant/";
                Q_mkdir( home.c_str() );
                home_path = home.c_str();
        }
        gamedetect();
 }
 
-#elif defined( WIN32 )
+#elif GDEF_OS_WINDOWS
 
 #include <windows.h>
 
-void environment_init( int argc, char* argv[] ){
+void environment_init( int argc, char const* argv[] ){
        args_init( argc, argv );
 
        {