Skip to content

Commit

Permalink
engine: server: avoid useless copying in SV_GetClientIDString for bot…
Browse files Browse the repository at this point in the history
…s or local clients
  • Loading branch information
a1batross committed Dec 5, 2024
1 parent b28c118 commit 0a85734
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions engine/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 0a85734

Please sign in to comment.