From: Holger Schemel Date: Fri, 29 Apr 2022 23:18:45 +0000 (+0200) Subject: added reading optional platform setup file X-Git-Tag: 4.3.2.2~49 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=711a4d7c7c5fae06245617ac494b25d216875224;p=rocksndiamonds.git added reading optional platform setup file --- diff --git a/src/files.c b/src/files.c index 044dcbcc..b0e376d2 100644 --- a/src/files.c +++ b/src/files.c @@ -10838,6 +10838,12 @@ void LoadSetup_Default(void) // try to load setup values from default setup file filename = getDefaultSetupFilename(); + if (fileExists(filename)) + LoadSetupFromFilename(filename); + + // try to load setup values from platform setup file + filename = getPlatformSetupFilename(); + if (fileExists(filename)) LoadSetupFromFilename(filename); diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 0382a4d7..8da478a3 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -593,6 +593,34 @@ char *getProgramConfigFilename(char *command_filename) return config_filename_3; } +static char *getPlatformConfigFilename(char *config_filename) +{ + static char *platform_config_filename = NULL; + static boolean initialized = FALSE; + + if (!initialized) + { + char *config_basepath = getBasePath(config_filename); + char *config_basename = getBaseNameNoSuffix(config_filename); + char *config_filename_prefix = getPath2(config_basepath, config_basename); + char *platform_string_lower = getStringToLower(PLATFORM_STRING); + char *platform_suffix = getStringCat2("-", platform_string_lower); + + platform_config_filename = getStringCat3(config_filename_prefix, + platform_suffix, ".conf"); + + checked_free(config_basepath); + checked_free(config_basename); + checked_free(config_filename_prefix); + checked_free(platform_string_lower); + checked_free(platform_suffix); + + initialized = TRUE; + } + + return platform_config_filename; +} + char *getTapeFilename(int nr) { static char *filename = NULL; @@ -749,6 +777,11 @@ char *getDefaultSetupFilename(void) return program.config_filename; } +char *getPlatformSetupFilename(void) +{ + return getPlatformConfigFilename(program.config_filename); +} + char *getEditorSetupFilename(void) { static char *filename = NULL; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 1e785a95..62145bec 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -275,6 +275,7 @@ char *getScoreTapeFilename(char *, int); char *getScoreCacheTapeFilename(char *, int); char *getSetupFilename(void); char *getDefaultSetupFilename(void); +char *getPlatformSetupFilename(void); char *getEditorSetupFilename(void); char *getHelpAnimFilename(void); char *getHelpTextFilename(void);