ref: 600ac5db6bf147ab689763a672e3f2ec0a9ac6b3
parent: 3ab0057eae1f361eb3e930d5ba062d410abc53bd
author: Simon Howard <[email protected]>
date: Fri Sep 27 18:54:23 EDT 2013
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
--- a/src/heretic/deh_htic.c
+++ b/src/heretic/deh_htic.c
@@ -138,6 +138,24 @@
}
}
+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)
--- a/src/heretic/deh_htic.h
+++ b/src/heretic/deh_htic.h
@@ -51,6 +51,7 @@
#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);
--- a/src/heretic/deh_thing.c
+++ b/src/heretic/deh_thing.c
@@ -66,21 +66,24 @@
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;
}