legacymode: some codestyle fixes

This commit is contained in:
Alibek Omarov 2019-01-27 03:02:16 +03:00
parent 860d3be42d
commit 6ba406be7d
5 changed files with 47 additions and 11 deletions

View File

@ -721,7 +721,10 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
CL_WriteDemoJumpTime();
// sentinel count. save it for debug checking
count = cls.legacymode?MSG_ReadWord( msg ) : ( MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1 );
if( cls.legacymode )
count = MSG_ReadWord( msg );
else count = MSG_ReadUBitLong( msg, MAX_VISIBLE_PACKET_BITS ) + 1;
newframe = &cl.frames[cl.parsecountmod];
// allocate parse entities
@ -795,8 +798,19 @@ int CL_ParsePacketEntities( sizebuf_t *msg, qboolean delta )
while( 1 )
{
newnum = cls.legacymode ? MSG_ReadWord( msg ) : MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
if( newnum == (cls.legacymode?0:LAST_EDICT) ) break; // end of packet entities
int lastedict;
if( cls.legacymode )
{
newnum = MSG_ReadWord( msg );
lastedict = 0;
}
else
{
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
lastedict = LAST_EDICT;
}
if( newnum == lastedict ) break; // end of packet entities
if( MSG_CheckOverflow( msg ))
Host_Error( "CL_ParsePacketEntities: overflow\n" );
player = CL_IsPlayerIndex( newnum );

View File

@ -1295,14 +1295,26 @@ register new user message or update existing
void CL_RegisterUserMessage( sizebuf_t *msg )
{
char *pszName;
int svc_num, size;
int svc_num, size, bits;
svc_num = MSG_ReadByte( msg );
size = cls.legacymode?MSG_ReadByte( msg ):MSG_ReadWord( msg );
if( cls.legacymode )
{
size = MSG_ReadByte( msg );
bits = 8;
}
else
{
size = MSG_ReadWord( msg );
bits = 16;
}
pszName = MSG_ReadString( msg );
// important stuff
if( size == (cls.legacymode?0xFF:0xFFFF) ) size = -1;
if( size == ( BIT( bits ) - 1 ) )
size = -1;
svc_num = bound( 0, svc_num, 255 );
CL_LinkUserMessage( pszName, svc_num, size );
@ -1958,7 +1970,13 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
iSize = clgame.msg[i].size;
// message with variable sizes receive an actual size as first byte
if( iSize == -1 ) iSize = cls.legacymode?MSG_ReadByte( msg ):MSG_ReadWord( msg );
if( iSize == -1 )
{
if( cls.legacymode )
iSize = MSG_ReadByte( msg );
else iSize = MSG_ReadWord( msg );
}
if( iSize >= MAX_USERMSG_LENGTH )
{
Msg("WTF??? %d %d\n", i, svc_num );

View File

@ -2024,7 +2024,7 @@ void CL_ParseTempEntity( sizebuf_t *msg )
{
sizebuf_t buf;
byte pbuf[256];
int iSize = cls.legacymode?MSG_ReadByte( msg ):MSG_ReadWord( msg );
int iSize;
int type, color, count, flags;
int decalIndex, modelIndex, entityIndex;
float scale, life, frameRate, vel, random;
@ -2035,6 +2035,10 @@ void CL_ParseTempEntity( sizebuf_t *msg )
cl_entity_t *pEnt;
dlight_t *dl;
if( cls.legacymode )
iSize = MSG_ReadByte( msg );
else iSize = MSG_ReadWord( msg );
decalIndex = modelIndex = entityIndex = 0;
// parse user message into buffer