diff options
Diffstat (limited to 'src/deh_main.c')
-rw-r--r-- | src/deh_main.c | 80 |
1 files changed, 22 insertions, 58 deletions
diff --git a/src/deh_main.c b/src/deh_main.c index e61933fa..4bb3e383 100644 --- a/src/deh_main.c +++ b/src/deh_main.c @@ -24,9 +24,11 @@ // //----------------------------------------------------------------------------- +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <ctype.h> -#include "doomdef.h" #include "doomtype.h" #include "d_iwad.h" #include "m_argv.h" @@ -35,30 +37,10 @@ #include "deh_defs.h" #include "deh_io.h" -static char *deh_signatures[] = -{ - "Patch File for DeHackEd v2.3", - "Patch File for DeHackEd v3.0", -}; - -// deh_ammo.c: -extern deh_section_t deh_section_ammo; -// deh_cheat.c: -extern deh_section_t deh_section_cheat; -// deh_frame.c: -extern deh_section_t deh_section_frame; -// deh_misc.c: -extern deh_section_t deh_section_misc; -// deh_ptr.c: -extern deh_section_t deh_section_pointer; -// deh_sound.c -extern deh_section_t deh_section_sound; -// deh_text.c: -extern deh_section_t deh_section_text; -// deh_thing.c: -extern deh_section_t deh_section_thing; -// deh_weapon.c: -extern deh_section_t deh_section_weapon; +extern deh_section_t *deh_section_types[]; +extern char *deh_signatures[]; + +static boolean deh_initialized = false; // If true, we can do long string replacements. @@ -72,23 +54,6 @@ boolean deh_allow_long_cheats = false; boolean deh_apply_cheats = true; -// -// List of section types: -// - -static deh_section_t *section_types[] = -{ - &deh_section_ammo, - &deh_section_cheat, - &deh_section_frame, - &deh_section_misc, - &deh_section_pointer, - &deh_section_sound, - &deh_section_text, - &deh_section_thing, - &deh_section_weapon, -}; - void DEH_Checksum(sha1_digest_t digest) { sha1_context_t sha1_context; @@ -96,11 +61,11 @@ void DEH_Checksum(sha1_digest_t digest) SHA1_Init(&sha1_context); - for (i=0; i<arrlen(section_types); ++i) + for (i=0; deh_section_types[i] != NULL; ++i) { - if (section_types[i]->sha1_hash != NULL) + if (deh_section_types[i]->sha1_hash != NULL) { - section_types[i]->sha1_hash(&sha1_context); + deh_section_types[i]->sha1_hash(&sha1_context); } } @@ -113,11 +78,11 @@ static void InitializeSections(void) { unsigned int i; - for (i=0; i<arrlen(section_types); ++i) + for (i=0; deh_section_types[i] != NULL; ++i) { - if (section_types[i]->init != NULL) + if (deh_section_types[i]->init != NULL) { - section_types[i]->init(); + deh_section_types[i]->init(); } } } @@ -128,11 +93,11 @@ static deh_section_t *GetSectionByName(char *name) { unsigned int i; - for (i=0; i<arrlen(section_types); ++i) + for (i=0; deh_section_types[i] != NULL; ++i) { - if (!strcasecmp(section_types[i]->name, name)) + if (!strcasecmp(deh_section_types[i]->name, name)) { - return section_types[i]; + return deh_section_types[i]; } } @@ -228,7 +193,7 @@ static boolean CheckSignatures(deh_context_t *context) // Check all signatures to see if one matches - for (i=0; i<arrlen(deh_signatures); ++i) + for (i=0; deh_signatures[i] != NULL; ++i) { if (!strcmp(deh_signatures[i], line)) { @@ -359,10 +324,11 @@ int DEH_LoadFile(char *filename) { deh_context_t *context; - // Vanilla dehacked files don't allow long string or cheat replacements. - - deh_allow_long_strings = false; - deh_allow_long_cheats = false; + if (!deh_initialized) + { + InitializeSections(); + deh_initialized = true; + } printf(" loading %s\n", filename); @@ -430,8 +396,6 @@ void DEH_Init(void) char *filename; int p; - InitializeSections(); - //! // @category mod // |