shithub: choc

Download patch

ref: 78ca3a89b94dea261c88441df044709dd4ca8e7a
parent: 5f3eb6fee3165a44ca032c9642130dddb2128e1d
author: Fabian Greffrath <[email protected]>
date: Thu Sep 11 11:15:25 EDT 2014

simplify and generalize deh_allow_extended_strings usage

--- a/src/deh_io.c
+++ b/src/deh_io.c
@@ -28,7 +28,6 @@
 
 #include "deh_defs.h"
 #include "deh_io.h"
-#include "deh_main.h"
 
 typedef enum
 {
@@ -251,7 +250,7 @@
         }
 
         // extended string support
-        if (deh_allow_extended_strings && extended && c == '\\')
+        if (extended && c == '\\')
         {
             c = DEH_GetChar(context);
 
--- a/src/deh_main.c
+++ b/src/deh_main.c
@@ -88,6 +88,14 @@
 {
     unsigned int i;
 
+    // we explicitely do not recognize [STRINGS] sections at all
+    // if extended strings are not allowed
+
+    if (!deh_allow_extended_strings && !strncasecmp("[STRINGS]", name, 9))
+    {
+        return NULL;
+    }
+
     for (i=0; deh_section_types[i] != NULL; ++i)
     {
         if (!strcasecmp(deh_section_types[i]->name, name))
@@ -253,14 +261,14 @@
         DEH_Error(context, "This is not a valid dehacked patch file!");
     }
 
+    // extended string support required?
+
+    bexstr = GetSectionByName("[STRINGS]");
+
     // Read the file
     
     for (;;) 
     {
-        // extended string support required?
-
-        bexstr = GetSectionByName("[STRINGS]");
-
         // read a new line
  
         line = DEH_ReadLine(context, bexstr && current_section == bexstr);