Browse Source

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

pull/2/head
Alibek Omarov 2 years ago
parent
commit
bd3dc71f39
  1. 70
      engine/server/sv_filter.c

70
engine/server/sv_filter.c

@ -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 )) Con_Reportf( S_ERROR "banid: no players\n" );
id += 5; return;
}
if( svs.clients ) if( id[0] == '#' )
{ {
if( id[0] == '#' ) Con_Printf( S_ERROR "banid: not supported\n" );
cl = SV_ClientById( Q_atoi( id + 1 )); 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;
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;
for( i = 0, cl1 = svs.clients; i < sv_maxclients->value; i++, cl1++ ) 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 );

Loading…
Cancel
Save