shithub: choc

Download patch

ref: 79f8427436cf2da7de710e9046f2e01dc6c8b17e
parent: dc57eb0844fea8fd444281453b25f43ab7007a22
author: Fabian Greffrath <[email protected]>
date: Mon Feb 24 02:20:49 EST 2014

More robust checks for BFG Edition.

1) Move the check for (bfgedition) right behind loading the IWAD, i.e.
   before any PWADs are loaded that could probably provide a DMENUPIC lump.
2) Instead of checking for a missing TITLEPIC lump (which is only true
   for the doom2.wad shipped with the BFG Edition) check for the presence
   of DMENUPIC (which is exclusive to both classic IWADs shipped with the
   BFG Edition). The M_GDHIGH lumps, however, are incompatibly modified
   in *both* IWADs.
3) Move the check for the missing TITLEPIC lump to the place where it
   becomes actually crucial, i.e. D_DoAdvanceDemo() and make it independent
   of the (bfgedition) check. So, PWADs still have a chance to provide their
   own TITLEPIC lump.

--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -576,9 +576,9 @@
 
     // The Doom 3: BFG Edition version of doom2.wad does not have a
     // TITLETPIC lump. Use INTERPIC instead as a workaround.
-    if (bfgedition && !strcasecmp(pagename, "TITLEPIC"))
+    if (!strcasecmp(pagename, "TITLEPIC") && W_CheckNumForName("titlepic") < 0)
     {
-        pagename = "INTERPIC";
+        pagename = DEH_String("INTERPIC");
     }
 }
 
@@ -1278,6 +1278,31 @@
 
     DEH_printf("W_Init: Init WADfiles.\n");
     D_AddFile(iwadfile);
+
+    // Doom 3: BFG Edition includes modified versions of the classic
+    // IWADs which can be identified by an additional DMENUPIC lump.
+    // Furthermore, the M_GDHIGH lumps have been modified in a way that
+    // makes them incompatible to Vanilla Doom and the modified version
+    // of doom2.wad is missing the TITLEPIC lump.
+    // We specifically check for DMENUPIC here, before PWADs have been
+    // loaded which could probably include a lump of that name.
+
+    if (W_CheckNumForName("dmenupic") >= 0)
+    {
+        printf("BFG Edition: Using workarounds as needed.\n");
+        bfgedition = true;
+
+        // BFG Edition changes the names of the secret levels to
+        // censor the Wolfenstein references. It also has an extra
+        // secret level (MAP33). In Vanilla Doom (meaning the DOS
+        // version), MAP33 overflows into the Plutonia level names
+        // array, so HUSTR_33 is actually PHUSTR_1.
+
+        DEH_AddStringReplacement(HUSTR_31, "level 31: idkfa");
+        DEH_AddStringReplacement(HUSTR_32, "level 32: keen");
+        DEH_AddStringReplacement(PHUSTR_1, "level 33: betray");
+    }
+
     modifiedgame = W_ParseCommandLine();
 
     // Debug:
@@ -1576,30 +1601,6 @@
 
     if (gamemode == commercial && W_CheckNumForName("map01") < 0)
         storedemo = true;
-
-    // Doom 3: BFG Edition includes modified versions of the classic
-    // IWADs. The modified version of doom2.wad does not have a
-    // TITLEPIC lump, so detect this so we can apply a workaround.
-    // We specifically check for TITLEPIC here, after PWADs have been
-    // loaded - this means that we can play with the BFG Edition with
-    // PWADs that change the title screen and still see the modified
-    // titles.
-
-    if (gamemode == commercial && W_CheckNumForName("titlepic") < 0)
-    {
-        printf("BFG Edition: Using INTERPIC instead of TITLEPIC.\n");
-        bfgedition = true;
-
-        // BFG Edition changes the names of the secret levels to
-        // censor the Wolfenstein references. It also has an extra
-        // secret level (MAP33). In Vanilla Doom (meaning the DOS
-        // version), MAP33 overflows into the Plutonia level names
-        // array, so HUSTR_33 is actually PHUSTR_1.
-
-        DEH_AddStringReplacement(HUSTR_31, "level 31: idkfa");
-        DEH_AddStringReplacement(HUSTR_32, "level 32: keen");
-        DEH_AddStringReplacement(PHUSTR_1, "level 33: betray");
-    }
 
     if (M_CheckParmWithArgs("-statdump", 1))
     {