]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
(non-ascii path) fix an Win32 API annotation, fix "mygames" folder
authorNaitLee <naitli@foxmail.com>
Mon, 10 Jul 2023 12:06:32 +0000 (20:06 +0800)
committerNaitLee <naitli@foxmail.com>
Mon, 10 Jul 2023 12:06:32 +0000 (20:06 +0800)
Signed-off-by: NaitLee <naitli@foxmail.com>
fs.c

diff --git a/fs.c b/fs.c
index a1a760632da8fc44769760d965428a82f94d2a14..90b7e7c664d2a76dcad65ade63cd5dd42456e4a5 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -442,7 +442,7 @@ static dllhandle_t zlib_dll = NULL;
 #endif
 
 #ifdef WIN32
-static HRESULT (WINAPI *qSHGetFolderPath) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPTSTR pszPath);
+static HRESULT (WINAPI *qSHGetFolderPath) (HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath);
 static dllfunction_t shfolderfuncs[] =
 {
        {"SHGetFolderPathW", (void **) &qSHGetFolderPath},
@@ -1873,7 +1873,8 @@ static int FS_ChooseUserDir(userdirmode_t userdirmode, char *userdir, size_t use
 #if _MSC_VER >= 1400
        size_t homedirwlen;
 #endif
-       TCHAR mydocsdir[MAX_PATH + 1];
+       wchar_t mydocsdirw[WSTRBUF];
+       char mydocsdir[WSTRBUF];
        wchar_t *savedgamesdirw;
        char savedgamesdir[WSTRBUF] = {0};
        int fd;
@@ -1891,8 +1892,9 @@ static int FS_ChooseUserDir(userdirmode_t userdirmode, char *userdir, size_t use
                if (!shfolder_dll)
                        Sys_LoadDependency(shfolderdllnames, &shfolder_dll, shfolderfuncs);
                mydocsdir[0] = 0;
-               if (qSHGetFolderPath && qSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir) == S_OK)
+               if (qSHGetFolderPath && qSHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdirw) == S_OK)
                {
+                       narrow(mydocsdirw, mydocsdir);
                        dpsnprintf(userdir, userdirsize, "%s/My Games/%s/", mydocsdir, gameuserdirname);
                        break;
                }