summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Howard2006-09-02 19:02:11 +0000
committerSimon Howard2006-09-02 19:02:11 +0000
commit1ecd11222f7da8e54cd7c37d754eecb3ad7f09be (patch)
tree7713b1a7315b8aa717f67c45e2f1eafd95f951d3
parent27b9f8bdac5b224615bec43cc15e758a7a6ef601 (diff)
downloadchocolate-doom-1ecd11222f7da8e54cd7c37d754eecb3ad7f09be.tar.gz
chocolate-doom-1ecd11222f7da8e54cd7c37d754eecb3ad7f09be.tar.bz2
chocolate-doom-1ecd11222f7da8e54cd7c37d754eecb3ad7f09be.zip
Allow loading dehacked 2.3 patches.
Subversion-branch: /trunk/chocolate-doom Subversion-revision: 595
-rw-r--r--src/deh_main.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/src/deh_main.c b/src/deh_main.c
index 81eb960d..448d53fa 100644
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: deh_main.c 559 2006-06-18 22:54:48Z fraggle $
+// $Id: deh_main.c 595 2006-09-02 19:02:11Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -69,7 +69,11 @@
#include "deh_defs.h"
#include "deh_io.h"
-static char deh_signature[] = "Patch File for DeHackEd v3.0\n";
+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;
@@ -214,19 +218,31 @@ boolean DEH_ParseAssignment(char *line, char **variable_name, char **value)
return true;
}
-static boolean CheckSignature(deh_context_t *context)
+static boolean CheckSignatures(deh_context_t *context)
{
int i;
+ char *line;
+
+ // Read the first line
- for (i=0; i<strlen(deh_signature); ++i)
+ line = DEH_ReadLine(context);
+
+ if (line == NULL)
{
- int c = DEH_GetChar(context);
+ return false;
+ }
- if (c != deh_signature[i])
- return false;
+ // Check all signatures to see if one matches
+
+ for (i=0; i<sizeof(deh_signatures) / sizeof(*deh_signatures); ++i)
+ {
+ if (!strcmp(deh_signatures[i], line))
+ {
+ return true;
+ }
}
- return true;
+ return false;
}
// Parses a dehacked file by reading from the context
@@ -240,9 +256,9 @@ static void DEH_ParseContext(deh_context_t *context)
// Read the header and check it matches the signature
- if (!CheckSignature(context))
+ if (!CheckSignatures(context))
{
- DEH_Error(context, "This is not a dehacked v3.0 patch file!");
+ DEH_Error(context, "This is not a valid dehacked patch file!");
}
// Read the file