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

@ -393,7 +393,7 @@ void CL_ParseEvent( sizebuf_t *msg )
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, cls.legacymode ? MAX_LEGACY_ENTITY_BITS : MAX_ENTITY_BITS );
else packet_index = -1; else packet_index = -1;
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))

View File

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

View File

@ -1128,7 +1128,7 @@ void CL_ParseClientData( sizebuf_t *msg )
if( !MSG_ReadOneBit( msg )) break; if( !MSG_ReadOneBit( msg )) break;
// read the weapon idx // read the weapon idx
idx = MSG_ReadUBitLong( msg, cls.legacymode?MAX_LEGACY_WEAPON_BITS:MAX_WEAPON_BITS ); idx = MSG_ReadUBitLong( msg, cls.legacymode ? MAX_LEGACY_WEAPON_BITS : MAX_WEAPON_BITS );
MSG_ReadWeaponData( msg, &from_wd[idx], &to_wd[idx], cl.mtime[0] ); MSG_ReadWeaponData( msg, &from_wd[idx], &to_wd[idx], cl.mtime[0] );
} }
@ -1295,14 +1295,26 @@ register new user message or update existing
void CL_RegisterUserMessage( sizebuf_t *msg ) void CL_RegisterUserMessage( sizebuf_t *msg )
{ {
char *pszName; char *pszName;
int svc_num, size; int svc_num, size, bits;
svc_num = MSG_ReadByte( msg ); 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 ); pszName = MSG_ReadString( msg );
// important stuff // important stuff
if( size == (cls.legacymode?0xFF:0xFFFF) ) size = -1; if( size == ( BIT( bits ) - 1 ) )
size = -1;
svc_num = bound( 0, svc_num, 255 ); svc_num = bound( 0, svc_num, 255 );
CL_LinkUserMessage( pszName, svc_num, size ); CL_LinkUserMessage( pszName, svc_num, size );
@ -1958,7 +1970,13 @@ void CL_ParseUserMessage( sizebuf_t *msg, int svc_num )
iSize = clgame.msg[i].size; iSize = clgame.msg[i].size;
// 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 ) 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 ) if( iSize >= MAX_USERMSG_LENGTH )
{ {
Msg("WTF??? %d %d\n", i, svc_num ); Msg("WTF??? %d %d\n", i, svc_num );

View File

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

View File

@ -1890,7 +1890,7 @@ qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state
to->entityType = MSG_ReadUBitLong( msg, 2 ); to->entityType = MSG_ReadUBitLong( msg, 2 );
to->number = number; to->number = number;
if( cls.legacymode?(to->entityType == ENTITY_BEAM):FBitSet(to->entityType, ENTITY_BEAM) ) if( cls.legacymode ? ( to->entityType == ENTITY_BEAM ) : FBitSet( to->entityType, ENTITY_BEAM ))
{ {
dt = Delta_FindStruct( "custom_entity_state_t" ); dt = Delta_FindStruct( "custom_entity_state_t" );
} }