foxygit / doom Log in
commit 7a140df7c041e1ee627bac432a345bdc3c4f6308
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Fri Nov 25 00:12:31 2016 -0500
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Fri Nov 25 00:12:31 2016 -0500

    hexen: Convert demo code to use new demo API.

    The vvHeretic bits are non-vanilla extensions and we should be able
    to disable these entirely either when recording or playing back.
---
 src/hexen/g_game.c | 54 ++++++++++++++++++++++--------------------------------
 1 file changed, 22 insertions(+), 32 deletions(-)

diff --git a/src/hexen/g_game.c b/src/hexen/g_game.c
index 7fe370f4..d1c508b8 100644
--- a/src/hexen/g_game.c
+++ b/src/hexen/g_game.c
@@ -1958,7 +1958,8 @@ void G_RecordDemo(skill_t skill, int numplayers, int episode, int map,
     // Record or playback a demo with high resolution turning.
     //

-    longtics = M_ParmExists("-longtics");
+    longtics = D_NonVanillaRecord(M_ParmExists("-longtics"),
+                                  "vvHeretic longtics demo");

     // If not recording a longtics demo, record in low res

@@ -2005,7 +2006,7 @@ void G_RecordDemo(skill_t skill, int numplayers, int episode, int map,
     //   0x02 = -nomonsters

     *demo_p = 1; // assume player one exists
-    if (respawnparm)
+    if (D_NonVanillaRecord(respawnparm, "vvHeretic -respawn header flag"))
     {
         *demo_p |= DEMOHEADER_RESPAWN;
     }
@@ -2013,7 +2014,7 @@ void G_RecordDemo(skill_t skill, int numplayers, int episode, int map,
     {
         *demo_p |= DEMOHEADER_LONGTICS;
     }
-    if (nomonsters)
+    if (D_NonVanillaRecord(nomonsters, "vvHeretic -nomonsters header flag"))
     {
         *demo_p |= DEMOHEADER_NOMONSTERS;
     }
@@ -2046,21 +2047,6 @@ void G_DeferedPlayDemo(char *name)
     gameaction = ga_playdemo;
 }

-// Returns true if the given lump number corresponds to data from a .lmp
-// file, as opposed to a WAD.
-static boolean IsDemoFile(int lumpnum)
-{
-    char *lower;
-    boolean result;
-
-    lower = M_StringDuplicate(lumpinfo[lumpnum]->wad_file->path);
-    M_ForceLowercase(lower);
-    result = M_StringEndsWith(lower, ".lmp");
-    free(lower);
-
-    return result;
-}
-
 void G_DoPlayDemo(void)
 {
     skill_t skill;
@@ -2075,20 +2061,24 @@ void G_DoPlayDemo(void)
     map = *demo_p++;

     // When recording we store some extra options inside the upper bits
-    // of the player 1 present byte; this is equivalent to what vvHeretic
-    // does. However, only recognize these bits if they are in a demo file
-    // being played manually by the user; we ignore them (as is Vanilla
-    // behavior) if they are inside a WAD file.
-    // These extra bits are a convenience feature for demo playback, not
-    // an editing extension for WAD authors.
-    if (IsDemoFile(lumpnum))
-    {
-        // Read special parameter bits: see G_RecordDemo() for details.
-        longtics = (*demo_p & DEMOHEADER_LONGTICS) != 0;
-
-        // don't overwrite arguments from the command line
-        respawnparm |= (*demo_p & DEMOHEADER_RESPAWN) != 0;
-        nomonsters |= (*demo_p & DEMOHEADER_NOMONSTERS) != 0;
+    // of the player 1 present byte. However, this is a non-vanilla extension.
+    // Note references to vvHeretic here; these are the extensions used by
+    // vvHeretic, which we're just reusing for Hexen demos too. There is no
+    // vvHexen.
+    if (D_NonVanillaPlayback((*demo_p & DEMOHEADER_LONGTICS) != 0,
+                             lumpnum, "vvHeretic longtics demo"))
+    {
+        longtics = true;
+    }
+    if (D_NonVanillaPlayback((*demo_p & DEMOHEADER_RESPAWN) != 0,
+                             lumpnum, "vvHeretic -respawn header flag"))
+    {
+        respawnparm = true;
+    }
+    if (D_NonVanillaPlayback((*demo_p & DEMOHEADER_NOMONSTERS) != 0,
+                             lumpnum, "vvHeretic -nomonsters header flag"))
+    {
+        nomonsters = true;
     }

     for (i = 0; i < maxplayers; i++)