foxygit / doom Log in
commit 8ede3a584620f43c0b40599308a6f3c77074f2fc
Author:     Acts 19 quiz <N/A>
AuthorDate: Fri Dec 31 11:12:43 2021 -0600
Commit:     Acts 19 quiz <N/A>
CommitDate: Fri Dec 31 11:12:43 2021 -0600

    Add detection and search for doom2f.wad and french.deh, respectively.
---
 src/d_iwad.c      |  1 +
 src/d_mode.h      |  1 +
 src/doom/d_main.c | 39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+)

diff --git a/src/d_iwad.c b/src/d_iwad.c
index cb5e6ab6..6b4380a4 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -38,6 +38,7 @@ static const iwad_t iwads[] =
     { "tnt.wad",      pack_tnt,  commercial, "Final Doom: TNT: Evilution" },
     { "doom.wad",     doom,      retail,     "Doom" },
     { "doom1.wad",    doom,      shareware,  "Doom Shareware" },
+    { "doom2f.wad",   doom2,     commercial, "Doom II: L'Enfer sur Terre" },
     { "chex.wad",     pack_chex, retail,     "Chex Quest" },
     { "hacx.wad",     pack_hacx, commercial, "Hacx" },
     { "freedoom2.wad", doom2,    commercial, "Freedoom: Phase 2" },
diff --git a/src/d_mode.h b/src/d_mode.h
index 7822a44a..df1a9991 100644
--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -82,6 +82,7 @@ typedef enum
     freedoom,   // FreeDoom: Phase 1 + 2
     freedm,     // FreeDM
     bfgedition, // Doom Classic (Doom 3: BFG Edition)
+    doom2f,     // Doom II (French)
 } GameVariant_t;

 // Skill level.
diff --git a/src/doom/d_main.c b/src/doom/d_main.c
index aa7fd7ae..a90a9098 100644
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1240,6 +1240,41 @@ static void LoadIwadDeh(void)
             I_Error("Failed to load chex.deh needed for emulating chex.exe.");
         }
     }
+
+    if (gamevariant == doom2f)
+    {
+        char *french_deh = NULL;
+        char *dirname;
+
+        // Look for french.deh in the same directory as the IWAD file.
+        dirname = M_DirName(iwadfile);
+        french_deh = M_StringJoin(dirname, DIR_SEPARATOR_S, "french.deh", NULL);
+        free(dirname);
+
+        // If the dehacked patch isn't found, try searching the WAD
+        // search path instead.  We might find it...
+        if (!M_FileExists(french_deh))
+        {
+            free(french_deh);
+            french_deh = D_FindWADByName("french.deh");
+        }
+
+        // Still not found?
+        if (french_deh == NULL)
+        {
+            I_Error("Unable to find French Doom II dehacked file\n"
+                    "(french.deh).  The dehacked file is required in order to\n"
+                    "emulate French doom2.exe correctly.  It can be found in\n"
+                    "your nearest /idgames repository mirror at:\n\n"
+                    "   utils/exe_edit/patches/french.zip");
+        }
+
+        if (!DEH_LoadFile(french_deh))
+        {
+            I_Error("Failed to load french.deh needed for emulating French\n"
+                    "doom2.exe.");
+        }
+    }
 }

 static void G_CheckDemoStatusAtExit (void)
@@ -1493,6 +1528,10 @@ void D_DoomMain (void)
     {
         gamevariant = bfgedition;
     }
+    else if (gamemission == doom2 && W_CheckNumForName("M_RDTHIS") < 0 && W_CheckNumForName("M_EPISOD") < 0 && W_CheckNumForName("M_EPI1") < 0 && W_CheckNumForName("M_EPI2") < 0 && W_CheckNumForName("M_EPI3") < 0 && W_CheckNumForName("WIOSTF") < 0 && W_CheckNumForName("WIOBJ") >= 0)
+    {
+        gamevariant = doom2f;
+    }

     //!
     // @category mod