diff --git a/src/engine.c b/src/engine.c
index f993e89..4523dc9 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -22,7 +22,9 @@ along with this program. If not, see .
#include
#include
-#ifndef _WIN32
+#ifdef _WIN32
+#include
+#else
#include
#endif
@@ -197,10 +199,11 @@ void engine_setupConfigDirectory()
char dir[PATH_MAX];
#ifdef _WIN32
- // XXX: This is a bad design, but I just can't be bothered to learn
- // the Windows API so I can do this properly. If anyone wants to
- // make this point to the proper directory, be my guest!
- userHome = ".";
+ if (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, NULL, &userHome) != S_OK)
+ {
+ userHome = ".";
+ engine_warn("Could not get appdata location; using the current working directory instead.");
+ }
#else
if ((userHome = getenv("HOME")) == NULL)
userHome = getpwuid(getuid())->pw_dir;