@@ -46,6 +46,7 @@ uint32_t g_sleepDelay = SLEEP;
4646constexpr const char *DEFAULT_PREFIX = " data/" ;
4747constexpr const char *DEFAULT_MAPARCH = " levels.mapz" ;
4848constexpr const char *CONF_FILE = " game.cfg" ;
49+ constexpr const char *WINDOWS_GAME_ROAMPATH = " \\ cs3-runtime" ;
4950
5051// Platform detection
5152#if defined(__APPLE__)
@@ -176,6 +177,28 @@ const std::string getPrefix()
176177#if defined(__MINGW32__)
177178#pragma message "Compiling with MinGW"
178179#include < windows.h>
180+ #include < shlobj.h>
181+ #include < iostream>
182+ #include < vector>
183+
184+ std::string GetAppDataPath ()
185+ {
186+ PWSTR path = NULL ;
187+ // Get the roaming AppData folder (C:\Users\Name\AppData\Roaming)
188+ HRESULT hr = SHGetKnownFolderPath (FOLDERID_RoamingAppData, 0 , NULL , &path);
189+
190+ if (SUCCEEDED (hr))
191+ {
192+ // Convert PWSTR (wchar_t*) to std::string
193+ std::wstring ws (path);
194+ std::string s (ws.begin (), ws.end ());
195+ CoTaskMemFree (path); // Free the memory allocated by SHGetKnownFolderPath
196+ return s;
197+ }
198+ CoTaskMemFree (path);
199+ return " " ;
200+ }
201+
179202int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
180203{
181204 std::vector<std::string> list;
@@ -220,6 +243,8 @@ int main(int argc, char *args[])
220243 return EXIT_FAILURE ;
221244 }
222245 params.workspace = path;
246+ #elif defined(__MINGW32__)
247+ params.workspace = GetAppDataPath () + WINDOWS_GAME_ROAMPATH ;
223248#elif defined(__EMSCRIPTEN__)
224249 params.workspace = " /offline/" ;
225250#endif
0 commit comments