2007-01-15 12:09:25 -08:00
|
|
|
/*
|
|
|
|
This file is part of Warzone 2100.
|
|
|
|
Copyright (C) 1999-2004 Eidos Interactive
|
2009-02-10 10:01:48 -08:00
|
|
|
Copyright (C) 2005-2009 Warzone Resurrection Project
|
2007-01-15 12:09:25 -08:00
|
|
|
|
|
|
|
Warzone 2100 is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Warzone 2100 is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Warzone 2100; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2007-06-28 10:47:08 -07:00
|
|
|
%{
|
|
|
|
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/framework/frame.h"
|
2006-09-23 10:24:55 -07:00
|
|
|
#include "lib/gamelib/parser.h"
|
2006-06-02 12:34:58 -07:00
|
|
|
#include "lib/sound/audio.h"
|
2006-09-23 10:24:55 -07:00
|
|
|
#include "lib/gamelib/anim.h"
|
2008-05-12 13:29:13 -07:00
|
|
|
#include "lib/framework/lexer_input.h"
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
static int g_iCurAnimID = 0;
|
2007-05-20 04:05:28 -07:00
|
|
|
static Vector3i vecPos, vecRot, vecScale;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-03-26 05:49:51 -07:00
|
|
|
extern int audp_lex(void);
|
|
|
|
extern int audp_lex_destroy(void);
|
2008-05-12 13:29:13 -07:00
|
|
|
extern int audp_get_lineno(void);
|
|
|
|
extern char* audp_get_text(void);
|
|
|
|
extern void audp_set_extra(YY_EXTRA_TYPE user_defined);
|
2008-03-26 05:49:51 -07:00
|
|
|
|
2008-12-04 04:58:42 -08:00
|
|
|
void yyerror(const char* fmt);
|
2005-12-02 05:22:19 -08:00
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
%}
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
%name-prefix="audp_"
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
%union {
|
|
|
|
float fval;
|
|
|
|
long ival;
|
2008-05-12 13:51:46 -07:00
|
|
|
bool bval;
|
2008-05-12 13:55:29 -07:00
|
|
|
char* sval;
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* value tokens */
|
2005-12-05 08:47:41 -08:00
|
|
|
%token <fval> FLOAT_T
|
2007-06-28 10:47:08 -07:00
|
|
|
%token <ival> INTEGER
|
2007-04-11 07:21:45 -07:00
|
|
|
%token <sval> QTEXT /* Text with double quotes surrounding it */
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2008-05-12 13:55:29 -07:00
|
|
|
%destructor {
|
2008-05-27 14:37:54 -07:00
|
|
|
#ifndef WZ_OS_WIN
|
2008-05-12 13:55:29 -07:00
|
|
|
// Force type checking by the compiler
|
|
|
|
char * const s = $$;
|
|
|
|
|
|
|
|
if (s)
|
|
|
|
free(s);
|
2008-05-27 14:37:54 -07:00
|
|
|
#endif
|
2008-05-12 13:55:29 -07:00
|
|
|
} QTEXT
|
|
|
|
|
2007-06-28 10:47:08 -07:00
|
|
|
/* keywords */
|
2008-05-12 13:51:46 -07:00
|
|
|
%token ONESHOT
|
|
|
|
%token LOOP
|
2007-06-28 10:47:08 -07:00
|
|
|
%token AUDIO
|
|
|
|
%token ANIM3DFRAMES
|
|
|
|
%token ANIM3DTRANS
|
|
|
|
%token ANIM3DFILE
|
|
|
|
%token AUDIO_MODULE
|
|
|
|
%token ANIM_MODULE
|
|
|
|
%token ANIMOBJECT
|
|
|
|
|
2008-05-12 13:51:46 -07:00
|
|
|
/* rule types */
|
|
|
|
%type <bval> looping
|
2007-06-28 10:47:08 -07:00
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
data_file: module_file | anim_file
|
|
|
|
;
|
|
|
|
|
|
|
|
module_file: module_file data_list |
|
|
|
|
data_list
|
|
|
|
;
|
|
|
|
|
|
|
|
data_list: audio_module | anim_module
|
|
|
|
;
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
audio_header: AUDIO_MODULE '{'
|
2007-06-28 10:47:08 -07:00
|
|
|
;
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
audio_module: audio_header audio_list '}' |
|
|
|
|
audio_header '}'
|
2007-06-28 10:47:08 -07:00
|
|
|
;
|
|
|
|
|
|
|
|
audio_list: audio_list audio_track |
|
|
|
|
audio_track
|
|
|
|
;
|
|
|
|
/*
|
2007-07-13 16:39:40 -07:00
|
|
|
* unsigned int audio_SetTrackVals(const char* fileName, BOOL loop, unsigned int volume, unsigned int audibleRadius)
|
2007-06-28 10:47:08 -07:00
|
|
|
*/
|
|
|
|
|
2008-05-12 13:51:46 -07:00
|
|
|
audio_track: AUDIO QTEXT looping INTEGER INTEGER
|
|
|
|
{
|
|
|
|
audio_SetTrackVals($2, $3, $4, $5);
|
2008-05-12 13:55:29 -07:00
|
|
|
free($2);
|
2008-05-12 13:51:46 -07:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
looping: LOOP
|
|
|
|
{ $$ = true; }
|
|
|
|
| ONESHOT
|
|
|
|
{ $$ = false; }
|
|
|
|
;
|
2007-06-28 10:47:08 -07:00
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
anim_module_header: ANIM_MODULE '{'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
anim_module: anim_module_header anim_file_list '}' |
|
2007-08-21 06:03:09 -07:00
|
|
|
anim_module_header anim_config_list '}'
|
2007-06-28 10:47:08 -07:00
|
|
|
/* NULL */
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_config_list: anim_config_list anim_config |
|
2007-08-21 06:03:09 -07:00
|
|
|
anim_config
|
2007-06-28 10:47:08 -07:00
|
|
|
/* NULL */
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_file_list: anim_file_list anim_file |
|
2007-08-21 06:03:09 -07:00
|
|
|
anim_file
|
2007-06-28 10:47:08 -07:00
|
|
|
/* NULL */
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_file: anim_trans | anim_frames
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_config: QTEXT INTEGER
|
|
|
|
{
|
|
|
|
g_iCurAnimID = $2;
|
|
|
|
anim_SetVals( $1, $2 );
|
2008-05-12 13:55:29 -07:00
|
|
|
free($1);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* anim_Create3D( char szAniFileName[], char szPieFileName[], UWORD uwFrames,
|
|
|
|
* UWORD uwFrameRate, UWORD uwNumObj, char cType, UWORD uwID )
|
|
|
|
*/
|
|
|
|
|
|
|
|
anim_trans: ANIM3DTRANS QTEXT INTEGER INTEGER INTEGER
|
|
|
|
{
|
|
|
|
anim_Create3D( $2, $3, $4, $5, ANIM_3D_TRANS, g_iCurAnimID );
|
2008-05-12 13:55:29 -07:00
|
|
|
free($2);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2005-12-02 05:22:19 -08:00
|
|
|
'{' anim_obj_list '}'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
g_iCurAnimID++;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_frames: ANIM3DFRAMES QTEXT INTEGER INTEGER
|
|
|
|
{
|
|
|
|
anim_Create3D( $2, $3, $4, 1, ANIM_3D_FRAMES, g_iCurAnimID );
|
2008-05-12 13:55:29 -07:00
|
|
|
free($2);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2005-12-02 05:22:19 -08:00
|
|
|
'{'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
anim_BeginScript();
|
|
|
|
}
|
2005-12-02 05:22:19 -08:00
|
|
|
anim_script '}'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
anim_EndScript();
|
|
|
|
g_iCurAnimID++;
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_obj_list: anim_obj anim_obj_list |
|
|
|
|
anim_obj
|
|
|
|
;
|
|
|
|
|
2005-12-02 05:22:19 -08:00
|
|
|
anim_obj: ANIMOBJECT INTEGER QTEXT '{'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
anim_BeginScript();
|
2008-05-12 13:55:29 -07:00
|
|
|
free($3);
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
2005-12-02 05:22:19 -08:00
|
|
|
anim_script '}'
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
|
|
|
anim_EndScript();
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_script: anim_script anim_state |
|
|
|
|
anim_state
|
|
|
|
;
|
|
|
|
|
|
|
|
anim_state: INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
|
|
|
|
{
|
|
|
|
vecPos.x = $2;
|
|
|
|
vecPos.y = $3;
|
|
|
|
vecPos.z = $4;
|
|
|
|
vecRot.x = $5;
|
|
|
|
vecRot.y = $6;
|
|
|
|
vecRot.z = $7;
|
|
|
|
vecScale.x = $8;
|
|
|
|
vecScale.y = $9;
|
|
|
|
vecScale.z = $10;
|
|
|
|
anim_AddFrameToAnim( $1, vecPos, vecRot, vecScale );
|
|
|
|
}
|
|
|
|
;
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
/* A simple error reporting routine */
|
2008-12-04 04:58:42 -08:00
|
|
|
void yyerror(const char* msg)
|
2007-06-28 10:47:08 -07:00
|
|
|
{
|
2008-12-04 04:58:42 -08:00
|
|
|
debug(LOG_ERROR, "RES file parse error:\n%s at line %d\nToken: %d, Text: '%s'\n", msg, audp_get_lineno(), audp_char, audp_get_text());
|
2007-06-28 10:47:08 -07:00
|
|
|
}
|
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
/** Read an audio properties file
|
|
|
|
*/
|
|
|
|
bool ParseResourceFile(PHYSFS_file* fileHandle)
|
2007-04-08 16:25:48 -07:00
|
|
|
{
|
2008-05-12 13:29:13 -07:00
|
|
|
bool retval;
|
|
|
|
lexerinput_t input;
|
|
|
|
input.type = LEXINPUT_PHYSFS;
|
|
|
|
input.input.physfsfile = fileHandle;
|
|
|
|
|
|
|
|
audp_set_extra(&input);
|
2007-04-08 16:25:48 -07:00
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
retval = (audp_parse() == 0);
|
2008-03-26 05:49:51 -07:00
|
|
|
audp_lex_destroy();
|
2007-04-08 16:25:48 -07:00
|
|
|
|
2008-05-12 13:29:13 -07:00
|
|
|
return retval;
|
2007-04-08 16:25:48 -07:00
|
|
|
}
|