]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - fs.c
fixed gfx/menuplyr handling - Draw_NewPic now flags the cachepic_t with
[xonotic/darkplaces.git] / fs.c
diff --git a/fs.c b/fs.c
index 80916b0f8f323de03f006bac22890b63e4a77cf8..d810ff541f1b6e497dc6489150dd1f38415d4c57 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1206,7 +1206,7 @@ void FS_AddGameDirectory (const char *dir)
 
        stringlistinit(&list);
        listdirectory(&list, "", dir);
-       stringlistsort(&list);
+       stringlistsort(&list, false);
 
        // add any PAK package in the directory
        for (i = 0;i < list.numstrings;i++)
@@ -1647,7 +1647,7 @@ static void FS_ListGameDirs(void)
        stringlistinit(&list);
        listdirectory(&list, va("%s/", fs_basedir), "");
        listdirectory(&list, va("%s/", fs_userdir), "");
-       stringlistsort(&list);
+       stringlistsort(&list, false);
 
        stringlistinit(&list2);
        for(i = 0; i < list.numstrings; ++i)
@@ -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
@@ -3493,7 +3512,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet)
 
        if (resultlist.numstrings)
        {
-               stringlistsort(&resultlist);
+               stringlistsort(&resultlist, true);
                numfiles = resultlist.numstrings;
                numchars = 0;
                for (resultlistindex = 0;resultlistindex < resultlist.numstrings;resultlistindex++)
@@ -3597,7 +3616,7 @@ int FS_ListDirectory(const char *pattern, int oneperline)
 static void FS_ListDirectoryCmd (const char* cmdname, int oneperline)
 {
        const char *pattern;
-       if (Cmd_Argc() > 3)
+       if (Cmd_Argc() >= 3)
        {
                Con_Printf("usage:\n%s [path/pattern]\n", cmdname);
                return;