1
0
Fork 0
forked from fte/fteqw

Improved name matching. Added a clientkick command to empty a specific client slot. This makes the q3 remove bot menu item work.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3394 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-10-06 00:41:42 +00:00
parent 92b1572092
commit a01158a6e0

View file

@ -35,13 +35,39 @@ cvar_t sv_cheats = SCVARF("sv_cheats", "0", CVAR_LATCH);
extern cvar_t sv_public; extern cvar_t sv_public;
void deleetstring(char *match, char *leet)
{
char *s = match;
char *s2 = leet;
while(*s2)
{
*s = *s2 & ~128;
s2++;
if (*s == '3')
*s = 'e';
else if (*s == '4')
*s = 'a';
else if (*s == '1' || *s == '7')
*s = 'l';
else if (*s >= 18 && *s < 27)
*s = *s - 18 + '0';
else if (*s >= 'A' && *s <= 'Z')
*s = *s - 'A' + 'a';
else if (*s<' ' || *s == '~')
continue;
s++;
}
*s = '\0';
}
//generic helper function for naming players. //generic helper function for naming players.
client_t *SV_GetClientForString(char *name, int *id) client_t *SV_GetClientForString(char *name, int *id)
{ {
int i; int i;
char *s, *s2; char *s;
char nicename[80]; char nicename[80];
char niceclname[80];
client_t *cl; client_t *cl;
int first=0; int first=0;
@ -95,30 +121,10 @@ client_t *SV_GetClientForString(char *name, int *id)
continue; continue;
s = nicename; deleetstring(niceclname, cl->name);
s2 = cl->name; deleetstring(nicename, name);
while(*s2)
{
*s = *s2 & ~128;
s2++;
if (*s == '3')
*s = 'e';
else if (*s == '4')
*s = 'a';
else if (*s == '1' || *s == '7')
*s = 'l';
else if (*s >= 18 && *s < 27)
*s = *s - 18 + '0';
else if (*s >= 'A' && *s <= 'Z')
*s = *s - 'A' + 'a';
else if (*s<' ' || *s == '~')
continue;
s++; if (strstr(niceclname, nicename))
}
*s = '\0';
if (strstr(nicename, name))
{ {
if (id) if (id)
*id=i+1; *id=i+1;
@ -652,6 +658,9 @@ void SV_Kick_f (void)
client_t *cl; client_t *cl;
int clnum=-1; int clnum=-1;
if (!sv.state)
return;
while((cl = SV_GetClientForString(Cmd_Argv(1), &clnum))) while((cl = SV_GetClientForString(Cmd_Argv(1), &clnum)))
{ {
SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTWASKICKED, cl->name); SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTWASKICKED, cl->name);
@ -667,6 +676,31 @@ void SV_Kick_f (void)
Con_TPrintf (STL_USERDOESNTEXIST, Cmd_Argv(1)); Con_TPrintf (STL_USERDOESNTEXIST, Cmd_Argv(1));
} }
/*for q3's kick bot menu*/
void SV_KickSlot_f (void)
{
client_t *cl;
int clnum=atoi(Cmd_Argv(1));
if (!sv.state)
return;
if (clnum < sv.allocated_client_slots && svs.clients[clnum].state)
{
cl = &svs.clients[clnum];
SV_BroadcastTPrintf (PRINT_HIGH, STL_CLIENTWASKICKED, cl->name);
// print directly, because the dropped client won't get the
// SV_BroadcastPrintf message
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUWEREKICKED);
SV_LogPlayer(cl, "kicked");
SV_DropClient (cl);
}
else
Con_Printf("Client %i is not active\n", clnum);
}
void SV_BanName_f (void) void SV_BanName_f (void)
{ {
client_t *cl; client_t *cl;
@ -2065,6 +2099,7 @@ void SV_InitOperatorCommands (void)
//various punishments //various punishments
Cmd_AddCommand ("kick", SV_Kick_f); Cmd_AddCommand ("kick", SV_Kick_f);
Cmd_AddCommand ("clientkick", SV_KickSlot_f);
Cmd_AddCommand ("mute", SV_Mute_f); Cmd_AddCommand ("mute", SV_Mute_f);
Cmd_AddCommand ("cuff", SV_Cuff_f); Cmd_AddCommand ("cuff", SV_Cuff_f);
Cmd_AddCommand ("renameclient", SV_ForceName_f); Cmd_AddCommand ("renameclient", SV_ForceName_f);