moved code to check redefined screen positions to separate function
authorHolger Schemel <holger.schemel@virtion.de>
Sun, 3 Sep 2023 20:42:52 +0000 (22:42 +0200)
committerHolger Schemel <holger.schemel@virtion.de>
Sun, 3 Sep 2023 20:51:17 +0000 (22:51 +0200)
src/files.c

index 627cafc0ffe01e5450844a0fc13771da008b127c..c484aceed3b0499363ebea86578bacf4ea235258 100644 (file)
@@ -12345,6 +12345,30 @@ static void InitMenuDesignSettings_SpecialPostProcessing_AfterGraphics(void)
   }
 }
 
+static void InitMenuDesignSettings_PreviewPlayers_FromHash(SetupFileHash *hash)
+{
+
+  // special case: check if network and preview player positions are redefined,
+  // to compare this later against the main menu level preview being redefined
+  struct TokenIntPtrInfo menu_config_players[] =
+  {
+    { "main.network_players.x",        &menu.main.network_players.redefined    },
+    { "main.network_players.y",        &menu.main.network_players.redefined    },
+    { "main.preview_players.x",        &menu.main.preview_players.redefined    },
+    { "main.preview_players.y",        &menu.main.preview_players.redefined    },
+    { "preview.x",             &preview.redefined                      },
+    { "preview.y",             &preview.redefined                      }
+  };
+  int i;
+
+  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
+    *menu_config_players[i].value = FALSE;
+
+  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
+    if (getHashEntry(hash, menu_config_players[i].token) != NULL)
+      *menu_config_players[i].value = TRUE;
+}
+
 static void LoadMenuDesignSettingsFromFilename(char *filename)
 {
   static struct TitleFadingInfo tfi;
@@ -12686,24 +12710,8 @@ static void LoadMenuDesignSettingsFromFilename(char *filename)
     }
   }
 
-  // special case: check if network and preview player positions are redefined,
-  // to compare this later against the main menu level preview being redefined
-  struct TokenIntPtrInfo menu_config_players[] =
-  {
-    { "main.network_players.x",        &menu.main.network_players.redefined    },
-    { "main.network_players.y",        &menu.main.network_players.redefined    },
-    { "main.preview_players.x",        &menu.main.preview_players.redefined    },
-    { "main.preview_players.y",        &menu.main.preview_players.redefined    },
-    { "preview.x",             &preview.redefined                      },
-    { "preview.y",             &preview.redefined                      }
-  };
-
-  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
-    *menu_config_players[i].value = FALSE;
-
-  for (i = 0; i < ARRAY_SIZE(menu_config_players); i++)
-    if (getHashEntry(setup_file_hash, menu_config_players[i].token) != NULL)
-      *menu_config_players[i].value = TRUE;
+  // special case: check if network and preview player positions are redefined
+  InitMenuDesignSettings_PreviewPlayers_FromHash(setup_file_hash);
 
   // read (and overwrite with) values that may be specified in config file
   InitMenuDesignSettings_FromHash(setup_file_hash, TRUE);