shithub: choc

Download patch

ref: ab050f0a6f70c33215e591dae3d7591d966c01dc
parent: 6df0ab868009646160037f90e654bad0352e082f
author: Fabian Greffrath <fabian@greffrath.com>
date: Fri Apr 22 02:10:43 EDT 2016

gamevariant can be either freedoom or freedm

Also, simplify the checks and set the variable earlier, i.e. before
any PWADs are loaded that could contain one of the lumps we check for.

--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -78,10 +78,10 @@
 
 typedef enum
 {
-    vanilla    = 0, // Vanilla Doom
-    freedoom   = 1, // FreeDoom: Phase 1 + 2
-    freedm     = 2, // FreeDM
-    bfgedition = 4, // Doom Classic (Doom 3: BFG Edition)
+    vanilla,    // Vanilla Doom
+    freedoom,   // FreeDoom: Phase 1 + 2
+    freedm,     // FreeDM
+    bfgedition, // Doom Classic (Doom 3: BFG Edition)
 } GameVariant_t;
 
 // Skill level.
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -408,7 +408,7 @@
 //
 void D_DoomLoop (void)
 {
-    if (gamevariant & bfgedition &&
+    if (gamevariant == bfgedition &&
         (demorecording || (gameaction == ga_playdemo) || netgame))
     {
         printf(" WARNING: You are playing using one of the Doom Classic\n"
@@ -576,7 +576,7 @@
 
     // The Doom 3: BFG Edition version of doom2.wad does not have a
     // TITLETPIC lump. Use INTERPIC instead as a workaround.
-    if (gamevariant & bfgedition && !strcasecmp(pagename, "TITLEPIC")
+    if (gamevariant == bfgedition && !strcasecmp(pagename, "TITLEPIC")
         && W_CheckNumForName("titlepic") < 0)
     {
         pagename = DEH_String("INTERPIC");
@@ -809,10 +809,6 @@
 
 void D_SetGameDescription(void)
 {
-    gamevariant = W_CheckNumForName("FREEDOOM") >= 0 ?
-                  W_CheckNumForName("FREEDM") >= 0 ?
-                  freedoom & freedm : freedoom : vanilla;
-
     gamedescription = "Unknown";
 
     if (logical_gamemission == doom)
@@ -819,7 +815,7 @@
     {
         // Doom 1.  But which version?
 
-        if (gamevariant & freedoom)
+        if (gamevariant == freedoom)
         {
             gamedescription = GetGameName("Freedoom: Phase 1");
         }
@@ -842,17 +838,14 @@
     {
         // Doom 2 of some kind.  But which mission?
 
-        if (gamevariant & freedoom)
+        if (gamevariant == freedm)
         {
-            if (gamevariant & freedm)
-            {
-                gamedescription = GetGameName("FreeDM");
-            }
-            else
-            {
-                gamedescription = GetGameName("Freedoom: Phase 2");
-            }
+            gamedescription = GetGameName("FreeDM");
         }
+        else if (gamevariant == freedoom)
+        {
+            gamedescription = GetGameName("Freedoom: Phase 2");
+        }
         else if (logical_gamemission == doom2)
         {
             gamedescription = GetGameName("DOOM 2: Hell on Earth");
@@ -1124,7 +1117,7 @@
 static void LoadIwadDeh(void)
 {
     // The Freedoom IWADs have DEHACKED lumps that must be loaded.
-    if (gamevariant & freedoom)
+    if (gamevariant == freedoom || gamevariant == freedm)
     {
         // Old versions of Freedoom (before 2014-09) did not have technically
         // valid DEHACKED lumps, so ignore errors and just continue if this
@@ -1435,6 +1428,24 @@
         LoadIwadDeh();
     }
 
+    // Check which IWAD variant we are using.
+
+    if (W_CheckNumForName("FREEDOOM") >= 0)
+    {
+        if (W_CheckNumForName("FREEDM") >= 0)
+        {
+            gamevariant = freedm;
+        }
+        else
+        {
+            gamevariant = freedoom;
+        }
+    }
+    else if (W_CheckNumForName("DMENUPIC") >= 0)
+    {
+        gamevariant = bfgedition;
+    }
+
     // 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
@@ -1443,10 +1454,9 @@
     // 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)
+    if (gamevariant == bfgedition)
     {
         printf("BFG Edition: Using workarounds as needed.\n");
-        gamevariant = bfgedition;
 
         // BFG Edition changes the names of the secret levels to
         // censor the Wolfenstein references. It also has an extra
@@ -1633,7 +1643,7 @@
     // Freedoom's IWADs are Boom-compatible, which means they usually
     // don't work in Vanilla (though FreeDM is okay). Show a warning
     // message and give a link to the website.
-    if (gamevariant & freedoom && !(gamevariant & freedm))
+    if (gamevariant == freedoom)
     {
         printf(" WARNING: You are playing using one of the Freedoom IWAD\n"
                " files, which might not work in this port. See this page\n"