diff --git a/src/main.c b/src/main.c index ebcb8b5d7df19fa689b0165a4ce4b90d72591aa9..3172536858efeafd0894434b3088e7c28db80b41 100644 --- a/src/main.c +++ b/src/main.c @@ -52,7 +52,7 @@ #define DEFAULT_IDLE_FPS (2) int start_xpos = -1, start_ypos = -1; - +char *override_home = NULL; int g_argc = 0; char **g_argv; SDL_Window *window = NULL; @@ -1129,6 +1129,7 @@ int main(int argc, char *argv[]) if (!strncmp(arg, "--xpos", 6)) start_xpos = strtol(argv[++i], NULL, 10); if (!strncmp(arg, "--ypos", 6)) start_ypos = strtol(argv[++i], NULL, 10); if (!strncmp(arg, "--safe-mode", 11)) safe_mode = TRUE; + if (!strncmp(arg, "--home", 6)) override_home = strdup(argv[++i]); } // Initialize display lock for thread safety. diff --git a/src/main.h b/src/main.h index 1bcedf36fb6c7fc61f3cc33e0d59d10c458cafa2..bd65d0e47f19365aea15fa3dc362dfa57eeca345 100644 --- a/src/main.h +++ b/src/main.h @@ -44,6 +44,7 @@ extern bool multitexture_active; extern long total_keyframes; extern int g_argc; extern char **g_argv; +extern char *override_home; /* Error handling */ struct lua_err_type_s { diff --git a/src/physfs.c b/src/physfs.c index 501b1ccd9fddef291d6250492d4a1c6e00df11bd..e8ae181993da4ed7b7cfce716f3ccc5bc3343a62 100644 --- a/src/physfs.c +++ b/src/physfs.c @@ -350,7 +350,10 @@ static int lua_fs_get_home_path(lua_State *L) static int lua_fs_get_user_path(lua_State *L) { - lua_pushstring(L, PHYSFS_getUserDir()); + if (override_home) + lua_pushstring(L, override_home); + else + lua_pushstring(L, PHYSFS_getUserDir()); return 1; }