From 6070f702fa7f25a01f30340f647fc976ec7eb345 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Sun, 8 May 2022 17:28:01 -0700 Subject: [PATCH] Add option to override save folder location The `--save-folder` command line option, or `save-folder` option in .xsys4rc, can be used to override the default save folder location. This is useful in cases where English and Japanese versions of the same game share a save location, or to isolate saves from a mod, etc. --- src/system4.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/system4.c b/src/system4.c index 4e9517c..4e34636 100644 --- a/src/system4.c +++ b/src/system4.c @@ -168,6 +168,9 @@ static void read_user_config_file(const char *path) config.manual_text_x_scale = true; config.text_x_scale = f; } + } else if (!strcmp(ini[i].name->text, "save-folder")) { + free(config.save_dir); + config.save_dir = xstrdup(ini_string(&ini[i])->text); } ini_free_entry(&ini[i]); } @@ -336,6 +339,7 @@ static void usage(void) puts(" --font-gothic Specify the path to the gothic font to use"); puts(" --font-x-scale Specify the x scale for text rendering (1.0 = default scale)"); puts(" -j, --joypad Enable joypad"); + puts(" --save-folder Override save folder location"); #ifdef DEBUGGER_ENABLED puts(" --nodebug Disable debugger"); puts(" --debug Start in debugger"); @@ -351,6 +355,7 @@ enum { LOPT_FONT_GOTHIC, LOPT_FONT_X_SCALE, LOPT_JOYPAD, + LOPT_SAVE_FOLDER, #ifdef DEBUGGER_ENABLED LOPT_NODEBUG, LOPT_DEBUG, @@ -370,6 +375,7 @@ int main(int argc, char *argv[]) char *font_mincho = NULL; char *font_gothic = NULL; char *joypad = NULL; + char *savedir = NULL; while (1) { static struct option long_options[] = { @@ -381,6 +387,7 @@ int main(int argc, char *argv[]) { "font-gothic", required_argument, 0, LOPT_FONT_GOTHIC }, { "font-x-scale", required_argument, 0, LOPT_FONT_X_SCALE }, { "joypad", optional_argument, 0, LOPT_JOYPAD }, + { "save-folder", required_argument, 0, LOPT_SAVE_FOLDER }, #ifdef DEBUGGER_ENABLED { "nodebug", no_argument, 0, LOPT_NODEBUG }, { "debug", no_argument, 0, LOPT_DEBUG }, @@ -428,6 +435,9 @@ int main(int argc, char *argv[]) case LOPT_JOYPAD: joypad = optarg ? optarg : "on"; break; + case LOPT_SAVE_FOLDER: + savedir = optarg; + break; #ifdef DEBUGGER_ENABLED case LOPT_NODEBUG: dbg_enabled = false; @@ -473,6 +483,9 @@ int main(int argc, char *argv[]) config.joypad = false; else WARNING("Invalid value for 'joypad' option (must be 'on' or 'off')"); + } if (savedir) { + free(config.save_dir); + config.save_dir = strdup(savedir); } if (!(ain = ain_open(ainfile, &err))) {