d3dxof: Move list type and list nb elements into the parse context.

This commit is contained in:
Christian Costa 2013-05-30 23:05:39 +02:00 committed by Alexandre Julliard
parent f39547f5a8
commit 7325b798b4
3 changed files with 13 additions and 15 deletions

View File

@ -291,10 +291,9 @@ static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LP
HRESULT hr; HRESULT hr;
LPBYTE decomp_buffer = NULL; LPBYTE decomp_buffer = NULL;
ZeroMemory(&buf, sizeof(buf));
buf.buffer = pvData; buf.buffer = pvData;
buf.rem_bytes = cbSize; buf.rem_bytes = cbSize;
buf.txt = FALSE;
buf.token_present = FALSE;
buf.pdxf = This; buf.pdxf = This;
TRACE("(%p/%p)->(%p,%d)\n", This, iface, pvData, cbSize); TRACE("(%p/%p)->(%p,%d)\n", This, iface, pvData, cbSize);

View File

@ -125,6 +125,8 @@ typedef struct {
WORD current_token; WORD current_token;
BOOL token_present; BOOL token_present;
BOOL txt; BOOL txt;
DWORD list_nb_elements;
BOOL list_type_float;
ULONG cur_pos_data; ULONG cur_pos_data;
LPBYTE cur_pstrings; LPBYTE cur_pstrings;
BYTE value[100]; BYTE value[100];

View File

@ -717,10 +717,7 @@ static WORD parse_TOKEN(parse_buffer * buf)
} }
else else
{ {
static int nb_elem; if (!buf->list_nb_elements)
static int is_float;
if (!nb_elem)
{ {
if (!read_bytes(buf, &token, 2)) if (!read_bytes(buf, &token, 2))
return TOKEN_NONE; return TOKEN_NONE;
@ -728,26 +725,26 @@ static WORD parse_TOKEN(parse_buffer * buf)
/* Convert integer and float list into separate elements */ /* Convert integer and float list into separate elements */
if (token == TOKEN_INTEGER_LIST) if (token == TOKEN_INTEGER_LIST)
{ {
if (!read_bytes(buf, &nb_elem, 4)) if (!read_bytes(buf, &buf->list_nb_elements, 4))
return TOKEN_ERROR; return TOKEN_ERROR;
token = TOKEN_INTEGER; token = TOKEN_INTEGER;
is_float = FALSE; buf->list_type_float = FALSE;
TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", nb_elem); TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", buf->list_nb_elements);
} }
else if (token == TOKEN_FLOAT_LIST) else if (token == TOKEN_FLOAT_LIST)
{ {
if (!read_bytes(buf, &nb_elem, 4)) if (!read_bytes(buf, &buf->list_nb_elements, 4))
return TOKEN_ERROR; return TOKEN_ERROR;
token = TOKEN_FLOAT; token = TOKEN_FLOAT;
is_float = TRUE; buf->list_type_float = TRUE;
TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", nb_elem); TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", buf->list_nb_elements);
} }
} }
if (nb_elem) if (buf->list_nb_elements)
{ {
token = is_float ? TOKEN_FLOAT : TOKEN_INTEGER; token = buf->list_type_float ? TOKEN_FLOAT : TOKEN_INTEGER;
nb_elem--; buf->list_nb_elements--;
{ {
DWORD integer; DWORD integer;