+
+#if defined(WIN32)
+ TCHAR mydocsdir[MAX_PATH + 1];
+ wchar_t *mydocsdirw;
+ HMODULE shfolder = LoadLibrary("shfolder.dll");
+ if(shfolder)
+ qSHGetKnownFolderPath = (qSHGetKnownFolderPath_t *) GetProcAddress(shfolder, "SHGetKnownFolderPath");
+ else
+ qSHGetKnownFolderPath = NULL;
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ if(qSHGetKnownFolderPath && qSHGetKnownFolderPath(qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw) == S_OK)
+ {
+ memset(mydocsdir, 0, sizeof(mydocsdir));
+ wcstombs(mydocsdir, mydocsdirw, sizeof(mydocsdir)-1);
+ CoTaskMemFree(mydocsdirw);
+ path.clear();
+ path << DirectoryCleaned(mydocsdir) << (prefix+1) << "/";
+ if(file_is_directory(path.c_str()))
+ {
+ g_qeglobals.m_userEnginePath = path.c_str();
+ CoUninitialize();
+ FreeLibrary(shfolder);
+ break;
+ }
+ }
+ CoUninitialize();
+ if(shfolder)
+ FreeLibrary(shfolder);
+ if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
+ {
+ path.clear();
+ 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();
+ break;
+ }
+ }
+#endif
+
+#if defined(POSIX)
+ path.clear();
+ path << DirectoryCleaned(g_get_home_dir()) << prefix << "/";
+ g_qeglobals.m_userEnginePath = path.c_str();
+ break;
+#endif
+ }
+