shithub: choc

Download patch

ref: 8069d8a0fdf30516cb6eff6d6a9e2990061f95c1
parent: 0c0d4ed517a8a9559f96e92ef105e52eb01be1ee
author: Simon Howard <[email protected]>
date: Sun Apr 18 12:40:14 EDT 2010

Add -hhever command line parameter to select patch version number.

Subversion-branch: /branches/raven-branch
Subversion-revision: 1902

--- a/src/heretic/deh_frame.c
+++ b/src/heretic/deh_frame.c
@@ -186,17 +186,10 @@
   DEH_MAPPING("Unknown 2",        misc2)
 DEH_END_MAPPING
 
-// When a HHE patch is first loaded, we must apply a small change
-// to the states[] table.  The table was changed between 1.0 and
-// 1.3 to add two extra frames to the player "burning death"
-// animation.
-// If we are using an HHE patch, the table must behave like the
-// Heretic 1.0 table.  We must therefore change the table to cut
-// these out again.
-
 static void DEH_FrameInit(void)
 {
-    states[S_PLAY_FDTH18].nextstate = S_NULL;
+    // Bit of a hack here:
+    DEH_HereticInit();
 }
 
 static void *DEH_FrameStart(deh_context_t *context, char *line)
--- a/src/heretic/deh_htic.c
+++ b/src/heretic/deh_htic.c
@@ -24,11 +24,15 @@
 //
 //-----------------------------------------------------------------------------
 
+#include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+
 #include "deh_defs.h"
 #include "deh_main.h"
 #include "deh_htic.h"
 #include "info.h"
+#include "m_argv.h"
 
 char *deh_signatures[] =
 {
@@ -37,6 +41,11 @@
     NULL
 };
 
+static char *hhe_versions[] =
+{
+    "1.0", "1.2", "1.3"
+};
+
 // Version number for patches.
 
 deh_hhe_version_t deh_hhe_version = deh_hhe_1_0;
@@ -72,9 +81,65 @@
     NULL
 };
 
+static void SetHHEVersionByName(char *name)
+{
+    int i;
+
+    for (i=0; i<arrlen(hhe_versions); ++i)
+    {
+        if (!strcmp(hhe_versions[i], name))
+        {
+            deh_hhe_version = i;
+            return;
+        }
+    }
+
+    fprintf(stderr, "Unknown Heretic version: %s\n", name);
+    fprintf(stderr, "Valid versions:\n");
+
+    for (i=0; i<arrlen(hhe_versions); ++i)
+    {
+        fprintf(stderr, "\t%s\n", hhe_versions[i]);
+    }
+}
+
+// Initialize Heretic(HHE)-specific dehacked bits.
+
+void DEH_HereticInit(void)
+{
+    int i;
+
+    //!
+    // @arg <version>
+    //
+    // Select the Heretic version number that was used to generate the
+    // HHE patch to be loaded.  Patches for each of the Vanilla
+    // Heretic versions (1.0, 1.2, 1.3) can be loaded, but the correct
+    // version number must be specified.
+
+    i = M_CheckParm("-hhever");
+
+    if (i > 0)
+    {
+        SetHHEVersionByName(myargv[i + 1]);
+    }
+
+    // For v1.0 patches, we must apply a slight change to the states[]
+    // table.  The table was changed between 1.0 and 1.3 to add two extra
+    // frames to the player "burning death" animation.
+    //
+    // If we are using a v1.0 patch, we must change the table to cut
+    // these out again.
+
+    if (deh_hhe_version < deh_hhe_1_2)
+    {
+        states[S_PLAY_FDTH18].nextstate = S_NULL;
+    }
+}
+
 int DEH_MapHereticFrameNumber(int frame)
 {
-    if (deh_hhe_version < deh_hhe_1_0)
+    if (deh_hhe_version < deh_hhe_1_2)
     {
         // Between Heretic 1.0 and 1.2, two new frames
         // were added to the "states" table, to extend the "flame death"
--- a/src/heretic/deh_htic.h
+++ b/src/heretic/deh_htic.h
@@ -50,6 +50,7 @@
 
 #define DEH_HERETIC_NUMMOBJTYPES (NUMMOBJTYPES - 2)
 
+void DEH_HereticInit(void);
 int DEH_MapHereticFrameNumber(int frame);
 
 extern deh_hhe_version_t deh_hhe_version;