diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 37bce584..59dfc23e 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -16,6 +16,7 @@ #include "game/game_init.h" #include "game/ingame_menu.h" #include "game/options_menu.h" +#include "pc/cliopts.h" #include "pc/configfile.h" #include "pc/controller/controller_api.h" @@ -424,7 +425,7 @@ void optmenu_toggle(void) { newcam_init_settings(); // load bettercam settings from config vars #endif controller_reconfigure(); // rebind using new config values - configfile_save(CONFIG_FILE); + configfile_save(gCLIOpts.ConfigFile); } } diff --git a/src/pc/cliopts.c b/src/pc/cliopts.c index 602de098..0baf9fdd 100644 --- a/src/pc/cliopts.c +++ b/src/pc/cliopts.c @@ -1,5 +1,6 @@ #include "cliopts.h" #include +#include struct PCCLIOptions gCLIOpts; @@ -8,6 +9,8 @@ void parse_cli_opts(int argc, char* argv[]) // Initialize options with false values. gCLIOpts.SkipIntro = 0; gCLIOpts.FullScreen = 0; + gCLIOpts.ConfigFile = malloc(31); + strncpy(gCLIOpts.ConfigFile, "sm64config.txt", strlen("sm64config.txt")); // Scan arguments for options if (argc > 1) @@ -20,6 +23,19 @@ void parse_cli_opts(int argc, char* argv[]) if (strcmp(argv[i], "--fullscreen") == 0) // Open game in fullscreen gCLIOpts.FullScreen = 1; + + if (strncmp(argv[i], "--configfile", strlen("--configfile")) == 0) + { + if (i+1 < argc) + { + if (strlen(argv[i]) > 30) { + fprintf(stderr, "Configuration file supplied has a name too long.\n"); + } else { + memset(gCLIOpts.ConfigFile, 0, 30); + strncpy(gCLIOpts.ConfigFile, argv[i+1], strlen(argv[i+1])); + } + } + } } } } \ No newline at end of file diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 8dc69e27..49b48b93 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -3,8 +3,6 @@ #include -#define CONFIG_FILE "sm64config.txt" - #define MAX_BINDS 3 #define MAX_VOLUME 127 #define VOLUME_SHIFT 7 diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 93774fe2..f0c0a08b 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -92,7 +92,7 @@ void audio_shutdown(void) { } void game_shutdown(void) { - configfile_save(CONFIG_FILE); + configfile_save(gCLIOpts.ConfigFile);; controller_shutdown(); audio_shutdown(); gfx_shutdown(); @@ -136,7 +136,7 @@ void main_func(void) { main_pool_init(pool, pool + sizeof(pool) / sizeof(pool[0])); gEffectsMemoryPool = mem_pool_init(0x4000, MEMORY_POOL_LEFT); - configfile_load(CONFIG_FILE); + configfile_load(gCLIOpts.ConfigFile); atexit(game_shutdown); #ifdef TARGET_WEB