[PATCH 2/4] d3dxof: Handle float in binary mode and remove code that becomes useless.

Christian Costa titan.costa at gmail.com
Mon Jun 10 02:19:27 CDT 2013


---
 dlls/d3dxof/d3dxof_private.h |    1 +
 dlls/d3dxof/parsing.c        |   25 ++++++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/dlls/d3dxof/d3dxof_private.h b/dlls/d3dxof/d3dxof_private.h
index cf33ed2..de026f8 100644
--- a/dlls/d3dxof/d3dxof_private.h
+++ b/dlls/d3dxof/d3dxof_private.h
@@ -125,6 +125,7 @@ typedef struct {
   WORD current_token;
   BOOL token_present;
   BOOL txt;
+  BOOL parsing_template;
   DWORD list_nb_elements;
   BOOL list_type_float;
   BOOL list_separator;
diff --git a/dlls/d3dxof/parsing.c b/dlls/d3dxof/parsing.c
index 69fb992..fc43a4c 100644
--- a/dlls/d3dxof/parsing.c
+++ b/dlls/d3dxof/parsing.c
@@ -753,18 +753,10 @@ static WORD parse_TOKEN(parse_buffer * buf)
       }
       else
       {
-        DWORD value;
-
-        if (!read_bytes(buf, &value, 4))
-          return TOKEN_ERROR;
-        *(DWORD*)buf->value = value;
-
         buf->list_separator = TRUE;
         /* Convert list into a serie of their basic type counterpart */
         token = buf->list_type_float ? TOKEN_FLOAT : TOKEN_INTEGER;
       }
-      dump_TOKEN(token);
-      return token;
     }
 
     switch (token)
@@ -793,6 +785,19 @@ static WORD parse_TOKEN(parse_buffer * buf)
           *(DWORD*)buf->value = integer;
         }
         break;
+      case TOKEN_FLOAT:
+        /* This token is common to templates and objects but behaviours are different */
+        if (!buf->parsing_template)
+        {
+          float value;
+
+          if (!read_bytes(buf, &value, 4))
+            return TOKEN_ERROR;
+          TRACE("float = %f\n", value);
+
+          *(float*)buf->value = value;
+        }
+        break;
       case TOKEN_GUID:
         {
           char strguid[39];
@@ -842,7 +847,6 @@ static WORD parse_TOKEN(parse_buffer * buf)
       case TOKEN_TEMPLATE:
       case TOKEN_WORD:
       case TOKEN_DWORD:
-      case TOKEN_FLOAT:
       case TOKEN_DOUBLE:
       case TOKEN_CHAR:
       case TOKEN_UCHAR:
@@ -1073,6 +1077,7 @@ static BOOL parse_template(parse_buffer * buf)
 {
   if (get_TOKEN(buf) != TOKEN_TEMPLATE)
     return FALSE;
+  buf->parsing_template = TRUE;
   if (get_TOKEN(buf) != TOKEN_NAME)
     return FALSE;
   strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
@@ -1089,6 +1094,8 @@ static BOOL parse_template(parse_buffer * buf)
   TRACE("%d - %s - %s\n", buf->pdxf->nb_xtemplates, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, debugstr_guid(&buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id));
   buf->pdxf->nb_xtemplates++;
 
+  buf->parsing_template = FALSE;
+
   return TRUE;
 }
 




More information about the wine-patches mailing list