]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
theora encoding: set VP3 compatibility mode. This SHOULD fix issues with youtube.
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 80916b0f8f323de03f006bac22890b63e4a77cf8..ec93c091cca705081e8242d86ab9bd12c0cc0b85 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1875,6 +1875,12 @@ int FS_ChooseUserDir(userdirmode_t userdirmode, char *userdir, size_t userdirsiz
        }
 #endif
 
+
+#ifdef WIN32
+       // historical behavior...
+       if (userdirmode == USERDIRMODE_NOHOME && strcmp(gamedirname1, "id1"))
+               return 0; // don't bother checking if the basedir folder is writable, it's annoying...  unless it is Quake on Windows where NOHOME is the default preferred and we have to check for an error case
+#endif
        // see if we can write to this path (note: won't create path)
 #if _MSC_VER >= 1400
        _sopen_s(&fd, va("%s%s/config.cfg", userdir, gamedirname1), O_WRONLY | O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE); // note: no O_TRUNC here!
@@ -1921,8 +1927,7 @@ void FS_Init (void)
 #ifdef DP_FS_BASEDIR
                strlcpy(fs_basedir, DP_FS_BASEDIR, sizeof(fs_basedir));
 #elif defined(MACOSX)
-               // FIXME: is there a better way to find the directory outside the .app?
-               // FIXME: check if game data is inside .app bundle
+               // FIXME: is there a better way to find the directory outside the .app, without using Objective-C?
                if (strstr(com_argv[0], ".app/"))
                {
                        char *split;
@@ -1930,9 +1935,23 @@ void FS_Init (void)
                        split = strstr(fs_basedir, ".app/");
                        if (split)
                        {
-                               while (split > fs_basedir && *split != '/')
-                                       split--;
-                               *split = 0;
+                               struct stat statresult;
+                               // truncate to just after the .app/
+                               split[5] = 0;
+                               // see if gamedir exists in Resources
+                               if (stat(va("%s/Contents/Resources/%s", fs_basedir, gamedirname1), &statresult) == 0)
+                               {
+                                       // found gamedir inside Resources, use it
+                                       strlcat(fs_basedir, "Contents/Resources/", sizeof(fs_basedir));
+                               }
+                               else
+                               {
+                                       // no gamedir found in Resources, gamedir is probably
+                                       // outside the .app, remove .app part of path
+                                       while (split > fs_basedir && *split != '/')
+                                               split--;
+                                       *split = 0;
+                               }
                        }
                }
 #endif