summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/deh_ammo.c14
-rw-r--r--src/deh_cheat.c3
-rw-r--r--src/deh_defs.h9
-rw-r--r--src/deh_frame.c13
-rw-r--r--src/deh_main.c20
-rw-r--r--src/deh_main.h4
-rw-r--r--src/deh_mapping.c48
-rw-r--r--src/deh_mapping.h5
-rw-r--r--src/deh_misc.c13
-rw-r--r--src/deh_ptr.c28
-rw-r--r--src/deh_sound.c3
-rw-r--r--src/deh_text.c3
-rw-r--r--src/deh_thing.c13
-rw-r--r--src/deh_weapon.c13
15 files changed, 174 insertions, 17 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index f2a635e6..06839d71 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -71,6 +71,7 @@ m_cheat.c m_cheat.h \
m_fixed.c m_fixed.h \
m_menu.c m_menu.h \
m_misc.c m_misc.h \
+md5.c md5.h \
memio.c memio.h \
mus2mid.c mus2mid.h \
m_random.c m_random.h \
@@ -125,6 +126,7 @@ st_stuff.c st_stuff.h \
tables.c tables.h \
v_video.c v_video.h \
wi_stuff.c wi_stuff.h \
+w_checksum.c w_checksum.h \
w_merge.c w_merge.h \
w_wad.c w_wad.h \
z_zone.c z_zone.h
diff --git a/src/deh_ammo.c b/src/deh_ammo.c
index 7709894f..a6ecf52c 100644
--- a/src/deh_ammo.c
+++ b/src/deh_ammo.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_ammo.c 175 2005-10-08 20:54:16Z fraggle $
+// $Id: deh_ammo.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -106,6 +106,17 @@ static void DEH_AmmoParseLine(deh_context_t *context, char *line, void *tag)
}
}
+static void DEH_AmmoMD5Hash(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<NUMAMMO; ++i)
+ {
+ MD5_UpdateInt32(context, clipammo[i]);
+ MD5_UpdateInt32(context, maxammo[i]);
+ }
+}
+
deh_section_t deh_section_ammo =
{
"Ammo",
@@ -113,5 +124,6 @@ deh_section_t deh_section_ammo =
DEH_AmmoStart,
DEH_AmmoParseLine,
NULL,
+ DEH_AmmoMD5Hash,
};
diff --git a/src/deh_cheat.c b/src/deh_cheat.c
index a5fe2cde..68d4ce88 100644
--- a/src/deh_cheat.c
+++ b/src/deh_cheat.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_cheat.c 641 2006-09-21 11:13:28Z rtc_marine $
+// $Id: deh_cheat.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -138,5 +138,6 @@ deh_section_t deh_section_cheat =
DEH_CheatStart,
DEH_CheatParseLine,
NULL,
+ NULL,
};
diff --git a/src/deh_defs.h b/src/deh_defs.h
index c31893a7..072032cf 100644
--- a/src/deh_defs.h
+++ b/src/deh_defs.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_defs.h 153 2005-10-02 23:49:01Z fraggle $
+// $Id: deh_defs.h 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -34,12 +34,15 @@
#ifndef DEH_DEFS_H
#define DEH_DEFS_H
+#include "md5.h"
+
typedef struct deh_context_s deh_context_t;
typedef struct deh_section_s deh_section_t;
typedef void (*deh_section_init_t)(void);
typedef void *(*deh_section_start_t)(deh_context_t *context, char *line);
typedef void (*deh_section_end_t)(deh_context_t *context, void *tag);
typedef void (*deh_line_parser_t)(deh_context_t *context, char *line, void *tag);
+typedef void (*deh_md5_hash_t)(md5_context_t *context);
struct deh_section_s
{
@@ -61,6 +64,10 @@ struct deh_section_s
// This is called at the end of the section for any cleanup
deh_section_end_t end;
+
+ // Called when generating an MD5 sum of the dehacked state
+
+ deh_md5_hash_t md5_hash;
};
#endif /* #ifndef DEH_DEFS_H */
diff --git a/src/deh_frame.c b/src/deh_frame.c
index 4a11fd75..1c46f44d 100644
--- a/src/deh_frame.c
+++ b/src/deh_frame.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_frame.c 420 2006-03-15 18:53:06Z fraggle $
+// $Id: deh_frame.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -118,6 +118,16 @@ static void DEH_FrameParseLine(deh_context_t *context, char *line, void *tag)
DEH_SetMapping(context, &state_mapping, state, variable_name, ivalue);
}
+static void DEH_FrameMD5Sum(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<NUMSTATES; ++i)
+ {
+ DEH_StructMD5Sum(context, &state_mapping, &states[i]);
+ }
+}
+
deh_section_t deh_section_frame =
{
"Frame",
@@ -125,5 +135,6 @@ deh_section_t deh_section_frame =
DEH_FrameStart,
DEH_FrameParseLine,
NULL,
+ DEH_FrameMD5Sum,
};
diff --git a/src/deh_main.c b/src/deh_main.c
index b3e77426..b7c59316 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_main.c 641 2006-09-21 11:13:28Z rtc_marine $
+// $Id: deh_main.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -113,6 +113,24 @@ static deh_section_t *section_types[] =
static int num_section_types = sizeof(section_types) / sizeof(*section_types);
+void DEH_Checksum(byte digest[16])
+{
+ md5_context_t md5_context;
+ int i;
+
+ MD5_Init(&md5_context);
+
+ for (i=0; i<num_section_types; ++i)
+ {
+ if (section_types[i]->md5_hash != NULL)
+ {
+ section_types[i]->md5_hash(&md5_context);
+ }
+ }
+
+ MD5_Final(digest, &md5_context);
+}
+
// Called on startup to call the Init functions
static void InitialiseSections(void)
diff --git a/src/deh_main.h b/src/deh_main.h
index 982bb14c..ef3a51dc 100644
--- a/src/deh_main.h
+++ b/src/deh_main.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_main.h 214 2005-10-17 23:48:05Z fraggle $
+// $Id: deh_main.h 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -51,6 +51,8 @@ void DEH_Init(void);
boolean DEH_ParseAssignment(char *line, char **variable_name, char **value);
+void DEH_Checksum(byte digest[16]);
+
// deh_text.c:
//
// Used to do dehacked text substitutions throughout the program
diff --git a/src/deh_mapping.c b/src/deh_mapping.c
index 04316f0f..a8e242d7 100644
--- a/src/deh_mapping.c
+++ b/src/deh_mapping.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_mapping.c 175 2005-10-08 20:54:16Z fraggle $
+// $Id: deh_mapping.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -44,6 +44,7 @@
#include <stdlib.h>
#include <string.h>
+#include "i_system.h"
#include "deh_mapping.h"
//
@@ -85,9 +86,6 @@ boolean DEH_SetMapping(deh_context_t *context, deh_mapping_t *mapping,
case 4:
* ((unsigned int *) location) = value;
break;
- case 8:
- * ((unsigned long long *) location) = value;
- break;
default:
DEH_Error(context, "Unknown field type for '%s' (BUG)", name);
return false;
@@ -104,3 +102,45 @@ boolean DEH_SetMapping(deh_context_t *context, deh_mapping_t *mapping,
return false;
}
+void DEH_StructMD5Sum(md5_context_t *context, deh_mapping_t *mapping,
+ void *structptr)
+{
+ int i;
+
+ // Go through each mapping
+
+ for (i=0; mapping->entries[i].name != NULL; ++i)
+ {
+ deh_mapping_entry_t *entry = &mapping->entries[i];
+ void *location;
+
+ if (entry->location == NULL)
+ {
+ // Unsupported field
+
+ continue;
+ }
+
+ // Add in data for this field
+
+ location = structptr + (entry->location - mapping->base);
+
+ switch (entry->size)
+ {
+ case 1:
+ MD5_UpdateInt32(context, *((unsigned char *) location));
+ break;
+ case 2:
+ MD5_UpdateInt32(context, *((unsigned short *) location));
+ break;
+ case 4:
+ MD5_UpdateInt32(context, *((unsigned int *) location));
+ break;
+ default:
+ I_Error("Unknown dehacked mapping field type for '%s' (BUG)",
+ entry->name);
+ break;
+ }
+ }
+}
+
diff --git a/src/deh_mapping.h b/src/deh_mapping.h
index e3521e40..6644ba46 100644
--- a/src/deh_mapping.h
+++ b/src/deh_mapping.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_mapping.h 420 2006-03-15 18:53:06Z fraggle $
+// $Id: deh_mapping.h 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -45,6 +45,7 @@
#include "doomtype.h"
#include "deh_io.h"
+#include "md5.h"
#define DEH_BEGIN_MAPPING(mapping_name, structname) \
static structname deh_mapping_base; \
@@ -96,6 +97,8 @@ struct deh_mapping_s
boolean DEH_SetMapping(deh_context_t *context, deh_mapping_t *mapping,
void *structptr, char *name, int value);
+void DEH_StructMD5Sum(md5_context_t *context, deh_mapping_t *mapping,
+ void *structptr);
#endif /* #ifndef DEH_MAPPING_H */
diff --git a/src/deh_misc.c b/src/deh_misc.c
index b89ad429..a00057ff 100644
--- a/src/deh_misc.c
+++ b/src/deh_misc.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_misc.c 641 2006-09-21 11:13:28Z rtc_marine $
+// $Id: deh_misc.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -253,6 +253,16 @@ static void DEH_MiscParseLine(deh_context_t *context, char *line, void *tag)
DEH_Warning(context, "Unknown Misc variable '%s'", variable_name);
}
+static void DEH_MiscMD5Sum(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<sizeof(misc_settings) / sizeof(*misc_settings); ++i)
+ {
+ MD5_UpdateInt32(context, *misc_settings[i].value);
+ }
+}
+
deh_section_t deh_section_misc =
{
"Misc",
@@ -260,5 +270,6 @@ deh_section_t deh_section_misc =
DEH_MiscStart,
DEH_MiscParseLine,
NULL,
+ DEH_MiscMD5Sum,
};
diff --git a/src/deh_ptr.c b/src/deh_ptr.c
index bb0757b9..4ee75657 100644
--- a/src/deh_ptr.c
+++ b/src/deh_ptr.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_ptr.c 175 2005-10-08 20:54:16Z fraggle $
+// $Id: deh_ptr.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -54,6 +54,21 @@
static actionf_t codeptrs[NUMSTATES];
+static int CodePointerIndex(actionf_t *ptr)
+{
+ int i;
+
+ for (i=0; i<NUMSTATES; ++i)
+ {
+ if (!memcmp(&codeptrs[i], ptr, sizeof(actionf_t)))
+ {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
static void DEH_PointerInit(void)
{
int i;
@@ -131,6 +146,16 @@ static void DEH_PointerParseLine(deh_context_t *context, char *line, void *tag)
}
}
+static void DEH_PointerMD5Sum(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<NUMSTATES; ++i)
+ {
+ MD5_UpdateInt32(context, CodePointerIndex(&states[i].action));
+ }
+}
+
deh_section_t deh_section_pointer =
{
"Pointer",
@@ -138,5 +163,6 @@ deh_section_t deh_section_pointer =
DEH_PointerStart,
DEH_PointerParseLine,
NULL,
+ DEH_PointerMD5Sum,
};
diff --git a/src/deh_sound.c b/src/deh_sound.c
index 7a81ec1d..009187f6 100644
--- a/src/deh_sound.c
+++ b/src/deh_sound.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_sound.c 420 2006-03-15 18:53:06Z fraggle $
+// $Id: deh_sound.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -117,5 +117,6 @@ deh_section_t deh_section_sound =
DEH_SoundStart,
DEH_SoundParseLine,
NULL,
+ NULL,
};
diff --git a/src/deh_text.c b/src/deh_text.c
index 3ba44031..0567cd9a 100644
--- a/src/deh_text.c
+++ b/src/deh_text.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_text.c 580 2006-08-31 18:12:43Z fraggle $
+// $Id: deh_text.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -267,5 +267,6 @@ deh_section_t deh_section_text =
DEH_TextStart,
DEH_TextParseLine,
NULL,
+ NULL,
};
diff --git a/src/deh_thing.c b/src/deh_thing.c
index 3c6457aa..ad2a15be 100644
--- a/src/deh_thing.c
+++ b/src/deh_thing.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_thing.c 188 2005-10-09 23:52:28Z fraggle $
+// $Id: deh_thing.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -139,6 +139,16 @@ static void DEH_ThingParseLine(deh_context_t *context, char *line, void *tag)
DEH_SetMapping(context, &thing_mapping, mobj, variable_name, ivalue);
}
+static void DEH_ThingMD5Sum(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<NUMMOBJTYPES; ++i)
+ {
+ DEH_StructMD5Sum(context, &thing_mapping, &mobjinfo[i]);
+ }
+}
+
deh_section_t deh_section_thing =
{
"Thing",
@@ -146,5 +156,6 @@ deh_section_t deh_section_thing =
DEH_ThingStart,
DEH_ThingParseLine,
NULL,
+ DEH_ThingMD5Sum,
};
diff --git a/src/deh_weapon.c b/src/deh_weapon.c
index 26cd29ad..af3f3ced 100644
--- a/src/deh_weapon.c
+++ b/src/deh_weapon.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_weapon.c 175 2005-10-08 20:54:16Z fraggle $
+// $Id: deh_weapon.c 687 2006-10-05 22:12:22Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -108,6 +108,16 @@ static void DEH_WeaponParseLine(deh_context_t *context, char *line, void *tag)
DEH_SetMapping(context, &weapon_mapping, weapon, variable_name, ivalue);
}
+static void DEH_WeaponMD5Sum(md5_context_t *context)
+{
+ int i;
+
+ for (i=0; i<NUMWEAPONS ;++i)
+ {
+ DEH_StructMD5Sum(context, &weapon_mapping, &weaponinfo[i]);
+ }
+}
+
deh_section_t deh_section_weapon =
{
"Weapon",
@@ -115,5 +125,6 @@ deh_section_t deh_section_weapon =
DEH_WeaponStart,
DEH_WeaponParseLine,
NULL,
+ DEH_WeaponMD5Sum,
};