ref: 53ba7baf5191bb16ccfaa2aafd81f11cb210ecca
parent: d76bed743c72bfccf5cbbc18dcd9cdb1e75935b3
author: Simon Howard <fraggle@gmail.com>
date: Sun Apr 18 10:51:28 EDT 2010
Add deh_hhe_version variable to specify version of executable used to generate HHE patch. Refine DEH_MapHereticFrameNumber based on patch version. Subversion-branch: /branches/raven-branch Subversion-revision: 1895
--- a/src/heretic/deh_htic.c
+++ b/src/heretic/deh_htic.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include "deh_defs.h"
#include "deh_main.h"
+#include "deh_htic.h"
#include "info.h"
char *deh_signatures[] =
@@ -36,6 +37,10 @@
NULL
};
+// Version number for patches.
+
+deh_hhe_version_t deh_hhe_version = deh_hhe_1_0;
+
// deh_ammo.c:
extern deh_section_t deh_section_ammo;
// deh_frame.c:
@@ -67,18 +72,33 @@
NULL
};
-// HHE only worked with Heretic 1.0 and unfortunately was never updated
-// to support Heretic 1.3. Between Heretic 1.0 and 1.3, two new frames
-// were added to the "states" table, to extend the "flame death"
-// animation displayed when the player is killed by fire. Therefore,
-// we must map the HHE frame numbers (which assume a Heretic 1.0 frame
-// table) to corresponding indexes for the Heretic 1.3 frame table.
-
int DEH_MapHereticFrameNumber(int frame)
{
- if (frame >= S_PLAY_FDTH19)
+ if (deh_hhe_version < deh_hhe_1_0)
{
- frame = (frame - S_PLAY_FDTH19) + S_BLOODYSKULL1;
+ // Between Heretic 1.0 and 1.2, two new frames
+ // were added to the "states" table, to extend the "flame death"
+ // animation displayed when the player is killed by fire. Therefore,
+ // we must map Heretic 1.0 frame numbers to corresponding indexes
+ // for our state table.
+
+ if (frame >= S_PLAY_FDTH19)
+ {
+ frame = (frame - S_PLAY_FDTH19) + S_BLOODYSKULL1;
+ }
+ }
+ else
+ {
+ // After Heretic 1.2, three unused frames were removed from the
+ // states table, unused phoenix rod frames. Our state table includes
+ // these missing states for backwards compatibility. We must therefore
+ // adjust frame numbers for v1.2/v1.3 to corresponding indexes for
+ // our state table.
+
+ if (frame >= S_PHOENIXFXIX_1)
+ {
+ frame = (frame - S_PHOENIXFXIX_1) + S_PHOENIXPUFF1;
+ }
}
return frame;
--- a/src/heretic/deh_htic.h
+++ b/src/heretic/deh_htic.h
@@ -29,6 +29,17 @@
#include "info.h"
+// HHE executable version. Loading HHE patches is (unfortunately)
+// dependent on the version of the Heretic executable used to make them.
+
+typedef enum
+{
+ deh_hhe_1_0,
+ deh_hhe_1_2,
+ deh_hhe_1_3,
+ deh_hhe_num_versions
+} deh_hhe_version_t;
+
// HHE doesn't know about the last two states in the state table, so
// these are considered invalid.
@@ -40,6 +51,8 @@
#define DEH_HERETIC_NUMMOBJTYPES (NUMMOBJTYPES - 2)
int DEH_MapHereticFrameNumber(int frame);
+
+extern deh_hhe_version_t deh_hhe_version;
#endif /* #ifndef DEH_HTIC_H */