2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-12-23 17:25:24 +01:00

Update client engine interface

This commit is contained in:
mittorn 2018-04-19 21:51:17 +00:00
parent af7123f7dd
commit c1076f43f7
12 changed files with 2605 additions and 18 deletions

View File

@ -27,6 +27,16 @@ extern "C" {
#endif
#include "const.h"
#include <stdint.h>
#define MAX_ALIAS_NAME 32
typedef struct cmdalias_s
{
struct cmdalias_s *next;
char name[MAX_ALIAS_NAME];
char *value;
} cmdalias_t;
// this file is included by both the engine and the client-dll,
// so make sure engine declarations aren't done twice
@ -96,10 +106,12 @@ typedef struct hud_player_info_s
char *model;
short topcolor;
short bottomcolor;
uint64_t m_nSteamID;
} hud_player_info_t;
typedef struct event_args_s event_args_t;
typedef struct screenfade_s screenfade_t;
struct screenfade_s;
struct tagPOINT;
typedef struct cl_enginefuncs_s
{
@ -197,15 +209,15 @@ typedef struct cl_enginefuncs_s
void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
void (*pfnWeaponAnim)( int iAnim, int body );
float (*pfnRandomFloat)( float flLow, float flHigh );
long (*pfnRandomLong)( long lLow, long lHigh );
void (*pfnHookEvent)( char *name, void ( *pfnEvent )( event_args_t *args ));
int (*pfnRandomLong)( int lLow, int lHigh );
void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args ));
int (*Con_IsVisible) ();
const char *(*pfnGetGameDirectory)( void );
struct cvar_s *(*pfnGetCvarPointer)( const char *szName );
const char *(*Key_LookupBinding)( const char *pBinding );
const char *(*pfnGetLevelName)( void );
void (*pfnGetScreenFade)( screenfade_t *fade );
void (*pfnSetScreenFade)( screenfade_t *fade );
void (*pfnGetScreenFade)( struct screenfade_s *fade );
void (*pfnSetScreenFade)( struct screenfade_s *fade );
void* (*VGui_GetPanel)( );
void (*VGui_ViewportPaintBackground)( int extents[4] );
@ -251,6 +263,44 @@ typedef struct cl_enginefuncs_s
void (*pfnGetMousePos)( struct tagPOINT *ppt );
void (*pfnSetMousePos)( int x, int y );
void (*pfnSetMouseEnable)( qboolean fEnable );
// undocumented interface starts here
struct cvar_s* (*pfnGetFirstCvarPtr)( void );
void* (*pfnGetFirstCmdFunctionHandle)( void );
void* (*pfnGetNextCmdFunctionHandle)( void *cmdhandle );
const char* (*pfnGetCmdFunctionName)( void *cmdhandle );
float (*pfnGetClientOldTime)( void );
float (*pfnGetGravity)( void );
struct model_s* (*pfnGetModelByIndex)( int index );
void (*pfnSetFilterMode)( int mode ); // same as gl_texsort in original Quake
void (*pfnSetFilterColor)( float red, float green, float blue );
void (*pfnSetFilterBrightness)( float brightness );
void *(*pfnSequenceGet)( const char *fileName, const char *entryName );
void (*pfnSPR_DrawGeneric)( int frame, int x, int y, const wrect_t *prc, int blendsrc, int blenddst, int width, int height );
void *(*pfnSequencePickSentence)( const char *groupName, int pickMethod, int *entryPicked );
int (*pfnDrawString)( int x, int y, const char *str, int r, int g, int b );
int (*pfnDrawStringReverse)( int x, int y, const char *str, int r, int g, int b );
const char *(*LocalPlayerInfo_ValueForKey)( const char* key );
int (*pfnVGUI2DrawCharacter)( int x, int y, int ch, unsigned int font );
int (*pfnVGUI2DrawCharacterAdditive)( int x, int y, int ch, int r, int g, int b, unsigned int font );
unsigned int (*pfnGetApproxWavePlayLen)( char *filename );
void* (*GetCareerGameUI)( void ); // g-cont. !!!! potential crash-point!
void (*Cvar_Set)( char *name, char *value );
int (*pfnIsPlayingCareerMatch)( void );
void (*pfnPlaySoundVoiceByName)( char *szSound, float volume, int pitch );
void (*pfnPrimeMusicStream)( char *filename, int looping );
double (*pfnSys_FloatTime)( void );
// decay funcs
void (*pfnProcessTutorMessageDecayBuffer)( int *buffer, int buflen );
void (*pfnConstructTutorMessageDecayBuffer)( int *buffer, int buflen );
void (*pfnResetTutorMessageDecayData)( void );
void (*pfnPlaySoundByNameAtPitch)( char *szSound, float volume, int pitch );
void (*pfnFillRGBABlend)( int x, int y, int width, int height, int r, int g, int b, int a );
int (*pfnGetAppID)( void );
cmdalias_t *(*pfnGetAliases)( void );
void (*pfnVguiWrap2_GetMouseDelta)( int *x, int *y );
} cl_enginefunc_t;
#define CLDLL_INTERFACE_VERSION 7

