@@ -1173,16 +1173,40 @@ void GlobalData::parseGameDataDefinition( INI* ini )
11731173
11741174 TheWritableGlobalData->m_userDataDir .clear ();
11751175
1176+ #if defined(_MSC_VER) && _MSC_VER < 1300
11761177 char temp[_MAX_PATH];
11771178 if (::SHGetSpecialFolderPath (nullptr , temp, CSIDL_PERSONAL, true ))
11781179 {
1179- if (temp[strlen (temp)- 1 ] != ' \\ ' )
1180+ if (temp[strlen (temp) - 1 ] != ' \\ ' )
11801181 strcat (temp, " \\ " );
11811182 strcat (temp, TheWritableGlobalData->m_userDataLeafName .str ());
11821183 strcat (temp, " \\ " );
11831184 CreateDirectory (temp, nullptr );
11841185 TheWritableGlobalData->m_userDataDir = temp;
11851186 }
1187+ #else
1188+ // TheSuperHackers @bugfix Mauller 20/03/2026 Fix the handling of folder redirection
1189+ // OneDrive and Group Policy folder redirection is better supported by SHGetKnownFolderPath()
1190+ PWSTR pszPath = nullptr ;
1191+ HRESULT hr = SHGetKnownFolderPath (FOLDERID_Documents, KF_FLAG_DEFAULT, nullptr , &pszPath);
1192+ if (SUCCEEDED (hr) && pszPath)
1193+ {
1194+ AsciiString myDocumentsDirectory;
1195+ myDocumentsDirectory.translate (UnicodeString (pszPath));
1196+
1197+ if (myDocumentsDirectory.getCharAt (myDocumentsDirectory.getLength () -1 ) != ' \\ ' )
1198+ myDocumentsDirectory.concat ( ' \\ ' );
1199+
1200+ myDocumentsDirectory.concat (TheWritableGlobalData->m_userDataLeafName .str ());
1201+
1202+ if (myDocumentsDirectory.getCharAt ( myDocumentsDirectory.getLength () - 1 ) != ' \\ ' )
1203+ myDocumentsDirectory.concat ( ' \\ ' );
1204+
1205+ CreateDirectory (myDocumentsDirectory.str (), nullptr );
1206+ TheWritableGlobalData->m_userDataDir = myDocumentsDirectory;
1207+ }
1208+ CoTaskMemFree (pszPath);
1209+ #endif
11861210
11871211 // override INI values with user preferences
11881212 OptionPreferences optionPref;
0 commit comments