engine: server: avoid useless copying in SV_GetClientIDString for bots or local clients

This commit is contained in:
Alibek Omarov 2024-12-05 19:49:51 +03:00
parent b28c1186b2
commit 0a85734ae7

View file

@ -770,27 +770,21 @@ Returns a pointer to a static char for most likely only printing.
*/
const char *SV_GetClientIDString( sv_client_t *cl )
{
static char result[MAX_QPATH];
static char result[MAX_QPATH];
if( !cl ) return "";
if( !cl )
return "";
if( FBitSet( cl->flags, FCL_FAKECLIENT ))
{
Q_strncpy( result, "ID_BOT", sizeof( result ));
}
else if( NET_IsLocalAddress( cl->netchan.remote_address ))
{
Q_strncpy( result, "ID_LOOPBACK", sizeof( result ));
}
else if( sv_lan.value )
{
Q_strncpy( result, "ID_LAN", sizeof( result ));
}
else
{
Q_snprintf( result, sizeof( result ), "ID_%s", MD5_Print( (byte *)cl->hashedcdkey ));
}
return "ID_BOT";
if( NET_IsLocalAddress( cl->netchan.remote_address ))
return "ID_LOOPBACK";
if( sv_lan.value )
return "ID_LAN";
Q_snprintf( result, sizeof( result ), "ID_%s", MD5_Print( (byte *)cl->hashedcdkey ));
return result;
}