From 600ac5db6bf147ab689763a672e3f2ec0a9ac6b3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 27 Sep 2013 22:54:23 +0000 Subject: Translate HHE thing numbers according to patch exe version number, as our mobjinfo table contains an extra entry. Subversion-branch: /branches/v2-branch Subversion-revision: 2688 --- src/heretic/deh_htic.c | 18 ++++++++++++++++++ src/heretic/deh_htic.h | 1 + src/heretic/deh_thing.c | 13 ++++++++----- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'src/heretic') diff --git a/src/heretic/deh_htic.c b/src/heretic/deh_htic.c index 5a0a571e..5bd198ed 100644 --- a/src/heretic/deh_htic.c +++ b/src/heretic/deh_htic.c @@ -138,6 +138,24 @@ void DEH_HereticInit(void) } } +int DEH_MapHereticThingType(int type) +{ + // Heretic 1.0 had an extra entry in the mobjinfo table that was removed + // in later versions. This has been added back into the table for + // compatibility. However, it also means that if we're loading a patch + // for a later version, we need to translate to the index used internally. + + if (deh_hhe_version > deh_hhe_1_0) + { + if (type >= MT_PHOENIXFX_REMOVED) + { + ++type; + } + } + + return type; +} + int DEH_MapHereticFrameNumber(int frame) { if (deh_hhe_version < deh_hhe_1_2) diff --git a/src/heretic/deh_htic.h b/src/heretic/deh_htic.h index 7855da8c..26606045 100644 --- a/src/heretic/deh_htic.h +++ b/src/heretic/deh_htic.h @@ -51,6 +51,7 @@ typedef enum #define DEH_HERETIC_NUMMOBJTYPES (NUMMOBJTYPES - 2) void DEH_HereticInit(void); +int DEH_MapHereticThingType(int type); int DEH_MapHereticFrameNumber(int frame); void DEH_SuggestHereticVersion(deh_hhe_version_t version); diff --git a/src/heretic/deh_thing.c b/src/heretic/deh_thing.c index dbb239e4..63fd381e 100644 --- a/src/heretic/deh_thing.c +++ b/src/heretic/deh_thing.c @@ -66,21 +66,24 @@ DEH_END_MAPPING static void *DEH_ThingStart(deh_context_t *context, char *line) { - int thing_number = 0; + int orig_thing_number = 0, thing_number = 0; mobjinfo_t *mobj; - if (sscanf(line, "Thing %i", &thing_number) != 1) + if (sscanf(line, "Thing %i", &orig_thing_number) != 1) { DEH_Warning(context, "Parse error on section start"); return NULL; } - // HHE thing numbers are indexed from 1 - --thing_number; + // Translate to the correct thing number based on the exe version this + // patch was made for. Subtract one because HHE thing numbers are + // indexed from 1. + + thing_number = DEH_MapHereticThingType(orig_thing_number - 1); if (thing_number < 0 || thing_number >= DEH_HERETIC_NUMMOBJTYPES) { - DEH_Warning(context, "Invalid thing number: %i", thing_number); + DEH_Warning(context, "Invalid thing number: %i", orig_thing_number); return NULL; } -- cgit v1.2.3