add sv_floodprotect_suicide, sv_floodprotect_sendmessage, add floodprot legacy command

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2308 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-30 04:00:24 +00:00
parent c91b804c1e
commit 22ad876a50
5 changed files with 50 additions and 18 deletions

View File

@ -2131,15 +2131,11 @@ client_connect: //fixme: make function
if (!allowremotecmd && (!*localid.string || strcmp(localid.string, s))) {
if (!*localid.string) {
Con_TPrintf (TL_LINEBREAK_EQUALS);
Con_TPrintf (TLC_LOCALID_NOTSET);
Con_TPrintf (TL_LINEBREAK_EQUALS);
return;
}
Con_TPrintf (TL_LINEBREAK_EQUALS);
Con_TPrintf (TLC_LOCALID_BAD,
s, localid.string);
Con_TPrintf (TL_LINEBREAK_EQUALS);
Cvar_Set(&localid, "");
return;
}
@ -2818,10 +2814,7 @@ void VARGS Host_EndGame (char *message, ...)
va_start (argptr,message);
vsnprintf (string,sizeof(string)-1, message,argptr);
va_end (argptr);
Con_TPrintf (TL_NL);
Con_TPrintf (TL_LINEBREAK_EQUALS);
Con_TPrintf (TLC_CLIENTCON_ERROR_ENDGAME, string);
Con_TPrintf (TL_LINEBREAK_EQUALS);
Con_TPrintf (TL_NL);
SCR_EndLoadingPlaque();

View File

@ -214,9 +214,8 @@ static char *defaultlanguagetext =
"TLC_CONNECTED \"Connected.\\n\"\n"
"TLC_CONLESS_CONCMD \"client command\\n\"\n"
"TLC_CMDFROMREMOTE \"Command packet from remote host. Ignored.\\n\"\n"
"TL_LINEBREAK_EQUALS \"===========================\\n\"\n"
"TLC_LOCALID_NOTSET \"Command packet received from local host, but no localid has been set. You may need to upgrade your server browser.\\n\"\n"
"TLC_LOCALID_BAD \"Invalid localid on command packet received from local host. \\n|%s| != |%s|\\nYou may need to reload your server browser and QuakeWorld.\\n\"\n"
"TLC_LOCALID_NOTSET \""S_ERROR"Command packet received from local host, but no localid has been set. You may need to upgrade your server browser.\\n\"\n"
"TLC_LOCALID_BAD \""S_ERROR"Invalid localid on command packet received from local host. \\n|%s| != |%s|\\nYou may need to reload your server browser and QuakeWorld.\\n\"\n"
"TLC_A2C_PRINT \"print\\n\"\n"
"TLC_A2A_PING \"ping\\n\"\n"
"TLC_S2C_CHALLENGE \"challenge\\n\"\n"
@ -226,7 +225,7 @@ static char *defaultlanguagetext =
"TLC_CONNECTFIRST \"Must be connected.\\n\"\n"
"TLC_SYNTAX_DOWNLOAD \"Usage: download <datafile>\\n\"\n"
"TLC_REQUIRESSERVERMOD \"%s is only available with server support\\n\"\n"
"TLC_CLIENTCON_ERROR_ENDGAME \"Host_EndGame: "S_ERROR"%s\\n\"\n"
"TLC_CLIENTCON_ERROR_ENDGAME \""S_ERROR"Host_EndGame: %s\\n\"\n"
"TLC_HOSTFATALERROR \"Host_Error: %s\\n\"\n"
"TLC_CONFIGCFG_WRITEFAILED \"Couldn't write config.cfg.\\n\"\n"
"TLC_HOSTSPEEDSOUTPUT \"%3i tot %3i server %3i gfx %3i snd\\n\"\n"

View File

@ -255,7 +255,6 @@
NAME(TLC_CONNECTED)
NAME(TLC_CONLESS_CONCMD)
NAME(TLC_CMDFROMREMOTE)
NAME(TL_LINEBREAK_EQUALS)
NAME(TLC_LOCALID_NOTSET)
NAME(TLC_LOCALID_BAD)
NAME(TLC_A2C_PRINT)

View File

