* audp_parser can now only parse from a PHYSFS_file, it won't parse directly from a memory buffer anymore

* resource types ANI and ANIMCFG are now read directly from file

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1400 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-04-09 11:31:05 +00:00
parent 28fe84976e
commit 011d7187e2
6 changed files with 32 additions and 61 deletions

View File

@ -333,11 +333,11 @@ anim_SetVals( char szFileName[], UWORD uwAnimID )
/***************************************************************************/
// the playstation version uses sscanf's ... see animload.c
BASEANIM *anim_LoadFromBuffer(char *pBuffer, UDWORD size)
BASEANIM *anim_LoadFromFile(PHYSFS_file* fileHandle)
{
if ( ParseResourceBuffer( pBuffer, size ) == FALSE )
if ( ParseResourceFile( fileHandle ) == FALSE )
{
debug( LOG_ERROR, "anim_LoadFromBuffer: couldn't parse file\n" );
debug( LOG_ERROR, "anim_LoadFromFile: couldn't parse file\n" );
abort();
return NULL;
}

View File

@ -30,6 +30,8 @@
/***************************************************************************/
#include <physfs.h>
#include "lib/framework/types.h"
#include "lib/ivis_common/imd.h"
#include "maxpidef.h"
@ -129,6 +131,7 @@ ANIMGLOBALS;
BOOL anim_Init( GETSHAPEFUNC );
BOOL anim_Shutdown( void );
BASEANIM * anim_LoadFromBuffer(char *pBuffer, UDWORD size);
BASEANIM * anim_LoadFromFile(PHYSFS_file* fileHandle);
void anim_ReleaseAnim( BASEANIM *psAnim );
BOOL anim_Create3D( char szPieFileName[], UWORD uwFrames,
UWORD uwFrameRate, UWORD uwObj,

View File

@ -37,34 +37,20 @@
static BOOL g_bParsingSubFile;
static FILE *g_fpOld;
/* Pointer to the input buffer */
static char *pInputBuffer = NULL;
static char *pEndBuffer = NULL;
/* Handle to the input file */
static PHYSFS_file* pReadFile = NULL;
#define YY_INPUT(buf,result,max_size) \
if (pReadFile == NULL) \
if (PHYSFS_eof(pReadFile)) \
{ \
if (pInputBuffer != pEndBuffer) { \
buf[0] = *(pInputBuffer++); result = 1; \
} else { \
buf[0] = EOF; result = YY_NULL; \
} \
buf[0] = EOF; result = YY_NULL; \
} \
else \
{ \
if (PHYSFS_eof(pReadFile)) \
else { \
result = PHYSFS_read(pReadFile, buf, 1, max_size); \
if (result == -1) \
{ \
buf[0] = EOF; result = YY_NULL; \
} \
else { \
result = PHYSFS_read(pReadFile, buf, 1, max_size); \
if (result == -1) \
{ \
buf[0] = EOF; result = YY_NULL; \
} \
} \
}
void audp_error(char *pMessage,...);
@ -159,22 +145,12 @@ audp_wrap( void )
}
/***************************************************************************/
/* Set the current input buffer for the lexer */
/* Set the current input file for the lexer */
/***************************************************************************/
void parserSetInputBuffer(char *pBuffer, UDWORD size)
{
pInputBuffer = pBuffer;
pEndBuffer = pBuffer + size;
pReadFile = NULL;
}
void parserSetInputFile(PHYSFS_file* fileHandle)
{
pReadFile = fileHandle;
pInputBuffer = pEndBuffer = NULL;
}
/***************************************************************************/

View File

@ -226,17 +226,6 @@ void audp_error(char *pMessage,...)
/***************************************************************************/
/* Read a resource file */
BOOL ParseResourceBuffer(char *pData, UDWORD fileSize)
{
// Tell lex about the input buffer
parserSetInputBuffer( pData, fileSize );
audp_parse();
return TRUE;
}
BOOL ParseResourceFile(PHYSFS_file* fileHandle)
{
// Tell lex about the input file

View File

@ -32,9 +32,7 @@
extern void IncludeFile( char szFileName[] );
extern BOOL ParseFile( char szFileName[] );
extern void IncludeFile( char szFileName[] );
extern void parserSetInputBuffer(char *pBuffer, UDWORD size);
extern void parserSetInputFile(PHYSFS_file* fileHandle);
extern BOOL ParseResourceBuffer(char *pData, UDWORD fileSize);
extern BOOL ParseResourceFile(PHYSFS_file* fileHandle);
extern BOOL ParsingBuffer( void );
extern void parseGetErrorData(int *pLine, char **ppText);

View File

@ -1012,34 +1012,39 @@ static BOOL dataAudioCfgLoad(const char* fileName, void **ppData)
}
/* Load an anim file */
static BOOL dataAnimLoad(char *pBuffer, UDWORD size, void **ppData)
static BOOL dataAnimLoad(const char *fileName, void **ppData)
{
BASEANIM *psAnim;
if ( (psAnim = anim_LoadFromBuffer( pBuffer, size )) == NULL )
PHYSFS_file* fileHandle = PHYSFS_openRead(fileName);
if (fileHandle == NULL)
{
*ppData = NULL;
return FALSE;
}
/* copy anim for return */
*ppData = psAnim;
*ppData = anim_LoadFromFile(fileHandle);
PHYSFS_close(fileHandle);
return TRUE;
return *ppData != NULL;
}
/* Load an audio config file */
static BOOL dataAnimCfgLoad(char *pBuffer, UDWORD size, void **ppData)
static BOOL dataAnimCfgLoad(const char *fileName, void **ppData)
{
BOOL success;
PHYSFS_file* fileHandle = PHYSFS_openRead(fileName);
*ppData = NULL;
if ( ParseResourceBuffer( pBuffer, size ) == FALSE )
if (fileHandle == NULL)
{
return FALSE;
}
return TRUE;
success = ParseResourceFile(fileHandle);
PHYSFS_close(fileHandle);
return success;
}
@ -1183,8 +1188,6 @@ static const RES_TYPE_MIN_BUF BufferResourceTypes[] =
{"IMGPAGE", dataIMGPAGELoad, dataIMGPAGERelease},
{"TERTILES", NULL, NULL}, // This version was used when running with the software renderer.
{"HWTERTILES", dataHWTERTILESLoad, dataHWTERTILESRelease}, // freed by 3d shutdow},// Tertiles Files. This version used when running with hardware renderer.
{"ANI", dataAnimLoad, dataAnimRelease},
{"ANIMCFG", dataAnimCfgLoad, NULL},
{"IMG", dataIMGLoad, dataIMGRelease},
{"TEXPAGE", bufferTexPageLoad, dataTexPageRelease},
{"IMD", dataIMDBufferLoad, (RES_FREE)iV_IMDRelease},
@ -1201,6 +1204,8 @@ static const RES_TYPE_MIN_FILE FileResourceTypes[] =
{
{"WAV", dataAudioLoad, (RES_FREE)sound_ReleaseTrack},
{"AUDIOCFG", dataAudioCfgLoad, NULL},
{"ANI", dataAnimLoad, dataAnimRelease},
{"ANIMCFG", dataAnimCfgLoad, NULL},
};
/* Pass all the data loading functions to the framework library */