From 53ba7baf5191bb16ccfaa2aafd81f11cb210ecca Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 18 Apr 2010 14:51:28 +0000 Subject: 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 --- src/heretic/deh_htic.c | 38 +++++++++++++++++++++++++++++--------- src/heretic/deh_htic.h | 13 +++++++++++++ 2 files changed, 42 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/heretic/deh_htic.c b/src/heretic/deh_htic.c index 59c426ef..ff5d02ac 100644 --- a/src/heretic/deh_htic.c +++ b/src/heretic/deh_htic.c @@ -27,6 +27,7 @@ #include #include "deh_defs.h" #include "deh_main.h" +#include "deh_htic.h" #include "info.h" char *deh_signatures[] = @@ -36,6 +37,10 @@ char *deh_signatures[] = 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 @@ deh_section_t *deh_section_types[] = 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; diff --git a/src/heretic/deh_htic.h b/src/heretic/deh_htic.h index fefcf818..199ad2fe 100644 --- 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. @@ -41,5 +52,7 @@ int DEH_MapHereticFrameNumber(int frame); +extern deh_hhe_version_t deh_hhe_version; + #endif /* #ifndef DEH_HTIC_H */ -- cgit v1.2.3