View File

@ -2772,6 +2772,281 @@ void pfnSetMouseEnable( qboolean fEnable )
{
}
/*
=============
pfnGetServerTime
=============
*/
static float GAME_EXPORT pfnGetClientOldTime( void )
{
return cl.oldtime;
}
/*
=============
pfnGetGravity
=============
*/
static float GAME_EXPORT pfnGetGravity( void )
{
return clgame.movevars.gravity;
}
/*
=============
pfnEnableTexSort
TODO: implement
=============
*/
static void GAME_EXPORT pfnEnableTexSort( int enable )
{
}
/*
=============
pfnSetLightmapColor
TODO: implement
=============
*/
static void GAME_EXPORT pfnSetLightmapColor( float red, float green, float blue )
{
}
/*
=============
pfnSetLightmapScale
TODO: implement
=============
*/
static void GAME_EXPORT pfnSetLightmapScale( float scale )
{
}
/*
=============
pfnSPR_DrawGeneric
=============
*/
static void GAME_EXPORT pfnSPR_DrawGeneric( int frame, int x, int y, const wrect_t *prc, int blendsrc, int blenddst, int width, int height )
{
pglEnable( GL_BLEND );
pglBlendFunc( blendsrc, blenddst ); // g-cont. are params is valid?
SPR_DrawGeneric( frame, x, y, width, height, prc );
}
/*
=============
LocalPlayerInfo_ValueForKey
=============
*/
static const char *GAME_EXPORT LocalPlayerInfo_ValueForKey( const char* key )
{
return Info_ValueForKey( CL_Userinfo(), key );
}
/*
=============
pfnVGUI2DrawCharacter
=============
*/
static int GAME_EXPORT pfnVGUI2DrawCharacter( int x, int y, int number, unsigned int font )
{
if( !cls.creditsFont.valid )
return 0;
number &= 255;
number = Con_UtfProcessChar( number );
if( number < 32 ) return 0;
if( y < -clgame.scrInfo.iCharHeight )
return 0;
clgame.ds.adjust_size = true;
gameui.ds.gl_texturenum = cls.creditsFont.hFontTexture;
pfnPIC_DrawAdditive( x, y, -1, -1, &cls.creditsFont.fontRc[number] );
clgame.ds.adjust_size = false;
return clgame.scrInfo.charWidths[number];
}
/*
=============
pfnVGUI2DrawCharacterAdditive
=============
*/
static int GAME_EXPORT pfnVGUI2DrawCharacterAdditive( int x, int y, int ch, int r, int g, int b, unsigned int font )
{
/// TODO: fix UTF-8
#if 0
if( !hud_utf8->integer )
ch = Con_UtfProcessChar( ch );
#endif
return pfnDrawCharacter( x, y, ch, r, g, b );
}
/*
=============
pfnDrawString
=============
*/
static int GAME_EXPORT pfnDrawString( int x, int y, const char *str, int r, int g, int b )
{
Con_UtfProcessChar(0);
// draw the string until we hit the null character or a newline character
for ( ; *str != 0 && *str != '\n'; str++ )
{
x += pfnVGUI2DrawCharacterAdditive( x, y, (unsigned char)*str, r, g, b, 0 );
}
return x;
}
/*
=============
pfnDrawStringReverse
=============
*/
static int GAME_EXPORT pfnDrawStringReverse( int x, int y, const char *str, int r, int g, int b )
{
// find the end of the string
char *szIt;
for( szIt = (char*)str; *szIt != 0; szIt++ )
x -= clgame.scrInfo.charWidths[ (unsigned char) *szIt ];
pfnDrawString( x, y, str, r, g, b );
return x;
}
/*
=============
GetCareerGameInterface
=============
*/
static void *GAME_EXPORT GetCareerGameInterface( void )
{
Msg( "^1Career GameInterface called!\n" );
return NULL;
}
/*
=============
pfnPlaySoundVoiceByName
=============
*/
static void GAME_EXPORT pfnPlaySoundVoiceByName( char *filename, float volume, int pitch )
{
int hSound = S_RegisterSound( filename );
S_StartSound( NULL, cl.viewentity, CHAN_NETWORKVOICE_END + 1, hSound, volume, 1.0, pitch, SND_STOP_LOOPING );
}
/*
=============
pfnMP3_InitStream
=============
*/
static void GAME_EXPORT pfnMP3_InitStream( char *filename, int looping )
{
if( !filename )
{
S_StopBackgroundTrack();
return;
}
if( looping )
{
S_StartBackgroundTrack( filename, filename, 0, false );
}
else
{
S_StartBackgroundTrack( filename, NULL, 0, false );
}
}
/*
=============
pfnPlaySoundByNameAtPitch
=============
*/
static void GAME_EXPORT pfnPlaySoundByNameAtPitch( char *filename, float volume, int pitch )
{
int hSound = S_RegisterSound( filename );
S_StartSound( NULL, cl.viewentity, CHAN_ITEM, hSound, volume, 1.0, pitch, SND_STOP_LOOPING );
}
/*
=============
pfnFillRGBABlend
=============
*/
void GAME_EXPORT CL_FillRGBABlend( int x, int y, int w, int h, int r, int g, int b, int a )
{
r = bound( 0, r, 255 );
g = bound( 0, g, 255 );
b = bound( 0, b, 255 );
a = bound( 0, a, 255 );
SPR_AdjustSize( (float *)&x, (float *)&y, (float *)&w, (float *)&h );
pglDisable( GL_TEXTURE_2D );
pglEnable( GL_BLEND );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
pglColor4f( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
pglBegin( GL_QUADS );
pglVertex2f( x, y );
pglVertex2f( x + w, y );
pglVertex2f( x + w, y + h );
pglVertex2f( x, y + h );
pglEnd ();
pglColor3f( 1.0f, 1.0f, 1.0f );
pglEnable( GL_TEXTURE_2D );
pglDisable( GL_BLEND );
}
/*
=============
pfnGetAppID
=============
*/
static int GAME_EXPORT pfnGetAppID( void )
{
return 70; // Half-Life AppID
}
/*
=============
pfnVguiWrap2_GetMouseDelta
TODO: implement
=============
*/
static void GAME_EXPORT pfnVguiWrap2_GetMouseDelta( int *x, int *y )
{
}
/*
=============
pfnParseFile
@ -3779,6 +4054,39 @@ static cl_enginefunc_t gEngfuncs =
pfnGetMousePos,
pfnSetMousePos,
pfnSetMouseEnable,
Cvar_GetList,
(void*)Cmd_GetFirstFunctionHandle,
(void*)Cmd_GetNextFunctionHandle,
(void*)Cmd_GetName,
pfnGetClientOldTime,
pfnGetGravity,
Mod_Handle,
pfnEnableTexSort,
pfnSetLightmapColor,
pfnSetLightmapScale,
pfnSequenceGet,
pfnSPR_DrawGeneric,
pfnSequencePickSentence,
pfnDrawString,
pfnDrawStringReverse,
LocalPlayerInfo_ValueForKey,
pfnVGUI2DrawCharacter,
pfnVGUI2DrawCharacterAdditive,
(void*)Sound_GetApproxWavePlayLen,
GetCareerGameInterface,
(void*)Cvar_Set,
pfnIsCareerMatch,
pfnPlaySoundVoiceByName,
pfnMP3_InitStream,
Sys_DoubleTime,
pfnProcessTutorMessageDecayBuffer,
pfnConstructTutorMessageDecayBuffer,
pfnResetTutorMessageDecayData,
pfnPlaySoundByNameAtPitch,
CL_FillRGBABlend,
pfnGetAppID,
Cmd_AliasGetList,
pfnVguiWrap2_GetMouseDelta,
};
void CL_UnloadProgs( void )

View File

@ -21,13 +21,6 @@ GNU General Public License for more details.
#define MAX_CMD_LINE 2048
#define MAX_ALIAS_NAME 32
typedef struct cmdalias_s
{
struct cmdalias_s *next;
char name[MAX_ALIAS_NAME];
char *value;
} cmdalias_t;
typedef struct
{
byte *data;
@ -49,6 +42,7 @@ int cmd_condlevel;
=============================================================================
*/
/*
============
Cbuf_Init
@ -498,6 +492,56 @@ char *Cmd_Args( void )
return cmd_args;
}
/*
===========================
Client exports
===========================
*/
/*
============
Cmd_AliasGetList
============
*/
cmdalias_t *GAME_EXPORT Cmd_AliasGetList( void )
{
return cmd_alias;
}
/*
============
Cmd_GetList
============
*/
cmd_t *GAME_EXPORT Cmd_GetFirstFunctionHandle( void )
{
return cmd_functions;
}
/*
============
Cmd_GetNext
============
*/
cmd_t *GAME_EXPORT Cmd_GetNextFunctionHandle( cmd_t *cmd )
{
return (cmd) ? cmd->next : NULL;
}
/*
============
Cmd_GetName
============
*/
char *GAME_EXPORT Cmd_GetName( cmd_t *cmd )
{
return cmd->name;
}
/*
============
Cmd_TokenizeString

View File

@ -1321,3 +1321,110 @@ qboolean COM_IsSafeFileToDownload( const char *filename )
return true;
}
/*
======================
COMMON EXPORT STUBS
======================
*/
/*
=============
pfnSequenceGet
used by CS:CZ
=============
*/
void *GAME_EXPORT pfnSequenceGet( const char *fileName, const char *entryName )
{
Msg( "Sequence_Get: file %s, entry %s\n", fileName, entryName );
return Sequence_Get( fileName, entryName );
}
/*
=============
pfnSequencePickSentence
used by CS:CZ
=============
*/
void *GAME_EXPORT pfnSequencePickSentence( const char *groupName, int pickMethod, int *picked )
{
Msg( "Sequence_PickSentence: group %s, pickMethod %i\n", groupName, pickMethod );
return Sequence_PickSentence( groupName, pickMethod, picked );
}
/*
=============
pfnIsCareerMatch
used by CS:CZ (client stub)
=============
*/
int GAME_EXPORT GAME_EXPORT pfnIsCareerMatch( void )
{
return 0;
}
/*
=============
pfnRegisterTutorMessageShown
only exists in PlayStation version
=============
*/
void GAME_EXPORT pfnRegisterTutorMessageShown( int mid )
{
}
/*
=============
pfnGetTimesTutorMessageShown
only exists in PlayStation version
=============
*/
int GAME_EXPORT pfnGetTimesTutorMessageShown( int mid )
{
return 0;
}
/*
=============
pfnProcessTutorMessageDecayBuffer
only exists in PlayStation version
=============
*/
void GAME_EXPORT pfnProcessTutorMessageDecayBuffer( int *buffer, int bufferLength )
{
}
/*
=============
pfnConstructTutorMessageDecayBuffer
only exists in PlayStation version
=============
*/
void GAME_EXPORT pfnConstructTutorMessageDecayBuffer( int *buffer, int bufferLength )
{
}
/*
=============
pfnResetTutorMessageDecayData
only exists in PlayStation version
=============
*/
void GAME_EXPORT pfnResetTutorMessageDecayData( void )
{
}

View File

@ -122,6 +122,7 @@ typedef char string[MAX_STRING];
typedef struct file_s file_t; // normal file
typedef struct wfile_s wfile_t; // wad file
typedef struct stream_s stream_t; // sound stream for background music playing
typedef off_t fs_offset_t;
typedef void (*setpair_t)( const char *key, const char *value, void *buffer, void *numpairs );
@ -768,6 +769,7 @@ long FS_SetStreamPos( stream_t *stream, long newpos );
long FS_GetStreamPos( stream_t *stream );
void FS_FreeStream( stream_t *stream );
qboolean Sound_Process( wavdata_t **wav, int rate, int width, uint flags );
uint Sound_GetApproxWavePlayLen( const char *filepath );
//
// build.c
@ -860,6 +862,19 @@ int pfnNumberOfEntities( void );
int pfnIsInGame( void );
float pfnTime( void );
// CS:CS engfuncs (stubs)
void *pfnSequenceGet( const char *fileName, const char *entryName );
void *pfnSequencePickSentence( const char *groupName, int pickMethod, int *picked );
int pfnIsCareerMatch( void );
// Decay engfuncs (stubs)
int pfnGetTimesTutorMessageShown( int mid );
void pfnRegisterTutorMessageShown( int mid );
void pfnConstructTutorMessageDecayBuffer( int *buffer, int buflen );
void pfnProcessTutorMessageDecayBuffer( int *buffer, int bufferLength );
void pfnResetTutorMessageDecayData( void );
/*
==============================================================
@ -952,6 +967,10 @@ byte *COM_LoadFile( const char *filename, int usehunk, int *pLength );
qboolean CL_GetDemoComment( const char *demoname, char *comment );
void COM_AddAppDirectoryToSearchPath( const char *pszBaseDir, const char *appName );
int COM_ExpandFilename( const char *fileName, char *nameOutBuffer, int nameOutBufferSize );
struct cmd_s *Cmd_GetFirstFunctionHandle( void );
struct cmd_s *Cmd_GetNextFunctionHandle( struct cmd_s *cmd );
struct cmdalias_s *Cmd_AliasGetList( void );
char *Cmd_GetName( struct cmd_s *cmd );
struct pmtrace_s *PM_TraceLine( float *start, float *end, int flags, int usehull, int ignore_pe );
void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch );
void SV_StartMusic( const char *curtrack, const char *looptrack, long position );

View File

@ -19,6 +19,17 @@ GNU General Public License for more details.
convar_t *cvar_vars = NULL; // head of list
convar_t *cmd_scripting;
/*
============
Cvar_GetList
============
*/
cvar_t *GAME_EXPORT Cvar_GetList( void )
{
return (cvar_t *)cvar_vars;
}
/*
============
Cvar_FindVar

View File

@ -48,6 +48,7 @@ typedef struct convar_s
#define CVAR_DEFINE_AUTO( cv, cvstr, cvflags, cvdesc ) convar_t cv = { #cv, cvstr, cvflags, 0.0f, (void *)CVAR_SENTINEL, cvdesc }
#define CVAR_TO_BOOL( x ) ((x) && ((x)->value != 0.0f) ? true : false )
cvar_t *Cvar_GetList( void );
#define Cvar_FindVar( name ) Cvar_FindVarExt( name, 0 )
convar_t *Cvar_FindVarExt( const char *var_name, int ignore_group );
void Cvar_RegisterVariable( convar_t *var );

View File

@ -152,6 +152,7 @@ model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC );
qboolean Mod_ValidateCRC( const char *name, CRC32_t crc );
void Mod_NeedCRC( const char *name, qboolean needCRC );
void Mod_FreeUnused( void );
model_t *Mod_Handle( int handle );
//
// mod_bmodel.c

View File

@ -602,3 +602,20 @@ void Mod_NeedCRC( const char *name, qboolean needCRC )
if( needCRC ) SetBits( p->flags, FCRC_SHOULD_CHECKSUM );
else ClearBits( p->flags, FCRC_SHOULD_CHECKSUM );
}
/*
==================
Mod_Handle
==================
*/
model_t *GAME_EXPORT Mod_Handle( int handle )
{
if( handle < 0 || handle >= MAX_MODELS )
{
MsgDev( D_NOTE, "Mod_Handle: bad handle #%i\n", handle );
return NULL;
}
return &mod_known[handle];
}

1781
engine/common/sequence.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -93,6 +93,49 @@ byte *Sound_Copy( size_t size )
return out;
}
uint GAME_EXPORT Sound_GetApproxWavePlayLen( const char *filepath )
{
file_t *f;
wavehdr_t wav;
size_t filesize;
float seconds;
uint samples;
f = FS_Open( filepath, "rb", false );
if( !f ) return 0;
if( FS_Read( f, &wav, sizeof( wav )) != sizeof( wav ))
{
FS_Close( f );
return 0;
}
filesize = FS_FileLength( f );
filesize -= ( sizeof( wavehdr_t ) + sizeof( chunkhdr_t ));
FS_Close( f );
// is real wav file ?
if( wav.riff_id != RIFFHEADER || wav.wave_id != WAVEHEADER || wav.fmt_id != FORMHEADER )
return 0;
if( wav.wFormatTag != 1 )
return 0;
if( wav.nChannels != 1 && wav.nChannels != 2 )
return 0;
if( wav.nBitsPerSample != 8 && wav.nBitsPerSample != 16 )
return 0;
// calc samplecount
seconds = (float)filesize / wav.nAvgBytesPerSec / wav.nChannels;
samples = (uint)(( wav.nSamplesPerSec * wav.nChannels ) * seconds );
// g-cont. this function returns samplecount or time in milliseconds ???
return (uint)(seconds * 1000);
}
/*
================
Sound_ConvertToSigned

205
engine/sequence.h Normal file
View File

@ -0,0 +1,205 @@
//---------------------------------------------------------------------------
//
// S c r i p t e d S e q u e n c e s
//
//---------------------------------------------------------------------------
#ifndef _INCLUDE_SEQUENCE_H_
#define _INCLUDE_SEQUENCE_H_
#ifndef _DEF_BYTE_
//typedef unsigned char byte;
#endif
#ifndef CDLL_INT_H
//---------------------------------------------------------------------------
// client_textmessage_t
//---------------------------------------------------------------------------
typedef struct client_textmessage_s
{
int effect;
byte r1, g1, b1, a1; // 2 colors for effects
byte r2, g2, b2, a2;
float x;
float y;
float fadein;
float fadeout;
float holdtime;
float fxtime;
char *pName;
char *pMessage;
} client_textmessage_t;
#endif
//---------------------------------------------------------------------------
// sequenceCommandEnum_e
//
// Enumerated sequence command types.
//---------------------------------------------------------------------------
enum sequenceCommandEnum_
{
SEQUENCE_COMMAND_ERROR = -1,
SEQUENCE_COMMAND_PAUSE = 0,
SEQUENCE_COMMAND_FIRETARGETS,
SEQUENCE_COMMAND_KILLTARGETS,
SEQUENCE_COMMAND_TEXT,
SEQUENCE_COMMAND_SOUND,
SEQUENCE_COMMAND_GOSUB,
SEQUENCE_COMMAND_SENTENCE,
SEQUENCE_COMMAND_REPEAT,
SEQUENCE_COMMAND_SETDEFAULTS,
SEQUENCE_COMMAND_MODIFIER,
SEQUENCE_COMMAND_POSTMODIFIER,
SEQUENCE_COMMAND_NOOP,
SEQUENCE_MODIFIER_EFFECT,
SEQUENCE_MODIFIER_POSITION,
SEQUENCE_MODIFIER_COLOR,
SEQUENCE_MODIFIER_COLOR2,
SEQUENCE_MODIFIER_FADEIN,
SEQUENCE_MODIFIER_FADEOUT,
SEQUENCE_MODIFIER_HOLDTIME,
SEQUENCE_MODIFIER_FXTIME,
SEQUENCE_MODIFIER_SPEAKER,
SEQUENCE_MODIFIER_LISTENER,
SEQUENCE_MODIFIER_TEXTCHANNEL,
};
typedef enum sequenceCommandEnum_ sequenceCommandEnum_e;
//--------------------------------------------------------------------------
// sequenceDefaultBits_e
//
// Enumerated list of possible modifiers for a command. This enumeration
// is used in a bitarray controlling what modifiers are specified for a command.
//---------------------------------------------------------------------------
enum sequenceModifierBits
{
SEQUENCE_MODIFIER_EFFECT_BIT = (1 << 1),
SEQUENCE_MODIFIER_POSITION_BIT = (1 << 2),
SEQUENCE_MODIFIER_COLOR_BIT = (1 << 3),
SEQUENCE_MODIFIER_COLOR2_BIT = (1 << 4),
SEQUENCE_MODIFIER_FADEIN_BIT = (1 << 5),
SEQUENCE_MODIFIER_FADEOUT_BIT = (1 << 6),
SEQUENCE_MODIFIER_HOLDTIME_BIT = (1 << 7),
SEQUENCE_MODIFIER_FXTIME_BIT = (1 << 8),
SEQUENCE_MODIFIER_SPEAKER_BIT = (1 << 9),
SEQUENCE_MODIFIER_LISTENER_BIT = (1 << 10),
SEQUENCE_MODIFIER_TEXTCHANNEL_BIT = (1 << 11),
};
typedef enum sequenceModifierBits sequenceModifierBits_e ;
//---------------------------------------------------------------------------
// sequenceCommandType_e
//
// Typeerated sequence command types.
//---------------------------------------------------------------------------
enum sequenceCommandType_
{
SEQUENCE_TYPE_COMMAND,
SEQUENCE_TYPE_MODIFIER,
};
typedef enum sequenceCommandType_ sequenceCommandType_e;
//---------------------------------------------------------------------------
// sequenceCommandMapping_s
//
// A mapping of a command enumerated-value to its name.
//---------------------------------------------------------------------------
typedef struct sequenceCommandMapping_ sequenceCommandMapping_s;
struct sequenceCommandMapping_
{
sequenceCommandEnum_e commandEnum;
const char* commandName;
sequenceCommandType_e commandType;
};
//---------------------------------------------------------------------------
// sequenceCommandLine_s
//
// Structure representing a single command (usually 1 line) from a
// .SEQ file entry.
//---------------------------------------------------------------------------
typedef struct sequenceCommandLine_ sequenceCommandLine_s;
struct sequenceCommandLine_
{
int commandType; // Specifies the type of command
client_textmessage_t clientMessage; // Text HUD message struct
char* speakerName; // Targetname of speaking entity
char* listenerName; // Targetname of entity being spoken to
char* soundFileName; // Name of sound file to play
char* sentenceName; // Name of sentences.txt to play
char* fireTargetNames; // List of targetnames to fire
char* killTargetNames; // List of targetnames to remove
float delay; // Seconds 'till next command
int repeatCount; // If nonzero, reset execution pointer to top of block (N times, -1 = infinite)
int textChannel; // Display channel on which text message is sent
int modifierBitField; // Bit field to specify what clientmessage fields are valid
sequenceCommandLine_s* nextCommandLine; // Next command (linked list)
};
//---------------------------------------------------------------------------
// sequenceEntry_s
//
// Structure representing a single command (usually 1 line) from a
// .SEQ file entry.
//---------------------------------------------------------------------------
typedef struct sequenceEntry_ sequenceEntry_s;
struct sequenceEntry_
{
char* fileName; // Name of sequence file without .SEQ extension
char* entryName; // Name of entry label in file
sequenceCommandLine_s* firstCommand; // Linked list of commands in entry
sequenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
};
//---------------------------------------------------------------------------
// sentenceEntry_s
// Structure representing a single sentence of a group from a .SEQ
// file entry. Sentences are identical to entries in sentences.txt, but
// can be unique per level and are loaded/unloaded with the level.
//---------------------------------------------------------------------------
typedef struct sentenceEntry_ sentenceEntry_s;
struct sentenceEntry_
{
char* data; // sentence data (ie "We have hostiles" )
sentenceEntry_s* nextEntry; // Next loaded entry
qboolean isGlobal; // Is entry retained over level transitions?
unsigned int index; // this entry's position in the file.
};
//--------------------------------------------------------------------------
// sentenceGroupEntry_s
// Structure representing a group of sentences found in a .SEQ file.
// A sentence group is defined by all sentences with the same name, ignoring
// the number at the end of the sentence name. Groups enable a sentence
// to be picked at random across a group.
//--------------------------------------------------------------------------
typedef struct sentenceGroupEntry_ sentenceGroupEntry_s;
struct sentenceGroupEntry_
{
char* groupName; // name of the group (ie CT_ALERT )
unsigned int numSentences; // number of sentences in group
sentenceEntry_s* firstSentence; // head of linked list of sentences in group
sentenceGroupEntry_s* nextEntry; // next loaded group
};
//---------------------------------------------------------------------------
// Function declarations
//---------------------------------------------------------------------------
sequenceEntry_s* Sequence_Get( const char* fileName, const char* entryName );
void Sequence_ParseFile( const char* fileName, qboolean isGlobal );
void Sequence_OnLevelLoad( const char* mapName );
sentenceEntry_s* Sequence_PickSentence( const char *groupName, int pickMethod, int *picked );
void Sequence_Init( void );
void Sequence_PurgeEntries( qboolean purgeGlobals );
sentenceEntry_s *Sequence_GetSentenceByIndex( unsigned int index );
#endif // _INCLUDE_SEQUENCE_H_