shithub: choc

Download patch

ref: 6df0ab868009646160037f90e654bad0352e082f
parent: 5e162ed7e3bb7cc35446eb17aee247890b2c9909
author: Fabian Greffrath <fabian@greffrath.com>
date: Wed Apr 20 13:03:47 EDT 2016

introduce a gamevariant variable to tell different IWADs apart

Chocolate Doom supports different variants that are available of the
IWADs, e.g. for Doom 2 it supports the Vanilla IWAD, the one shipped
with the Doom 3: BFG Edition as well as Freedoom: Phase 2 and FreeDM.

Each of these IWAD variants requires some specific special-casing and
the newly introduced global "gamevariant" variable can be used to keep
track of all of this.

--- a/src/d_mode.h
+++ b/src/d_mode.h
@@ -74,6 +74,16 @@
     exe_strife_1_31  // Strife v1.31
 } GameVersion_t;
 
+// What IWAD variant are we using?
+
+typedef enum
+{
+    vanilla    = 0, // Vanilla Doom
+    freedoom   = 1, // FreeDoom: Phase 1 + 2
+    freedm     = 2, // FreeDM
+    bfgedition = 4, // Doom Classic (Doom 3: BFG Edition)
+} GameVariant_t;
+
 // Skill level.
 
 typedef enum
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -118,9 +118,6 @@
 // Store demo, do not accept any inputs
 boolean         storedemo;
 
-// "BFG Edition" version of doom2.wad does not include TITLEPIC.
-boolean         bfgedition;
-
 // If true, the main game loop has started.
 boolean         main_loop_started = false;
 
@@ -411,7 +408,7 @@
 //
 void D_DoomLoop (void)
 {
-    if (bfgedition &&
+    if (gamevariant & bfgedition &&
         (demorecording || (gameaction == ga_playdemo) || netgame))
     {
         printf(" WARNING: You are playing using one of the Doom Classic\n"
@@ -579,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 (bfgedition && !strcasecmp(pagename, "TITLEPIC")
+    if (gamevariant & bfgedition && !strcasecmp(pagename, "TITLEPIC")
         && W_CheckNumForName("titlepic") < 0)
     {
         pagename = DEH_String("INTERPIC");
@@ -812,8 +809,9 @@
 
 void D_SetGameDescription(void)
 {
-    boolean is_freedoom = W_CheckNumForName("FREEDOOM") >= 0,
-            is_freedm = W_CheckNumForName("FREEDM") >= 0;
+    gamevariant = W_CheckNumForName("FREEDOOM") >= 0 ?
+                  W_CheckNumForName("FREEDM") >= 0 ?
+                  freedoom & freedm : freedoom : vanilla;
 
     gamedescription = "Unknown";
 
@@ -821,7 +819,7 @@
     {
         // Doom 1.  But which version?
 
-        if (is_freedoom)
+        if (gamevariant & freedoom)
         {
             gamedescription = GetGameName("Freedoom: Phase 1");
         }
@@ -844,9 +842,9 @@
     {
         // Doom 2 of some kind.  But which mission?
 
-        if (is_freedoom)
+        if (gamevariant & freedoom)
         {
-            if (is_freedm)
+            if (gamevariant & freedm)
             {
                 gamedescription = GetGameName("FreeDM");
             }
@@ -1126,7 +1124,7 @@
 static void LoadIwadDeh(void)
 {
     // The Freedoom IWADs have DEHACKED lumps that must be loaded.
-    if (W_CheckNumForName("FREEDOOM") >= 0)
+    if (gamevariant & freedoom)
     {
         // Old versions of Freedoom (before 2014-09) did not have technically
         // valid DEHACKED lumps, so ignore errors and just continue if this
@@ -1448,7 +1446,7 @@
     if (W_CheckNumForName("dmenupic") >= 0)
     {
         printf("BFG Edition: Using workarounds as needed.\n");
-        bfgedition = true;
+        gamevariant = bfgedition;
 
         // BFG Edition changes the names of the secret levels to
         // censor the Wolfenstein references. It also has an extra
@@ -1635,7 +1633,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 (W_CheckNumForName("FREEDOOM") >= 0 && W_CheckNumForName("FREEDM") < 0)
+    if (gamevariant & freedoom && !(gamevariant & freedm))
     {
         printf(" WARNING: You are playing using one of the Freedoom IWAD\n"
                " files, which might not work in this port. See this page\n"
--- a/src/doom/doomstat.c
+++ b/src/doom/doomstat.c
@@ -25,6 +25,7 @@
 GameMode_t gamemode = indetermined;
 GameMission_t	gamemission = doom;
 GameVersion_t   gameversion = exe_final2;
+GameVariant_t   gamevariant = vanilla;
 char *gamedescription;
 
 // Set if homebrew PWAD stuff has been added.
--- a/src/doom/doomstat.h
+++ b/src/doom/doomstat.h
@@ -56,10 +56,8 @@
 extern GameMode_t	gamemode;
 extern GameMission_t	gamemission;
 extern GameVersion_t    gameversion;
+extern GameVariant_t    gamevariant;
 extern char            *gamedescription;
-
-// If true, we're using one of the mangled BFG edition IWADs.
-extern boolean bfgedition;
 
 // Convenience macro.
 // 'gamemission' can be equal to pack_chex or pack_hacx, but these are