From: Holger Schemel Date: Sat, 12 Mar 2022 15:56:57 +0000 (+0100) Subject: moved initializing menu design settings from hash to separate function X-Git-Tag: 4.3.2.0~81 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f728989f9c1a683940d4cdd47965179131b21820;p=rocksndiamonds.git moved initializing menu design settings from hash to separate function --- diff --git a/src/files.c b/src/files.c index 8a8f71f5..a2efae2a 100644 --- a/src/files.c +++ b/src/files.c @@ -12250,14 +12250,18 @@ static int get_token_parameter_value(char *token, char *value_raw) return get_parameter_value(value_raw, suffix, TYPE_INTEGER); } -void InitMenuDesignSettings_Static(void) +void InitMenuDesignSettings_FromHash(SetupFileHash *setup_file_hash, + boolean ignore_defaults) { int i; - // always start with reliable default values from static default config for (i = 0; image_config_vars[i].token != NULL; i++) { - char *value = getHashEntry(image_config_hash, image_config_vars[i].token); + char *value = getHashEntry(setup_file_hash, image_config_vars[i].token); + + // (ignore definitions set to "[DEFAULT]" which are already initialized) + if (ignore_defaults && strEqual(value, ARG_DEFAULT)) + continue; if (value != NULL) *image_config_vars[i].value = @@ -12265,6 +12269,12 @@ void InitMenuDesignSettings_Static(void) } } +void InitMenuDesignSettings_Static(void) +{ + // always start with reliable default values from static default config + InitMenuDesignSettings_FromHash(image_config_hash, FALSE); +} + static void InitMenuDesignSettings_SpecialPreProcessing(void) { int i; @@ -13063,15 +13073,7 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) *menu_config_players[i].value = TRUE; // read (and overwrite with) values that may be specified in config file - for (i = 0; image_config_vars[i].token != NULL; i++) - { - char *value = getHashEntry(setup_file_hash, image_config_vars[i].token); - - // (ignore definitions set to "[DEFAULT]" which are already initialized) - if (value != NULL && !strEqual(value, ARG_DEFAULT)) - *image_config_vars[i].value = - get_token_parameter_value(image_config_vars[i].token, value); - } + InitMenuDesignSettings_FromHash(setup_file_hash, TRUE); freeSetupFileHash(setup_file_hash); } diff --git a/src/files.h b/src/files.h index e32fcd80..cc5e2e4e 100644 --- a/src/files.h +++ b/src/files.h @@ -98,6 +98,7 @@ void removeHideSetupEntry(void *); boolean hideSetupEntry(void *); void LoadCustomElementDescriptions(void); +void InitMenuDesignSettings_FromHash(SetupFileHash *, boolean); void InitMenuDesignSettings_Static(void); void LoadMenuDesignSettings(void); void LoadMenuDesignSettings_AfterGraphics(void);