mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-20 12:40:25 +02:00
Quake 4 integrated with DoomRTX
This commit is contained in:
@@ -61,6 +61,14 @@ typedef enum {
|
||||
LEXFL_ALLOWMULTICHARLITERALS = BIT(11), // allow multi character literals
|
||||
LEXFL_ALLOWBACKSLASHSTRINGCONCAT = BIT(12), // allow multiple strings seperated by '\' to be concatenated
|
||||
LEXFL_ONLYSTRINGS = BIT(13) // parse as whitespace deliminated strings (quoted strings keep quotes)
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// jsinger: added to support binary writing from the lexer in either byte swapped or non-byte swapped formats
|
||||
, LEXFL_READBINARY = BIT(29), // read a byte code compiled version of the file
|
||||
LEXFL_BYTESWAP = BIT(30), // when writing the byte code compiled file, byte swap numbers
|
||||
LEXFL_WRITEBINARY = BIT(31) // write out a byte code compiled version of the file
|
||||
// RAVEN END
|
||||
#endif
|
||||
} lexerFlags_t;
|
||||
|
||||
// punctuation ids
|
||||
@@ -126,6 +134,13 @@ typedef enum {
|
||||
#define P_PRECOMP 51
|
||||
#define P_DOLLAR 52
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
#define P_INVERTED_PLING 53
|
||||
#define P_INVERTED_QUERY 54
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
// punctuation
|
||||
typedef struct punctuation_s
|
||||
{
|
||||
@@ -133,6 +148,31 @@ typedef struct punctuation_s
|
||||
int n; // punctuation id
|
||||
} punctuation_t;
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
#ifdef LEXER_READ_AHEAD
|
||||
class LexerIOWrapper {
|
||||
idFile *file;
|
||||
|
||||
int offset;
|
||||
int size;
|
||||
char *memory;
|
||||
|
||||
public:
|
||||
LexerIOWrapper();
|
||||
void InitFromMemory(char const * const ptr, int length);
|
||||
bool OpenFile(char const *filename, bool OSPath);
|
||||
int Length();
|
||||
int Tell();
|
||||
void Seek( int loc, int mode );
|
||||
void Read( void *dest, int s );
|
||||
void Close();
|
||||
int IsLoaded();
|
||||
};
|
||||
#endif
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
|
||||
class idLexer {
|
||||
|
||||
@@ -195,6 +235,12 @@ public:
|
||||
float ParseFloat( bool *errorFlag = NULL );
|
||||
// parse matrices with floats
|
||||
int Parse1DMatrix( int x, float *m );
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// rjohnson: added vertex color support to proc files. assume a default RGBA of 0x000000ff
|
||||
int Parse1DMatrixOpenEnded( int MaxCount, float *m );
|
||||
// RAVEN END
|
||||
#endif
|
||||
int Parse2DMatrix( int y, int x, float *m );
|
||||
int Parse3DMatrix( int z, int y, int x, float *m );
|
||||
// parse a braced section into a string
|
||||
@@ -241,6 +287,17 @@ public:
|
||||
// set the base folder to load files from
|
||||
static void SetBaseFolder( const char *path );
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// write a binary representation of a token
|
||||
void WriteBinaryToken( idToken *tok );
|
||||
static void WriteBinaryFile( char const * const filename );
|
||||
|
||||
// dluetscher: added method to parse a structure array that is made up of numerics (floats, ints), and stores them in the given storage
|
||||
void ParseNumericStructArray( int numStructElements, int tokenSubTypeStructElements[], int arrayCount, byte *arrayStorage );
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
private:
|
||||
int loaded; // set when a script file is loaded from file or memory
|
||||
idStr filename; // file name of the script
|
||||
@@ -264,6 +321,13 @@ private:
|
||||
idLexer * next; // next script in a chain
|
||||
bool hadError; // set by idLexer::Error, even if the error is supressed
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// jsinger: This is the file that WriteBinaryToken will write to when the proper flags are set
|
||||
idFile * mBinaryFile;
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
static char baseFolder[ 256 ]; // base folder to load files from
|
||||
|
||||
private:
|
||||
@@ -279,6 +343,96 @@ private:
|
||||
int NumLinesCrossed( void );
|
||||
};
|
||||
|
||||
|
||||
#ifdef QUAKE4
|
||||
// RAVEN BEGIN
|
||||
// This class is only necessary to parse binary files. When LEXFL_READBINARY is not set, it delegates to idLexer.
|
||||
class Lexer {
|
||||
friend class idParser;
|
||||
|
||||
public:
|
||||
#ifdef LEXER_READ_AHEAD
|
||||
static void BeginLevelLoad();
|
||||
static void EndLevelLoad();
|
||||
#endif
|
||||
|
||||
// constructors
|
||||
Lexer( const char *filename, int flags = 0, bool OSPath = false );
|
||||
Lexer( int flags = 0 );
|
||||
Lexer( char const * const ptr, int length, char const * const name, int flags = 0 );
|
||||
|
||||
// destructor
|
||||
~Lexer();
|
||||
int LoadFile( const char *filename, bool OSPath = false );
|
||||
int LoadMemory( const char *ptr, int length, const char *name, int startLine = 1 );
|
||||
void FreeSource( void );
|
||||
int IsLoaded( void );
|
||||
int ReadToken( idToken *token );
|
||||
int ExpectTokenString( const char *string );
|
||||
int ExpectTokenType( int type, int subtype, idToken *token );
|
||||
int ExpectAnyToken( idToken *token );
|
||||
int CheckTokenString( const char *string );
|
||||
int CheckTokenType( int type, int subtype, idToken *token );
|
||||
int SkipUntilString( const char *string );
|
||||
int SkipRestOfLine( void );
|
||||
int SkipBracedSection( bool parseFirstBrace = true );
|
||||
void UnreadToken( const idToken *token );
|
||||
int ReadTokenOnLine( idToken *token );
|
||||
int ParseInt( void );
|
||||
bool ParseBool( void );
|
||||
float ParseFloat( bool *errorFlag = NULL );
|
||||
int Parse1DMatrix( int x, float *m );
|
||||
int Parse1DMatrixOpenEnded( int MaxCount, float *m );
|
||||
int Parse2DMatrix( int y, int x, float *m );
|
||||
int Parse3DMatrix( int z, int y, int x, float *m );
|
||||
const char * ParseBracedSection( idStr &out );
|
||||
const char * ParseBracedSectionExact( idStr &out, int tabs = -1 );
|
||||
const char * ParseRestOfLine( idStr &out );
|
||||
int GetLastWhiteSpace( idStr &whiteSpace ) const;
|
||||
int GetLastWhiteSpaceStart( void ) const;
|
||||
int GetLastWhiteSpaceEnd( void ) const;
|
||||
void SetPunctuations( const punctuation_t *p );
|
||||
const char * GetPunctuationFromId( int id );
|
||||
int GetPunctuationId( const char *p );
|
||||
void SetFlags( int flags );
|
||||
int GetFlags( void );
|
||||
void Reset( void );
|
||||
int EndOfFile( void );
|
||||
const char * GetFileName( void );
|
||||
const int GetFileOffset( void );
|
||||
const unsigned int GetFileTime( void );
|
||||
const int GetLineNum( void );
|
||||
void Error( const char *str, ... );
|
||||
void Warning( const char *str, ... );
|
||||
bool HadError( void ) const;
|
||||
void WriteBinaryToken( idToken *tok );
|
||||
static void SetBaseFolder( char const * const path );
|
||||
void ParseNumericStructArray( int numStructElements, int tokenSubTypeStructElements[], int arrayCount, byte *arrayStorage );
|
||||
|
||||
// suffix that should be appended to the normal file extension to signify that the file is binary
|
||||
static idStr const sCompiledFileSuffix;
|
||||
|
||||
protected:
|
||||
static char baseFolder[256];
|
||||
|
||||
private:
|
||||
bool OpenFile( char const *filename, bool OSPath );
|
||||
|
||||
#ifdef LEXER_READ_AHEAD
|
||||
LexerIOWrapper mLexerIOWrapper;
|
||||
#else
|
||||
idFile *mFile;
|
||||
#endif
|
||||
unsigned int offset;
|
||||
idToken unreadToken;
|
||||
unsigned int unreadSize;
|
||||
bool tokenAvailable;
|
||||
idLexer *mDelegate;
|
||||
int mFlags;
|
||||
};
|
||||
// RAVEN END
|
||||
#endif
|
||||
|
||||
ID_INLINE const char *idLexer::GetFileName( void ) {
|
||||
return idLexer::filename;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user