engine: client: consolidate usermsg registering and parsing for multiple protocols
This commit is contained in:
parent
ff47fbaedc
commit
17f194b9a3
4 changed files with 23 additions and 30 deletions
|
@ -1409,14 +1409,14 @@ CL_RegisterUserMessage
|
||||||
register new user message or update existing
|
register new user message or update existing
|
||||||
================
|
================
|
||||||
*/
|
*/
|
||||||
void CL_RegisterUserMessage( sizebuf_t *msg )
|
void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto )
|
||||||
{
|
{
|
||||||
char *pszName;
|
char *pszName;
|
||||||
int svc_num, size, bits;
|
int svc_num, size, bits;
|
||||||
|
|
||||||
svc_num = MSG_ReadByte( msg );
|
svc_num = MSG_ReadByte( msg );
|
||||||
|
|
||||||
if( cls.legacymode )
|
if( proto == PROTO_LEGACY || proto == PROTO_GOLDSRC )
|
||||||
{
|
{
|
||||||
size = MSG_ReadByte( msg );
|
size = MSG_ReadByte( msg );
|
||||||
bits = 8;
|
bits = 8;
|
||||||
|
@ -1427,7 +1427,16 @@ void CL_RegisterUserMessage( sizebuf_t *msg )
|
||||||
bits = 16;
|
bits = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
pszName = MSG_ReadString( msg );
|
if( proto == PROTO_GOLDSRC )
|
||||||
|
{
|
||||||
|
static char szName[17];
|
||||||
|
|
||||||
|
MSG_ReadBytes( msg, szName, sizeof( szName ) - 1 );
|
||||||
|
szName[16] = 0;
|
||||||
|
|
||||||
|
pszName = szName;
|
||||||
|
}
|
||||||
|
else pszName = MSG_ReadString( msg );
|
||||||
|
|
||||||
// important stuff
|
// important stuff
|
||||||
if( size == ( BIT( bits ) - 1 ) )
|
if( size == ( BIT( bits ) - 1 ) )
|
||||||
|
@ -2298,7 +2307,7 @@ CL_ParseUserMessage
|
||||||
handles all user messages
|
handles all user messages
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto )
|
||||||
{
|
{
|
||||||
byte pbuf[MAX_USERMSG_LENGTH];
|
byte pbuf[MAX_USERMSG_LENGTH];
|
||||||
int i, iSize;
|
int i, iSize;
|
||||||
|
@ -2338,7 +2347,7 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
|
||||||
// message with variable sizes receive an actual size as first byte
|
// message with variable sizes receive an actual size as first byte
|
||||||
if( iSize == -1 )
|
if( iSize == -1 )
|
||||||
{
|
{
|
||||||
if( cls.legacymode )
|
if( proto == PROTO_GOLDSRC || proto == PROTO_LEGACY )
|
||||||
iSize = MSG_ReadByte( msg );
|
iSize = MSG_ReadByte( msg );
|
||||||
else iSize = MSG_ReadWord( msg );
|
else iSize = MSG_ReadWord( msg );
|
||||||
}
|
}
|
||||||
|
@ -2624,7 +2633,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseAddAngle( msg );
|
CL_ParseAddAngle( msg );
|
||||||
break;
|
break;
|
||||||
case svc_usermessage:
|
case svc_usermessage:
|
||||||
CL_RegisterUserMessage( msg );
|
CL_RegisterUserMessage( msg, PROTO_CURRENT );
|
||||||
break;
|
break;
|
||||||
case svc_packetentities:
|
case svc_packetentities:
|
||||||
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_CURRENT );
|
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_CURRENT );
|
||||||
|
@ -2684,7 +2693,7 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseExec( msg );
|
CL_ParseExec( msg );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CL_ParseUserMessage( msg, cmd );
|
CL_ParseUserMessage( msg, cmd, PROTO_CURRENT );
|
||||||
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,7 +509,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseAddAngle( msg );
|
CL_ParseAddAngle( msg );
|
||||||
break;
|
break;
|
||||||
case svc_usermessage:
|
case svc_usermessage:
|
||||||
CL_RegisterUserMessage( msg );
|
CL_RegisterUserMessage( msg, PROTO_LEGACY );
|
||||||
break;
|
break;
|
||||||
case svc_packetentities:
|
case svc_packetentities:
|
||||||
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_LEGACY );
|
playerbytes = CL_ParsePacketEntities( msg, false, PROTO_LEGACY );
|
||||||
|
@ -574,7 +574,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
|
CL_ParseCvarValue( msg, true, PROTO_LEGACY );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CL_ParseUserMessage( msg, cmd );
|
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
|
||||||
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,22 +89,6 @@ static void CL_ParseNewMovevars( sizebuf_t *msg )
|
||||||
clgame.oldmovevars.features = clgame.movevars.features = host.features;
|
clgame.oldmovevars.features = clgame.movevars.features = host.features;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CL_ParseNewUserMsg( sizebuf_t *msg )
|
|
||||||
{
|
|
||||||
int svc_num, size;
|
|
||||||
char s[16];
|
|
||||||
|
|
||||||
svc_num = MSG_ReadByte( msg );
|
|
||||||
size = MSG_ReadByte( msg );
|
|
||||||
MSG_ReadBytes( msg, s, sizeof( s ));
|
|
||||||
|
|
||||||
s[15] = 0;
|
|
||||||
if( size == 255 )
|
|
||||||
size = -1;
|
|
||||||
|
|
||||||
CL_LinkUserMessage( s, svc_num, size );
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct delta_header_t
|
typedef struct delta_header_t
|
||||||
{
|
{
|
||||||
qboolean remove : 1;
|
qboolean remove : 1;
|
||||||
|
@ -676,7 +660,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseAddAngle( msg );
|
CL_ParseAddAngle( msg );
|
||||||
break;
|
break;
|
||||||
case svc_goldsrc_newusermsg:
|
case svc_goldsrc_newusermsg:
|
||||||
CL_ParseNewUserMsg( msg );
|
CL_RegisterUserMessage( msg, PROTO_GOLDSRC );
|
||||||
break;
|
break;
|
||||||
case svc_packetentities:
|
case svc_packetentities:
|
||||||
playerbytes = CL_ParsePacketEntitiesGS( msg, false );
|
playerbytes = CL_ParsePacketEntitiesGS( msg, false );
|
||||||
|
@ -741,7 +725,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg )
|
||||||
CL_ParseExec( msg );
|
CL_ParseExec( msg );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CL_ParseUserMessage( msg, cmd );
|
CL_ParseUserMessage( msg, cmd, PROTO_LEGACY );
|
||||||
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
cl.frames[cl.parsecountmod].graphdata.usr += MSG_GetNumBytesRead( msg ) - bufStart;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -875,7 +875,7 @@ void CL_ParseSignon( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_ParseRestore( sizebuf_t *msg );
|
void CL_ParseRestore( sizebuf_t *msg );
|
||||||
void CL_ParseStaticDecal( sizebuf_t *msg );
|
void CL_ParseStaticDecal( sizebuf_t *msg );
|
||||||
void CL_ParseAddAngle( sizebuf_t *msg );
|
void CL_ParseAddAngle( sizebuf_t *msg );
|
||||||
void CL_RegisterUserMessage( sizebuf_t *msg );
|
void CL_RegisterUserMessage( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_ParseResourceList( sizebuf_t *msg, connprotocol_t proto );
|
void CL_ParseResourceList( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_ParseMovevars( sizebuf_t *msg );
|
void CL_ParseMovevars( sizebuf_t *msg );
|
||||||
void CL_ParseResourceRequest( sizebuf_t *msg );
|
void CL_ParseResourceRequest( sizebuf_t *msg );
|
||||||
|
@ -897,7 +897,7 @@ qboolean CL_RequestMissingResources( void );
|
||||||
void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto );
|
void CL_RegisterResources( sizebuf_t *msg, connprotocol_t proto );
|
||||||
void CL_ParseViewEntity( sizebuf_t *msg );
|
void CL_ParseViewEntity( sizebuf_t *msg );
|
||||||
void CL_ParseServerTime( sizebuf_t *msg );
|
void CL_ParseServerTime( sizebuf_t *msg );
|
||||||
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
|
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num, connprotocol_t proto );
|
||||||
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
|
||||||
void CL_ParseTextMessage( sizebuf_t *msg );
|
void CL_ParseTextMessage( sizebuf_t *msg );
|
||||||
void CL_ParseExec( sizebuf_t *msg );
|
void CL_ParseExec( sizebuf_t *msg );
|
||||||
|
|
Loading…
Add table
Reference in a new issue