engine: server: refactor banid, explicitly does not allow ban using userid for now

This commit is contained in:
Alibek Omarov 2023-04-28 16:24:09 +03:00
parent 48176233bd
commit bd3dc71f39
1 changed files with 42 additions and 30 deletions

View File

@ -104,51 +104,63 @@ static void SV_BanID_f( void )
return; return;
} }
if( !Q_strnicmp( id, "STEAM_", 6 ) || !Q_strnicmp( id, "VALVE_", 6 )) if( !svs.clients )
id += 6;
if( !Q_strnicmp( id, "XASH_", 5 ))
id += 5;
if( svs.clients )
{ {
if( id[0] == '#' ) Con_Reportf( S_ERROR "banid: no players\n" );
cl = SV_ClientById( Q_atoi( id + 1 )); return;
}
if( id[0] == '#' )
{
Con_Printf( S_ERROR "banid: not supported\n" );
return;
#if 0
int i = Q_atoi( &id[1] );
cl = SV_ClientById( i );
if( !cl ) if( !cl )
{ {
int i; Con_Printf( S_ERROR "banid: no such player with userid %d\n", i );
sv_client_t *cl1; return;
int len = Q_strlen( id ); }
#endif
}
else
{
size_t len;
int i;
for( i = 0, cl1 = svs.clients; i < sv_maxclients->value; i++, cl1++ ) if( !Q_strnicmp( id, "STEAM_", 6 ) || !Q_strnicmp( id, "VALVE_", 6 ))
id += 6;
if( !Q_strnicmp( id, "XASH_", 5 ))
id += 5;
len = Q_strlen( id );
for( i = 0; i < sv_maxclients->value; i++ )
{
if( FBitSet( svs.clients[i].flags, FCL_FAKECLIENT ))
continue;
if( svs.clients[i].state != cs_spawned )
continue;
if( !Q_strncmp( id, Info_ValueForKey( svs.clients[i].useragent, "uuid" ), len ))
{ {
if( !Q_strncmp( id, Info_ValueForKey( cl1->useragent, "uuid" ), len )) cl = &svs.clients[i];
{ break;
cl = cl1;
break;
}
} }
} }
if( !cl ) if( !cl )
{ {
Con_DPrintf( S_WARN "banid: no such player\n" ); Con_Printf( S_ERROR "banid: no such player with userid %s\n", id );
}
else
id = Info_ValueForKey( cl->useragent, "uuid" );
if( !id[0] )
{
Con_DPrintf( S_ERROR "Could not ban, not implemented yet\n" );
return; return;
} }
} }
if( !id[0] || id[0] == '#' ) id = Info_ValueForKey( cl->useragent, "uuid" );
{
Con_DPrintf( S_ERROR "banid: bad id\n" );
return;
}
SV_RemoveID( id ); SV_RemoveID( id );