engine: don't bother calculating crc32 for local clients for better performance (thanks @tyabus for the idea)

This commit is contained in:
Alibek Omarov 2025-01-14 11:55:28 +03:00
parent 785632a437
commit 38c82a3f76
2 changed files with 12 additions and 9 deletions

View file

@ -825,7 +825,7 @@ static void CL_WritePacket( void )
buf.pData[key] = CRC32_BlockSequence( &buf.pData[key + 1], size, cls.netchan.outgoing_sequence );
COM_Munge( &buf.pData[key + 1], Q_min( size, 255 ), cls.netchan.outgoing_sequence );
}
else
else if( !Host_IsLocalClient( ))
{
int size = MSG_GetRealBytesWritten( &buf ) - key - 1;
buf.pData[key] = CRC32_BlockSequence( &buf.pData[key + 1], size, cls.netchan.outgoing_sequence );

View file

@ -3227,7 +3227,7 @@ each of the backup packets.
static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
{
client_frame_t *frame;
int key, size, checksum1, checksum2;
int key, checksum1;
int i, numbackup, totalcmds, numcmds;
usercmd_t nullcmd, *to, *from;
usercmd_t cmds[CMD_BACKUP];
@ -3270,14 +3270,17 @@ static void SV_ParseClientMove( sv_client_t *cl, sizebuf_t *msg )
if( cl->state != cs_spawned )
return;
// if the checksum fails, ignore the rest of the packet
size = MSG_GetRealBytesRead( msg ) - key - 1;
checksum2 = CRC32_BlockSequence( msg->pData + key + 1, size, cl->netchan.incoming_sequence );
if( checksum2 != checksum1 )
if( !Host_IsLocalClient( ))
{
Con_Reportf( S_ERROR "%s: failed command checksum for %s (%d != %d)\n", __func__, cl->name, checksum2, checksum1 );
return;
// if the checksum fails, ignore the rest of the packet
int size = MSG_GetRealBytesRead( msg ) - key - 1;
int checksum2 = CRC32_BlockSequence( msg->pData + key + 1, size, cl->netchan.incoming_sequence );
if( checksum2 != checksum1 )
{
Con_Reportf( S_ERROR "%s: failed command checksum for %s (%d != %d)\n", __func__, cl->name, checksum2, checksum1 );
return;
}
}
cl->packet_loss = packet_loss;