moved initializing menu design settings from hash to separate function
authorHolger Schemel <info@artsoft.org>
Sat, 12 Mar 2022 15:56:57 +0000 (16:56 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 12 Mar 2022 15:56:57 +0000 (16:56 +0100)
src/files.c
src/files.h

index 8a8f71f5ff0cd0035a53dd89ca8f2c94cc8a512b..a2efae2a1874ceacf48a4210c472ebcbe193e867 100644 (file)
@@ -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);
 }
index e32fcd80c2c82c773d35117b35e090d36057443c..cc5e2e4e100205f4dde34effd561476ab62a7567 100644 (file)
@@ -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);