shithub: choc

Download patch

ref: 21a41318650adf10187f8c3d0be6a05a40f7cb67
parent: 378857f3c826f052bed2199611e13da06bddfcd7
author: Simon Howard <fraggle@gmail.com>
date: Mon Oct 20 20:54:19 EDT 2014

doom: Add -pack parameter to specify mission pack.

The main purpose for this parameter is to allow mods made for the Final
Doom IWADs to be played properly with Freedoom. Chocolate Doom detects
mission packs (pack_tnt/pack_plut) based on the file name. However, the
Freedoom: Phase 2 IWAD contains the textures for all three Doom2-format
IWADs, so can be used to play MegaWADs like Plutonia 2 that were
designed to be played with plutonia.wad.

Because mission pack detection is done based on filename, freedoom2.wad
is handled the same as doom2.wad (a sensible default). But this means that
when playing using a mod like Plutonia 2, the wrong level name is shown
on the automap screen (along with eg. intermission text). To fix this we
need a way to manually override the mission pack. -pack allows this to
be done. It's kind of tedious that this has to be done manually but at
least it can be done.

Thanks chungy for the bug report/suggestion. This fixes #449.

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -681,6 +681,38 @@
     return gamename;
 }
 
+static void SetMissionForPackName(char *pack_name)
+{
+    int i;
+    static const struct
+    {
+        char *name;
+        int mission;
+    } packs[] = {
+        { "doom2",    doom2 },
+        { "tnt",      pack_tnt },
+        { "plutonia", pack_plut },
+    };
+
+    for (i = 0; i < arrlen(packs); ++i)
+    {
+        if (!strcasecmp(pack_name, packs[i].name))
+        {
+            gamemission = packs[i].mission;
+            return;
+        }
+    }
+
+    printf("Valid mission packs are:\n");
+
+    for (i = 0; i < arrlen(packs); ++i)
+    {
+        printf("\t%s\n", packs[i].name);
+    }
+
+    I_Error("Unknown mission pack name: %s", pack_name);
+}
+
 //
 // Find out what version of Doom is playing.
 //
@@ -742,9 +774,27 @@
     }
     else
     {
-        // Doom 2 of some kind.
+        int p;
 
+        // Doom 2 of some kind.
         gamemode = commercial;
+
+        // We can manually override the gamemission that we got from the
+        // IWAD detection code. This allows us to eg. play Plutonia 2
+        // with Freedoom and get the right level names.
+
+        //!
+        // @arg <pack>
+        //
+        // Explicitly specify a Doom II "mission pack" to run as, instead of
+        // detecting it based on the filename. Valid values are: "doom2",
+        // "tnt" and "plutonia".
+        //
+        p = M_CheckParmWithArgs("-pack", 1);
+        if (p > 0)
+        {
+            SetMissionForPackName(myargv[p + 1]);
+        }
     }
 }