]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
untested changes so DP might work with this again. Who knows if they even compile.
authorRudolf Polzer <divVerent@xonotic.org>
Fri, 29 Apr 2011 08:55:57 +0000 (10:55 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Fri, 29 Apr 2011 08:55:57 +0000 (10:55 +0200)
radiant/mainframe.cpp
tools/quake3/q3map2/path_init.c

index 31f4635cd6f9315c7ec42f3b7d75df6af0f031ba..4b580bc310059de753833dd17b84475a3bcb7669 100644 (file)
@@ -189,7 +189,22 @@ void VFS_Destroy()
 #endif
 void HomePaths_Realise()
 {
-#if defined(POSIX)
+#if defined(__APPLE__)
+  const char* prefix = g_pGameDescription->getKeyValue("prefix");
+  if(!string_empty(prefix))
+  {
+    StringOutputStream path(256);
+    path << DirectoryCleaned(g_get_home_dir()) << "Library/Application Support" << (prefix+1) << "/";
+    if(!file_is_directory(path.c_str()))
+    {
+      path.clear();
+      path << DirectoryCleaned(g_get_home_dir()) << prefix << "/";
+    }
+    g_qeglobals.m_userEnginePath = path.c_str();
+    Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
+  }
+  else
+#elif defined(POSIX)
   const char* prefix = g_pGameDescription->getKeyValue("prefix");
   if(!string_empty(prefix))
   {
@@ -207,7 +222,7 @@ void HomePaths_Realise()
     TCHAR mydocsdir[MAX_PATH + 1];
     if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
     {
-      path << DirectoryCleaned(mydocsdir) << "My Games/" << prefix << "/";
+      path << DirectoryCleaned(mydocsdir) << "My Games/" << (prefix+1) << "/";
       // win32: only add it if it already exists
       if(file_is_directory(path.c_str()))
         g_qeglobals.m_userEnginePath = path.c_str();
index 501317f60767d2fb592d4e98d8be61bd8f0371a3..224a518e5f6d3c7071e00b6b8a1c63f47c6032df 100644 (file)
@@ -43,6 +43,7 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2."
 #define MAX_GAME_PATHS 10
 
 char                                   *homePath;
+qboolean                               homePathUsesDot;
 char                                   installPath[ MAX_OS_PATH ];
 
 int                                            numBasePaths;
@@ -65,8 +66,9 @@ gets the user's home dir (for ~/.q3a)
 #ifdef WIN32
 #include <shlobj.h>
 #endif
-char *LokiGetHomeDir( void )
+char *LokiGetHomeDir( qboolean *usedot )
 {
+       *usedot = qtrue;
        #ifndef Q_UNIX
                #ifndef WIN32
                        return NULL;
@@ -76,6 +78,7 @@ char *LokiGetHomeDir( void )
                        if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
                        {
                                snprintf(buf, sizeof(buf), "%s/My Games", mydocsdir);
+                               *usedot = qfalse;
                                return buf;
                        }
                        return NULL;
@@ -103,6 +106,18 @@ char *LokiGetHomeDir( void )
                        }
                        endpwent();
                }
+
+               #ifdef __APPLE__
+               {
+                       static char foo[MAX_OSPATH];
+                       snprintf(foo, sizeof(foo), "%s/Library/Application Support", home);
+                       if(access(foo, X_OK) == 0)
+                       {
+                               *usedot = qfalse;
+                               home = foo;
+                       }
+               }
+               #endif
                
                /* return it */
                return home;
@@ -125,10 +140,10 @@ void LokiInitPaths( char *argv0 )
                strcpy( installPath, "../" );
 
                /* get home dir */
-               home = LokiGetHomeDir();
+               home = LokiGetHomeDir(&homePathUsesDot);
                if( home == NULL )
                        home = ".";
-               
+
                /* set home path */
                homePath = home;
        #else
@@ -141,7 +156,7 @@ void LokiInitPaths( char *argv0 )
                
                
                /* get home dir */
-               home = LokiGetHomeDir();
+               home = LokiGetHomeDir(&homePathUsesDot);
                if( home == NULL )
                        home = ".";
                
@@ -307,7 +322,7 @@ void AddHomeBasePath( char *path )
                return;
 
        /* concatenate home dir and path */
-       sprintf( temp, "%s/%s", homePath, path );
+       sprintf( temp, "%s/%s", homePath, homePathUsesDot ? path : (path+1) );
        
 #ifdef WIN32
        {