ref: 1ecd11222f7da8e54cd7c37d754eecb3ad7f09be
parent: 27b9f8bdac5b224615bec43cc15e758a7a6ef601
author: Simon Howard <fraggle@gmail.com>
date: Sat Sep 2 15:02:11 EDT 2006
Allow loading dehacked 2.3 patches. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 595
--- 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 @@
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 @@
// 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