@ -1072,6 +1072,36 @@ void SV_Cuff_f (void)
Con_TPrintf (STL_USERDOESNTEXIST, Cmd_Argv(1));
}
void SV_Floodprot_f(void)
{
extern cvar_t sv_floodprotect;
extern cvar_t sv_floodprotect_messages;
extern cvar_t sv_floodprotect_interval;
extern cvar_t sv_floodprotect_silencetime;
if (Cmd_Argc() == 1)
{
if (sv_floodprotect_messages.value <= 0 || !sv_floodprotect.value)
Con_Printf("Flood protection is off.\n");
else
Con_Printf("Current flood protection settings: \nAfter %g msgs for %g seconds, silence for %g seconds\n",
sv_floodprotect_messages.value,
sv_floodprotect_interval.value,
sv_floodprotect_silencetime.value);
return;
}
if (Cmd_Argc() != 4)
{
Con_Printf("Usage: %s <messagerate> <ratepersecond> <silencetime>\n", Cmd_Argv(0));
return;
}
Cvar_SetValue(&sv_floodprotect_messages, atof(Cmd_Argv(1)));
Cvar_SetValue(&sv_floodprotect_interval, atof(Cmd_Argv(2)));
Cvar_SetValue(&sv_floodprotect_silencetime, atof(Cmd_Argv(3)));
}
void SV_StuffToClient_f(void)
{ //with this we emulate the progs 'stuffcmds' builtin
@ -1922,6 +1952,8 @@ void SV_InitOperatorCommands (void)
Cmd_AddCommand ("listip", SV_FilterList_f);
Cmd_AddCommand ("writeip", SV_WriteIP_f);
Cmd_AddCommand ("floodprot", SV_Floodprot_f);
// Cmd_AddCommand ("filterip", SV_FilterIP_f);
// Cmd_AddCommand ("unfilter", SV_Unfilter_f);
// Cmd_AddCommand ("filterlist", SV_FilterList_f);

View File

@ -62,6 +62,8 @@ cvar_t sv_floodprotect = SCVAR("sv_floodprotect", "1");
cvar_t sv_floodprotect_messages = SCVAR("sv_floodprotect_messages", "4");
cvar_t sv_floodprotect_interval = SCVAR("sv_floodprotect_interval", "4");
cvar_t sv_floodprotect_silencetime = SCVAR("sv_floodprotect_silencetime", "10");
cvar_t sv_floodprotect_suicide = SCVAR("sv_floodprotect_suicide", "1");
cvar_t sv_floodprotect_sendmessage = FCVAR("sv_floodprotect_sendmessage", "floodprotmsg", "", 0);
cvar_t votelevel = SCVAR("votelevel", "0");
cvar_t voteminimum = SCVAR("voteminimum", "4");
@ -1867,7 +1869,7 @@ float SV_CheckFloodProt(client_t *client)
{
if (!sv_floodprotect.value)
return 0;
if (sv_floodprotect_messages.value < 0 || sv_floodprotect_interval.value < 0)
if (sv_floodprotect_messages.value <= 0 || sv_floodprotect_interval.value <= 0)
return 0;
if (sv.paused)
return 0;
@ -1879,6 +1881,8 @@ float SV_CheckFloodProt(client_t *client)
client->lockedtill = realtime + sv_floodprotect_silencetime.value;
client->floodprotmessage = 0.0;
client->lastspoke = 0.0;
if (sv_floodprotect_sendmessage.string[0])
SV_ClientPrintf(client, PRINT_CHAT, "FloodProt: %s\n", sv_floodprotect_sendmessage.string);
return sv_floodprotect_silencetime.value;
}
@ -1889,7 +1893,7 @@ void SV_PushFloodProt(client_t *client)
{
if (!sv_floodprotect.value)
return;
if (sv_floodprotect_messages.value < 0 || sv_floodprotect_interval.value < 0)
if (sv_floodprotect_messages.value <= 0 || sv_floodprotect_interval.value <= 0)
return;
if (sv.paused)
return;
@ -2144,12 +2148,15 @@ void SV_Kill_f (void)
return;
}
if ((floodtime = SV_CheckFloodProt(host_client)))
if (sv_floodprotect_suicide.value)
{
SV_ClientPrintf (host_client, PRINT_HIGH, "You can't suicide for %i seconds\n", (int)floodtime);
return;
if ((floodtime = SV_CheckFloodProt(host_client)))
{
SV_ClientPrintf (host_client, PRINT_HIGH, "You can't suicide for %i seconds\n", (int)floodtime);
return;
}
SV_PushFloodProt(host_client);
}
SV_PushFloodProt(host_client);
pr_global_struct->time = sv.time;
pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, sv_player);
@ -5081,6 +5088,8 @@ void SV_UserInit (void)
Cvar_Register (&sv_floodprotect_interval, cvargroup_servercontrol);
Cvar_Register (&sv_floodprotect_messages, cvargroup_servercontrol);
Cvar_Register (&sv_floodprotect_silencetime, cvargroup_servercontrol);
Cvar_Register (&sv_floodprotect_suicide, cvargroup_servercontrol);
Cvar_Register (&sv_floodprotect_sendmessage, cvargroup_servercontrol);
Cvar_Register (&sv_cmdlikercon, cvargroup_serverpermissions);
Cvar_Register(&cmd_gamecodelevel, "Access controls");