engine: client: support parsing GoldSrc event messages
This commit is contained in:
parent
ccbe370c8e
commit
609680b328
5 changed files with 33 additions and 16 deletions
|
@ -380,7 +380,7 @@ CL_ParseReliableEvent
|
||||||
|
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void CL_ParseReliableEvent( sizebuf_t *msg )
|
void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||||
{
|
{
|
||||||
int event_index;
|
int event_index;
|
||||||
event_args_t nullargs, args;
|
event_args_t nullargs, args;
|
||||||
|
@ -390,11 +390,19 @@ void CL_ParseReliableEvent( sizebuf_t *msg )
|
||||||
|
|
||||||
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||||
|
|
||||||
|
// reliable events not use delta-compression just null-compression
|
||||||
|
if( proto == PROTO_GOLDSRC )
|
||||||
|
{
|
||||||
|
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
|
||||||
|
if( MSG_ReadOneBit( msg ))
|
||||||
|
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if( MSG_ReadOneBit( msg ))
|
if( MSG_ReadOneBit( msg ))
|
||||||
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
delay = (float)MSG_ReadWord( msg ) * (1.0f / 100.0f);
|
||||||
|
|
||||||
// reliable events not use delta-compression just null-compression
|
|
||||||
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||||
|
}
|
||||||
|
|
||||||
if( args.entindex > 0 && args.entindex <= cl.maxclients )
|
if( args.entindex > 0 && args.entindex <= cl.maxclients )
|
||||||
args.angles[PITCH] *= -3.0f;
|
args.angles[PITCH] *= -3.0f;
|
||||||
|
@ -409,7 +417,7 @@ CL_ParseEvent
|
||||||
|
|
||||||
=============
|
=============
|
||||||
*/
|
*/
|
||||||
void CL_ParseEvent( sizebuf_t *msg )
|
void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto )
|
||||||
{
|
{
|
||||||
int event_index;
|
int event_index;
|
||||||
int i, num_events;
|
int i, num_events;
|
||||||
|
@ -417,24 +425,33 @@ void CL_ParseEvent( sizebuf_t *msg )
|
||||||
event_args_t nullargs, args;
|
event_args_t nullargs, args;
|
||||||
entity_state_t *state;
|
entity_state_t *state;
|
||||||
float delay;
|
float delay;
|
||||||
|
int entity_bits;
|
||||||
|
|
||||||
memset( &nullargs, 0, sizeof( nullargs ));
|
memset( &nullargs, 0, sizeof( nullargs ));
|
||||||
memset( &args, 0, sizeof( args ));
|
memset( &args, 0, sizeof( args ));
|
||||||
|
|
||||||
num_events = MSG_ReadUBitLong( msg, 5 );
|
num_events = MSG_ReadUBitLong( msg, 5 );
|
||||||
|
|
||||||
|
if( proto == PROTO_GOLDSRC )
|
||||||
|
entity_bits = MAX_GOLDSRC_ENTITY_BITS;
|
||||||
|
else if( proto == PROTO_LEGACY )
|
||||||
|
entity_bits = MAX_LEGACY_ENTITY_BITS;
|
||||||
|
else entity_bits = MAX_ENTITY_BITS;
|
||||||
|
|
||||||
// parse events queue
|
// parse events queue
|
||||||
for( i = 0 ; i < num_events; i++ )
|
for( i = 0 ; i < num_events; i++ )
|
||||||
{
|
{
|
||||||
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
event_index = MSG_ReadUBitLong( msg, MAX_EVENT_BITS );
|
||||||
|
|
||||||
if( MSG_ReadOneBit( msg ))
|
if( MSG_ReadOneBit( msg ))
|
||||||
packet_index = MSG_ReadUBitLong( msg, cls.legacymode ? MAX_LEGACY_ENTITY_BITS : MAX_ENTITY_BITS );
|
packet_index = MSG_ReadUBitLong( msg, entity_bits );
|
||||||
else packet_index = -1;
|
else packet_index = -1;
|
||||||
|
|
||||||
if( MSG_ReadOneBit( msg ))
|
if( MSG_ReadOneBit( msg ))
|
||||||
{
|
{
|
||||||
MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
if( proto == PROTO_GOLDSRC )
|
||||||
|
Delta_ReadGSFields( msg, DT_EVENT_T, &nullargs, &args, 0.0f );
|
||||||
|
else MSG_ReadDeltaEvent( msg, &nullargs, &args );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( MSG_ReadOneBit( msg ))
|
if( MSG_ReadOneBit( msg ))
|
||||||
|
|
|
@ -2359,7 +2359,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
||||||
Host_AbortCurrentFrame ();
|
Host_AbortCurrentFrame ();
|
||||||
break;
|
break;
|
||||||
case svc_event:
|
case svc_event:
|
||||||
CL_ParseEvent( msg );
|
CL_ParseEvent( msg, PROTO_CURRENT );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
case svc_changing:
|
case svc_changing:
|
||||||
|
@ -2466,7 +2466,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseStaticEntity( msg );
|
CL_ParseStaticEntity( msg );
|
||||||
break;
|
break;
|
||||||
case svc_event_reliable:
|
case svc_event_reliable:
|
||||||
CL_ParseReliableEvent( msg );
|
CL_ParseReliableEvent( msg, PROTO_CURRENT );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
case svc_spawnbaseline:
|
case svc_spawnbaseline:
|
||||||
|
|
|
@ -359,7 +359,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||||
Host_AbortCurrentFrame ();
|
Host_AbortCurrentFrame ();
|
||||||
break;
|
break;
|
||||||
case svc_legacy_event:
|
case svc_legacy_event:
|
||||||
CL_ParseEvent( msg );
|
CL_ParseEvent( msg, PROTO_LEGACY );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
case svc_legacy_changing:
|
case svc_legacy_changing:
|
||||||
|
@ -478,7 +478,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||||
CL_LegacyParseStaticEntity( msg );
|
CL_LegacyParseStaticEntity( msg );
|
||||||
break;
|
break;
|
||||||
case svc_event_reliable:
|
case svc_event_reliable:
|
||||||
CL_ParseReliableEvent( msg );
|
CL_ParseReliableEvent( msg, PROTO_LEGACY );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
case svc_spawnbaseline:
|
case svc_spawnbaseline:
|
||||||
|
|
|
@ -575,7 +575,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||||
break;
|
break;
|
||||||
case svc_event:
|
case svc_event:
|
||||||
MSG_StartBitWriting( msg );
|
MSG_StartBitWriting( msg );
|
||||||
CL_ParseEvent( msg );
|
CL_ParseEvent( msg, PROTO_GOLDSRC );
|
||||||
MSG_EndBitWriting( msg );
|
MSG_EndBitWriting( msg );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
|
@ -643,7 +643,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg, qboolean normal_message )
|
||||||
break;
|
break;
|
||||||
case svc_event_reliable:
|
case svc_event_reliable:
|
||||||
MSG_StartBitWriting( msg );
|
MSG_StartBitWriting( msg );
|
||||||
CL_ParseReliableEvent( msg );
|
CL_ParseReliableEvent( msg, PROTO_GOLDSRC );
|
||||||
MSG_EndBitWriting( msg );
|
MSG_EndBitWriting( msg );
|
||||||
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -784,8 +784,8 @@ int CL_GetDemoComment( const char *demoname, char *comment );
|
||||||
//
|
//
|
||||||
// cl_events.c
|
// cl_events.c
|
||||||
//
|
//
|
||||||
void CL_ParseEvent( sizebuf_t *msg );
|
void CL_ParseEvent( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_ParseReliableEvent( sizebuf_t *msg );
|
void CL_ParseReliableEvent( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_SetEventIndex( const char *szEvName, int ev_index );
|
void CL_SetEventIndex( const char *szEvName, int ev_index );
|
||||||
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
|
void CL_PlaybackEvent( int flags, const edict_t *pInvoker, word eventindex, float delay, float *origin,
|
||||||
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||||
|
|
Loading…
Add table
Reference in a new issue