Set eol-style for files missing this.
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@1143 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
9640c6a42d
commit
929c4bf2ab
|
@ -1,202 +1,202 @@
|
|||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2007 Warzone Resurrection Project
|
||||
|
||||
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
|
||||
*/
|
||||
%{
|
||||
/*
|
||||
* chat_lexer.l
|
||||
*
|
||||
* lexer for multiplayer chat messages.
|
||||
* IMPORTANT: must be compiled with -i switch (case-insensitive scanner)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "src/base.h"
|
||||
#include "src/droiddef.h"
|
||||
#include "src/structuredef.h"
|
||||
//#include "src/scriptfuncs.h"
|
||||
#include "lib/script/script.h"
|
||||
#include "src/scriptfuncs.h"
|
||||
#include "lib/script/chat_processing.h"
|
||||
|
||||
/* Get the Yacc definitions */
|
||||
#include "chat_parser.tab.h"
|
||||
|
||||
/* Maximum length for any TEXT value */
|
||||
#ifndef YYLMAX
|
||||
#define YYLMAX 255
|
||||
#endif
|
||||
|
||||
/* Store for any string values */
|
||||
static char aText[TEXT_BUFFERS][YYLMAX];
|
||||
static UDWORD currText=0;
|
||||
|
||||
/* Pointer to the input buffer */
|
||||
static char *pInputBuffer = NULL;
|
||||
static char *pEndBuffer = NULL;
|
||||
|
||||
static SDWORD playerIndex;
|
||||
static INTERP_VAL parameter;
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
if (pInputBuffer != pEndBuffer) { \
|
||||
buf[0] = *(pInputBuffer++); result = 1; \
|
||||
} else { \
|
||||
buf[0] = EOF; result = YY_NULL; \
|
||||
}
|
||||
|
||||
#undef chat_getc
|
||||
#define chat_getc() (pInputBuffer != pEndBuffer ? *(pInputBuffer++) : EOF)
|
||||
|
||||
%}
|
||||
|
||||
%option yylineno
|
||||
%option prefix="chat_"
|
||||
%option nounput
|
||||
%option case-insensitive
|
||||
|
||||
%%
|
||||
|
||||
/* Match integer numbers */
|
||||
-?[0-9]+ { chat_lval.ival = atol(chat_text); return R_INTEGER; }
|
||||
|
||||
/* Keywords - Terminals */
|
||||
"?"+ { return _T_QM; }
|
||||
"!"+ { return _T_EM; }
|
||||
"."+ { return _T_FULLSTOP; }
|
||||
":" { return _T_COLON; };
|
||||
";" { return _T_SEMICOLON; };
|
||||
"," { return _T_COMMA; };
|
||||
"a" { return _T_A; }
|
||||
"affirmative" { return _T_AFFIRMATIVE; }
|
||||
"after" { return _T_AFTER; }
|
||||
"ally" { return _T_ALLY; }
|
||||
"am" { return _T_AM; }
|
||||
"and" { return _T_AND; }
|
||||
"any" { return _T_ANY; }
|
||||
"attack" { return _T_ATTACK; }
|
||||
"attacking" { return _T_ATTACKING; }
|
||||
"beacon" { return _T_BEACON; }
|
||||
"building" { return _T_BUILDING; }
|
||||
"can't" { return _T_CANT; }
|
||||
"center" { return _T_CENTER; }
|
||||
"dead" { return _T_DEAD; }
|
||||
"derrick" { return _T_DERRICK; }
|
||||
"do" { return _T_DO; }
|
||||
"drop" { return _T_DROP; }
|
||||
"fine" { return _T_FINE; }
|
||||
"get" { return _T_GET; }
|
||||
"getting" { return _T_GETTING; }
|
||||
"go" { return _T_GO; }
|
||||
"going" { return _T_GOING; }
|
||||
"gonna" { return _T_GONNA; }
|
||||
"got" { return _T_GOT; }
|
||||
"great" { return _T_GREAT; }
|
||||
"have" { return _T_HAVE; }
|
||||
"has" { return _T_HAS; }
|
||||
"help" { return _T_HELP; }
|
||||
"i" { return _T_I; }
|
||||
"i'm" { return _T_IM; }
|
||||
"is" { return _T_IS; }
|
||||
"let's" { return _T_LETS; }
|
||||
"me" { return _T_ME; }
|
||||
"no" { return _T_NO; }
|
||||
"now" { return _T_NOW; }
|
||||
"of course" { return _T_OFCOURSE; }
|
||||
"ok"+ { return _T_OK; }
|
||||
"place" { return _T_PLACE; }
|
||||
"possession" { return _T_POSSESSION; }
|
||||
"power" { return _T_POWER; }
|
||||
"pumping" { return _T_PUMPING; }
|
||||
"put" { return _T_PUT; }
|
||||
"roger" { return _T_ROGER; }
|
||||
"see" { return _T_SEE; }
|
||||
"some" { return _T_SOME; }
|
||||
"status" { return _T_STATUS; }
|
||||
"stop" { return _T_STOP; }
|
||||
"sure" { return _T_SURE; }
|
||||
"thank you" { return _T_THANK_YOU; }
|
||||
"thanks" { return _T_THANKS; }
|
||||
"u" { return _T_U; }
|
||||
"units" { return _T_UNITS; }
|
||||
"vtols" { return _T_VTOLS; }
|
||||
"wait" { return _T_WAIT; }
|
||||
"where" { return _T_WHERE; }
|
||||
"yea" { return _T_YEA; }
|
||||
"yeah" { return _T_YEAH; }
|
||||
"yes" { return _T_YES; }
|
||||
"you" { return _T_YOU; }
|
||||
|
||||
/* <<EOF>> { return _T_EOF; } */
|
||||
|
||||
-?[0-9]+ {
|
||||
chat_lval.ival = atol(chat_text);
|
||||
return R_INTEGER;
|
||||
}
|
||||
|
||||
[0-9_a-zA-Z_]* {
|
||||
playerIndex = getPlayerFromString(chat_text);
|
||||
|
||||
if(playerIndex >= 0)
|
||||
{
|
||||
//console( "matched 'player'");
|
||||
chat_lval.ival = playerIndex;
|
||||
|
||||
return R_PLAYER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* [^ \t\n\<\>\[\]\(\)]+ { return T_WORD; } */
|
||||
/* [^ \t\n]+ { console( "matched 'T_WORD'"); return T_WORD; } */
|
||||
|
||||
|
||||
/* Skip white space */
|
||||
[ \t\n\x0d\x0a] ;
|
||||
|
||||
|
||||
/* Match anything that's been missed and pass it as a char */
|
||||
/* . {console( "matched 'anything else '%s'", chat_text[0]); return chat_text[0];} */
|
||||
|
||||
%%
|
||||
|
||||
/* Set the current input buffer for the lexer */
|
||||
void chatSetInputBuffer(char *pBuffer, UDWORD size)
|
||||
{
|
||||
pInputBuffer = pBuffer;
|
||||
pEndBuffer = pBuffer + size;
|
||||
|
||||
/* Reset the lexer in case it's been used before */
|
||||
chat__flush_buffer(YY_CURRENT_BUFFER);
|
||||
}
|
||||
|
||||
void chatGetErrorData(int *pLine, char **ppText)
|
||||
{
|
||||
*pLine = chat_lineno;
|
||||
*ppText = chat_text;
|
||||
}
|
||||
|
||||
int chat_wrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2007 Warzone Resurrection Project
|
||||
|
||||
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
|
||||
*/
|
||||
%{
|
||||
/*
|
||||
* chat_lexer.l
|
||||
*
|
||||
* lexer for multiplayer chat messages.
|
||||
* IMPORTANT: must be compiled with -i switch (case-insensitive scanner)
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "src/base.h"
|
||||
#include "src/droiddef.h"
|
||||
#include "src/structuredef.h"
|
||||
//#include "src/scriptfuncs.h"
|
||||
#include "lib/script/script.h"
|
||||
#include "src/scriptfuncs.h"
|
||||
#include "lib/script/chat_processing.h"
|
||||
|
||||
/* Get the Yacc definitions */
|
||||
#include "chat_parser.tab.h"
|
||||
|
||||
/* Maximum length for any TEXT value */
|
||||
#ifndef YYLMAX
|
||||
#define YYLMAX 255
|
||||
#endif
|
||||
|
||||
/* Store for any string values */
|
||||
static char aText[TEXT_BUFFERS][YYLMAX];
|
||||
static UDWORD currText=0;
|
||||
|
||||
/* Pointer to the input buffer */
|
||||
static char *pInputBuffer = NULL;
|
||||
static char *pEndBuffer = NULL;
|
||||
|
||||
static SDWORD playerIndex;
|
||||
static INTERP_VAL parameter;
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) \
|
||||
if (pInputBuffer != pEndBuffer) { \
|
||||
buf[0] = *(pInputBuffer++); result = 1; \
|
||||
} else { \
|
||||
buf[0] = EOF; result = YY_NULL; \
|
||||
}
|
||||
|
||||
#undef chat_getc
|
||||
#define chat_getc() (pInputBuffer != pEndBuffer ? *(pInputBuffer++) : EOF)
|
||||
|
||||
%}
|
||||
|
||||
%option yylineno
|
||||
%option prefix="chat_"
|
||||
%option nounput
|
||||
%option case-insensitive
|
||||
|
||||
%%
|
||||
|
||||
/* Match integer numbers */
|
||||
-?[0-9]+ { chat_lval.ival = atol(chat_text); return R_INTEGER; }
|
||||
|
||||
/* Keywords - Terminals */
|
||||
"?"+ { return _T_QM; }
|
||||
"!"+ { return _T_EM; }
|
||||
"."+ { return _T_FULLSTOP; }
|
||||
":" { return _T_COLON; };
|
||||
";" { return _T_SEMICOLON; };
|
||||
"," { return _T_COMMA; };
|
||||
"a" { return _T_A; }
|
||||
"affirmative" { return _T_AFFIRMATIVE; }
|
||||
"after" { return _T_AFTER; }
|
||||
"ally" { return _T_ALLY; }
|
||||
"am" { return _T_AM; }
|
||||
"and" { return _T_AND; }
|
||||
"any" { return _T_ANY; }
|
||||
"attack" { return _T_ATTACK; }
|
||||
"attacking" { return _T_ATTACKING; }
|
||||
"beacon" { return _T_BEACON; }
|
||||
"building" { return _T_BUILDING; }
|
||||
"can't" { return _T_CANT; }
|
||||
"center" { return _T_CENTER; }
|
||||
"dead" { return _T_DEAD; }
|
||||
"derrick" { return _T_DERRICK; }
|
||||
"do" { return _T_DO; }
|
||||
"drop" { return _T_DROP; }
|
||||
"fine" { return _T_FINE; }
|
||||
"get" { return _T_GET; }
|
||||
"getting" { return _T_GETTING; }
|
||||
"go" { return _T_GO; }
|
||||
"going" { return _T_GOING; }
|
||||
"gonna" { return _T_GONNA; }
|
||||
"got" { return _T_GOT; }
|
||||
"great" { return _T_GREAT; }
|
||||
"have" { return _T_HAVE; }
|
||||
"has" { return _T_HAS; }
|
||||
"help" { return _T_HELP; }
|
||||
"i" { return _T_I; }
|
||||
"i'm" { return _T_IM; }
|
||||
"is" { return _T_IS; }
|
||||
"let's" { return _T_LETS; }
|
||||
"me" { return _T_ME; }
|
||||
"no" { return _T_NO; }
|
||||
"now" { return _T_NOW; }
|
||||
"of course" { return _T_OFCOURSE; }
|
||||
"ok"+ { return _T_OK; }
|
||||
"place" { return _T_PLACE; }
|
||||
"possession" { return _T_POSSESSION; }
|
||||
"power" { return _T_POWER; }
|
||||
"pumping" { return _T_PUMPING; }
|
||||
"put" { return _T_PUT; }
|
||||
"roger" { return _T_ROGER; }
|
||||
"see" { return _T_SEE; }
|
||||
"some" { return _T_SOME; }
|
||||
"status" { return _T_STATUS; }
|
||||
"stop" { return _T_STOP; }
|
||||
"sure" { return _T_SURE; }
|
||||
"thank you" { return _T_THANK_YOU; }
|
||||
"thanks" { return _T_THANKS; }
|
||||
"u" { return _T_U; }
|
||||
"units" { return _T_UNITS; }
|
||||
"vtols" { return _T_VTOLS; }
|
||||
"wait" { return _T_WAIT; }
|
||||
"where" { return _T_WHERE; }
|
||||
"yea" { return _T_YEA; }
|
||||
"yeah" { return _T_YEAH; }
|
||||
"yes" { return _T_YES; }
|
||||
"you" { return _T_YOU; }
|
||||
|
||||
/* <<EOF>> { return _T_EOF; } */
|
||||
|
||||
-?[0-9]+ {
|
||||
chat_lval.ival = atol(chat_text);
|
||||
return R_INTEGER;
|
||||
}
|
||||
|
||||
[0-9_a-zA-Z_]* {
|
||||
playerIndex = getPlayerFromString(chat_text);
|
||||
|
||||
if(playerIndex >= 0)
|
||||
{
|
||||
//console( "matched 'player'");
|
||||
chat_lval.ival = playerIndex;
|
||||
|
||||
return R_PLAYER;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* [^ \t\n\<\>\[\]\(\)]+ { return T_WORD; } */
|
||||
/* [^ \t\n]+ { console( "matched 'T_WORD'"); return T_WORD; } */
|
||||
|
||||
|
||||
/* Skip white space */
|
||||
[ \t\n\x0d\x0a] ;
|
||||
|
||||
|
||||
/* Match anything that's been missed and pass it as a char */
|
||||
/* . {console( "matched 'anything else '%s'", chat_text[0]); return chat_text[0];} */
|
||||
|
||||
%%
|
||||
|
||||
/* Set the current input buffer for the lexer */
|
||||
void chatSetInputBuffer(char *pBuffer, UDWORD size)
|
||||
{
|
||||
pInputBuffer = pBuffer;
|
||||
pEndBuffer = pBuffer + size;
|
||||
|
||||
/* Reset the lexer in case it's been used before */
|
||||
chat__flush_buffer(YY_CURRENT_BUFFER);
|
||||
}
|
||||
|
||||
void chatGetErrorData(int *pLine, char **ppText)
|
||||
{
|
||||
*pLine = chat_lineno;
|
||||
*ppText = chat_text;
|
||||
}
|
||||
|
||||
int chat_wrap(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,77 +1,77 @@
|
|||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2007 Warzone Resurrection Project
|
||||
|
||||
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
|
||||
*/
|
||||
/*
|
||||
* chat_processing.h
|
||||
*
|
||||
* Misc definitions for chat parser
|
||||
*/
|
||||
#ifndef _chat_processing_h
|
||||
#define _chat_processing_h
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "src/base.h"
|
||||
#include "src/droiddef.h"
|
||||
#include "src/structuredef.h"
|
||||
#include "lib/script/script.h"
|
||||
|
||||
#ifndef MAXSTRLEN
|
||||
#define MAXSTRLEN 255
|
||||
#endif
|
||||
|
||||
/* Max number of commands in a player chat message */
|
||||
#define MAX_CHAT_COMMANDS 10
|
||||
|
||||
/* Max number of parameters allowed in a single chat message command */
|
||||
#define MAX_CHAT_CMD_PARAMS 10
|
||||
|
||||
|
||||
/* Holds information for each recognized
|
||||
* command in a chat message */
|
||||
typedef struct _chat_command_data
|
||||
{
|
||||
char *pCmdDescription; /* String representing a certain command */
|
||||
BOOL bPlayerAddressed[MAX_PLAYERS]; /* Flag to indicate whether a command was addressed to a certain player */
|
||||
SDWORD numCmdParams; /* Number of extracted parameters associated with each command */
|
||||
INTERP_VAL parameter[MAX_CHAT_CMD_PARAMS]; /* Parameters extracted from text - to be used with scripts */
|
||||
}CHAT_CMD_DATA;
|
||||
|
||||
typedef struct _chat_command
|
||||
{
|
||||
char lastMessage[MAXSTRLEN]; /* Parse the same mesage only once - in case more than one player is trying to parse */
|
||||
SDWORD numCommands; /* Total number of commands in chat message */
|
||||
CHAT_CMD_DATA cmdData[MAX_CHAT_COMMANDS]; /* Holds information for each recognized command */
|
||||
}CHAT_MSG;
|
||||
|
||||
extern CHAT_MSG chat_msg;
|
||||
|
||||
/* Store parameter extracted from the message - for scripts */
|
||||
//extern BOOL chat_store_parameter(INTERP_VAL *parameter);
|
||||
|
||||
extern void chat_error(const char *pMessage,...);
|
||||
|
||||
extern void chatGetErrorData(int *pLine, char **ppText);
|
||||
|
||||
/* Set the current input buffer for the lexer */
|
||||
extern void chatSetInputBuffer(char *pBuffer, UDWORD size);
|
||||
|
||||
// Load message
|
||||
extern BOOL chatLoad(char *pData, UDWORD size);
|
||||
|
||||
#endif
|
||||
/*
|
||||
This file is part of Warzone 2100.
|
||||
Copyright (C) 1999-2004 Eidos Interactive
|
||||
Copyright (C) 2005-2007 Warzone Resurrection Project
|
||||
|
||||
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
|
||||
*/
|
||||
/*
|
||||
* chat_processing.h
|
||||
*
|
||||
* Misc definitions for chat parser
|
||||
*/
|
||||
#ifndef _chat_processing_h
|
||||
#define _chat_processing_h
|
||||
|
||||
#include "lib/framework/frame.h"
|
||||
#include "src/base.h"
|
||||
#include "src/droiddef.h"
|
||||
#include "src/structuredef.h"
|
||||
#include "lib/script/script.h"
|
||||
|
||||
#ifndef MAXSTRLEN
|
||||
#define MAXSTRLEN 255
|
||||
#endif
|
||||
|
||||
/* Max number of commands in a player chat message */
|
||||
#define MAX_CHAT_COMMANDS 10
|
||||
|
||||
/* Max number of parameters allowed in a single chat message command */
|
||||
#define MAX_CHAT_CMD_PARAMS 10
|
||||
|
||||
|
||||
/* Holds information for each recognized
|
||||
* command in a chat message */
|
||||
typedef struct _chat_command_data
|
||||
{
|
||||
char *pCmdDescription; /* String representing a certain command */
|
||||
BOOL bPlayerAddressed[MAX_PLAYERS]; /* Flag to indicate whether a command was addressed to a certain player */
|
||||
SDWORD numCmdParams; /* Number of extracted parameters associated with each command */
|
||||
INTERP_VAL parameter[MAX_CHAT_CMD_PARAMS]; /* Parameters extracted from text - to be used with scripts */
|
||||
}CHAT_CMD_DATA;
|
||||
|
||||
typedef struct _chat_command
|
||||
{
|
||||
char lastMessage[MAXSTRLEN]; /* Parse the same mesage only once - in case more than one player is trying to parse */
|
||||
SDWORD numCommands; /* Total number of commands in chat message */
|
||||
CHAT_CMD_DATA cmdData[MAX_CHAT_COMMANDS]; /* Holds information for each recognized command */
|
||||
}CHAT_MSG;
|
||||
|
||||
extern CHAT_MSG chat_msg;
|
||||
|
||||
/* Store parameter extracted from the message - for scripts */
|
||||
//extern BOOL chat_store_parameter(INTERP_VAL *parameter);
|
||||
|
||||
extern void chat_error(const char *pMessage,...);
|
||||
|
||||
extern void chatGetErrorData(int *pLine, char **ppText);
|
||||
|
||||
/* Set the current input buffer for the lexer */
|
||||
extern void chatSetInputBuffer(char *pBuffer, UDWORD size);
|
||||
|
||||
// Load message
|
||||
extern BOOL chatLoad(char *pData, UDWORD size);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue