shithub: choc

Download patch

ref: 09c8d7e8d57c84f59500e0e6a8ee0686c20a3148
parent: 436d8edbb83fd51dd75563d608b5d592f9eecece
author: Simon Howard <[email protected]>
date: Sat Oct 26 16:35:18 EDT 2013

Select fallback IWADs that match the game we are configuring (thanks
Alexandre Xavier).

Subversion-branch: /branches/v2-branch
Subversion-revision: 2719

--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -50,10 +50,14 @@
     WARP_MAPxy,
 } warptype_t;
 
-// Fallback IWAD if none are found to be installed
+// Fallback IWADs to use if no IWADs are detected.
 
-static iwad_t fallback_iwad = { "doom2.wad", doom2, commercial, "Doom II" };
-static iwad_t *fallback_iwad_list[2] = { &fallback_iwad, NULL };
+static iwad_t fallback_iwads[] = {
+    { "doom.wad",     doom,     commercial,  "Doom" },
+    { "heretic.wad",  heretic,  retail,      "Heretic" },
+    { "hexen.wad",    hexen,    commercial,  "Hexen" },
+    { "strife1.wad",  strife,   commercial,  "Strife" },
+};
 
 // Array of IWADs found to be installed
 
@@ -520,6 +524,31 @@
     UpdateSkillButton();
 }
 
+// Get an IWAD list with a default fallback IWAD that is appropriate
+// for the game we are configuring (matches gamemission global variable).
+
+static iwad_t **GetFallbackIwadList(void)
+{
+    static iwad_t *fallback_iwad_list[2];
+    unsigned int i;
+
+    // Default to use if we don't find something better.
+
+    fallback_iwad_list[0] = &fallback_iwads[0];
+    fallback_iwad_list[1] = NULL;
+
+    for (i = 0; i < arrlen(fallback_iwads); ++i)
+    {
+        if (gamemission == fallback_iwads[i].mission)
+        {
+            fallback_iwad_list[0] = &fallback_iwads[i];
+            break;
+        }
+    }
+
+    return fallback_iwad_list;
+}
+
 static txt_widget_t *IWADSelector(void)
 {
     txt_dropdown_list_t *dropdown;
@@ -528,7 +557,7 @@
     unsigned int i;
 
     // Find out what WADs are installed
-    
+
     found_iwads = GetIwads();
 
     // Build a list of the descriptions for all installed IWADs
@@ -546,7 +575,7 @@
 
     if (num_iwads == 0)
     {
-        found_iwads = fallback_iwad_list;
+        found_iwads = GetFallbackIwadList();
         num_iwads = 1;
     }