mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-29 07:02:12 +00:00
remove floodprot and floodprotmsg commands, add sv_floodprotect_messages/sv_floodprotect_interval/sv_floodprotect_silencetime cvars to replace old functionality, needs testing
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2306 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
e529c86c55
commit
4942e86843
8 changed files with 46 additions and 118 deletions
|
@ -48,7 +48,7 @@
|
|||
"STL_SERVERPAUSED \"server is paused\\n\"\n"
|
||||
"STL_UPLOADDENIED \"Upload denied\\n\"\n"
|
||||
"STL_NAMEDCLIENTDOESNTEXIST \"client does not exist\\n\"\n"
|
||||
"STL_NOSUISIDEWHENDEAD \"Can't suiside -- Already dead\\n\"\n"
|
||||
"STL_NOSUICIDEWHENDEAD \"Can't suicide -- Already dead\\n\"\n"
|
||||
"STL_CANTPAUSE \"Can't pause. Not allowed\\n\"\n"
|
||||
"STL_CANTPAUSESPEC \"Spectators may not pause the game\\n\"\n"
|
||||
"STL_CLIENTPAUSED \"%s paused the game\\n\"\n"
|
||||
|
@ -170,13 +170,7 @@
|
|||
"STL_LOCALINFOSETTINGS \"Local info settings:\\n\"\n"
|
||||
"STL_LOCALINFOSYNTAX \"usage: localinfo [ <key> <value> ]\\n\"\n"
|
||||
"STL_USERINFOSYNTAX \"Usage: info <userid>\\n\"\n"
|
||||
"STL_FLOODPROTSETTINGS \"Current floodprot settings: \\nAfter %d msgs per %d seconds, silence for %d seconds\\n\"\n"
|
||||
"STL_FLOODPROTNOTON \"No floodprots enabled.\\n\"\n"
|
||||
"STL_FLOODPROTSYNTAX \"Usage: floodprot <# of messages> <per # of seconds> <seconds to silence>\\nUse floodprotmsg to set a custom message to say to the flooder.\\n\"\n"
|
||||
"STL_NONEGATIVEVALUES \"All values must be positive numbers\\n\"\n"
|
||||
"STL_TRACK10PLUSSMESSAGES \"Can only track up to 10 messages.\\n\"\n"
|
||||
"STL_FLOODPROTCURRENTMESSAGE \"Current msg: %s\\n\"\n"
|
||||
"STL_FLOODPROTMESSAGESYNTAX \"Usage: floodprotmsg \\\"<message>\\\"\\n\"\n"
|
||||
"STL_CURRENTGAMEDIR \"Current gamedir: %s\\n\"\n"
|
||||
"STL_SVGAMEDIRUSAGE \"Usage: sv_gamedir <newgamedir>\\n\"\n"
|
||||
"STL_GAMEDIRCANTBEPATH \"*Gamedir should be a single filename, not a path\\n\"\n"
|
||||
|
|
|
@ -56,7 +56,7 @@ static char *defaultlanguagetext =
|
|||
"STL_SERVERPAUSED \"server is paused\\n\"\n"
|
||||
"STL_UPLOADDENIED \"Upload denied\\n\"\n"
|
||||
"STL_NAMEDCLIENTDOESNTEXIST \"client does not exist\\n\"\n"
|
||||
"STL_NOSUISIDEWHENDEAD \"Can't suiside -- Already dead\\n\"\n"
|
||||
"STL_NOSUICIDEWHENDEAD \"Can't suicide -- Already dead\\n\"\n"
|
||||
"STL_CANTPAUSE \"Can't pause. Not allowed\\n\"\n"
|
||||
"STL_CANTPAUSESPEC \"Spectators may not pause the game\\n\"\n"
|
||||
"STL_CLIENTPAUSED \"%s paused the game\\n\"\n"
|
||||
|
@ -177,13 +177,7 @@ static char *defaultlanguagetext =
|
|||
"STL_LOCALINFOSETTINGS \"Local info settings:\\n\"\n"
|
||||
"STL_LOCALINFOSYNTAX \"usage: localinfo [ <key> <value> ]\\n\"\n"
|
||||
"STL_USERINFOSYNTAX \"Usage: info <userid>\\n\"\n"
|
||||
"STL_FLOODPROTSETTINGS \"Current floodprot settings: \\nAfter %d msgs per %d seconds, silence for %d seconds\\n\"\n"
|
||||
"STL_FLOODPROTNOTON \"No floodprots enabled.\\n\"\n"
|
||||
"STL_FLOODPROTSYNTAX \"Usage: floodprot <# of messages> <per # of seconds> <seconds to silence>\\nUse floodprotmsg to set a custom message to say to the flooder.\\n\"\n"
|
||||
"STL_NONEGATIVEVALUES \"All values must be positive numbers\\n\"\n"
|
||||
"STL_TRACK10PLUSSMESSAGES \"Can only track up to 10 messages.\\n\"\n"
|
||||
"STL_FLOODPROTCURRENTMESSAGE \"Current msg: %s\\n\"\n"
|
||||
"STL_FLOODPROTMESSAGESYNTAX \"Usage: floodprotmsg \\\"<message>\\\"\\n\"\n"
|
||||
"STL_CURRENTGAMEDIR \"Current gamedir: %s\\n\"\n"
|
||||
"STL_SVGAMEDIRUSAGE \"Usage: sv_gamedir <newgamedir>\\n\"\n"
|
||||
"STL_GAMEDIRCANTBEPATH \"*Gamedir should be a single filename, not a path\\n\"\n"
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
NAME(STL_SERVERPAUSED)
|
||||
NAME(STL_UPLOADDENIED)
|
||||
NAME(STL_NAMEDCLIENTDOESNTEXIST)
|
||||
NAME(STL_NOSUISIDEWHENDEAD)
|
||||
NAME(STL_NOSUICIDEWHENDEAD)
|
||||
NAME(STL_CANTPAUSE)
|
||||
NAME(STL_CANTPAUSESPEC)
|
||||
NAME(STL_CLIENTPAUSED)
|
||||
|
@ -214,13 +214,7 @@
|
|||
NAME(STL_LOCALINFOSETTINGS)
|
||||
NAME(STL_LOCALINFOSYNTAX)
|
||||
NAME(STL_USERINFOSYNTAX)
|
||||
NAME(STL_FLOODPROTSETTINGS)
|
||||
NAME(STL_FLOODPROTNOTON)
|
||||
NAME(STL_FLOODPROTSYNTAX)
|
||||
NAME(STL_NONEGATIVEVALUES)
|
||||
NAME(STL_TRACK10PLUSSMESSAGES)
|
||||
NAME(STL_FLOODPROTCURRENTMESSAGE)
|
||||
NAME(STL_FLOODPROTMESSAGESYNTAX)
|
||||
NAME(STL_CURRENTGAMEDIR)
|
||||
NAME(STL_SVGAMEDIRUSAGE)
|
||||
NAME(STL_GAMEDIRCANTBEPATH)
|
||||
|
|
|
@ -5183,7 +5183,7 @@ void PF_logfrag (progfuncs_t *prinst, struct globalvars_s *pr_globals)
|
|||
return;
|
||||
|
||||
#ifdef SVRANKING
|
||||
if (e1 != e2) //don't get a point for suiside.
|
||||
if (e1 != e2) //don't get a point for suicide.
|
||||
svs.clients[e1-1].kills += 1;
|
||||
svs.clients[e2-1].deaths += 1;
|
||||
#endif
|
||||
|
|
|
@ -436,8 +436,8 @@ typedef struct client_s
|
|||
|
||||
qbyte istobeloaded; //loadgame creates place holders for clients to connect to. Effectivly loading a game reconnects all clients, but has precreated ents.
|
||||
|
||||
double whensaid[10]; // JACK: For floodprots
|
||||
int whensaidhead; // Head value for floodprots
|
||||
double floodprotmessage;
|
||||
double lastspoke;
|
||||
double lockedtill;
|
||||
|
||||
qboolean upgradewarn; // did we warn him?
|
||||
|
|
|
@ -29,8 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
qboolean sv_allow_cheats;
|
||||
|
||||
int fp_messages=4, fp_persecond=4, fp_secondsdead=10;
|
||||
char fp_msg[255] = { 0 };
|
||||
extern cvar_t cl_warncmd;
|
||||
cvar_t sv_cheats = SCVARF("sv_cheats", "0", CVAR_LATCH);
|
||||
extern redirect_t sv_redirected;
|
||||
|
@ -1539,65 +1537,6 @@ Sets the gamedir and path to a different directory.
|
|||
================
|
||||
*/
|
||||
|
||||
void SV_Floodprot_f (void)
|
||||
{
|
||||
int arg1, arg2, arg3;
|
||||
|
||||
if (Cmd_Argc() == 1)
|
||||
{
|
||||
if (fp_messages)
|
||||
{
|
||||
Con_TPrintf (STL_FLOODPROTSETTINGS,
|
||||
fp_messages, fp_persecond, fp_secondsdead);
|
||||
return;
|
||||
}
|
||||
else
|
||||
Con_TPrintf (STL_FLOODPROTNOTON);
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 4)
|
||||
{
|
||||
Con_TPrintf (STL_FLOODPROTSYNTAX);
|
||||
return;
|
||||
}
|
||||
|
||||
arg1 = atoi(Cmd_Argv(1));
|
||||
arg2 = atoi(Cmd_Argv(2));
|
||||
arg3 = atoi(Cmd_Argv(3));
|
||||
|
||||
if (arg1<=0 || arg2 <= 0 || arg3<=0)
|
||||
{
|
||||
Con_TPrintf (STL_NONEGATIVEVALUES);
|
||||
return;
|
||||
}
|
||||
|
||||
if (arg1 > 10)
|
||||
{
|
||||
Con_TPrintf (STL_TRACK10PLUSSMESSAGES);
|
||||
return;
|
||||
}
|
||||
|
||||
fp_messages = arg1;
|
||||
fp_persecond = arg2;
|
||||
fp_secondsdead = arg3;
|
||||
}
|
||||
|
||||
void SV_Floodprotmsg_f (void)
|
||||
{
|
||||
if (Cmd_Argc() == 1)
|
||||
{
|
||||
Con_TPrintf(STL_FLOODPROTCURRENTMESSAGE, fp_msg);
|
||||
return;
|
||||
}
|
||||
else if (Cmd_Argc() != 2)
|
||||
{
|
||||
Con_TPrintf(STL_FLOODPROTMESSAGESYNTAX);
|
||||
return;
|
||||
}
|
||||
snprintf(fp_msg, sizeof(fp_msg), "%s", Cmd_Argv(1));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
SV_Gamedir
|
||||
|
@ -1955,8 +1894,6 @@ void SV_InitOperatorCommands (void)
|
|||
Cmd_AddCommand ("localinfo", SV_Localinfo_f);
|
||||
Cmd_AddCommand ("gamedir", SV_Gamedir_f);
|
||||
Cmd_AddCommand ("sv_gamedir", SV_Gamedir);
|
||||
Cmd_AddCommand ("floodprot", SV_Floodprot_f);
|
||||
Cmd_AddCommand ("floodprotmsg", SV_Floodprotmsg_f);
|
||||
Cmd_AddCommand ("sv_settimer", SV_SetTimer_f);
|
||||
Cmd_AddCommand ("stuffcmd", SV_StuffToClient_f);
|
||||
|
||||
|
|
|
@ -1866,9 +1866,8 @@ client_t *SVC_DirectConnect(void)
|
|||
SV_GenerateBasicUserInfo (newcl);
|
||||
|
||||
// JACK: Init the floodprot stuff.
|
||||
for (i=0; i<10; i++)
|
||||
newcl->whensaid[i] = 0.0;
|
||||
newcl->whensaidhead = 0;
|
||||
newcl->floodprotmessage = 0.0;
|
||||
newcl->lastspoke = 0.0;
|
||||
newcl->lockedtill = 0;
|
||||
|
||||
#ifdef SVRANKING
|
||||
|
|
|
@ -59,6 +59,9 @@ cvar_t sv_brokenmovetypes = SCVAR("sv_brokenmovetypes", "0");
|
|||
cvar_t sv_chatfilter = SCVAR("sv_chatfilter", "0");
|
||||
|
||||
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 votelevel = SCVAR("votelevel", "0");
|
||||
cvar_t voteminimum = SCVAR("voteminimum", "4");
|
||||
|
@ -86,8 +89,6 @@ extern char cvargroup_servercontrol[];
|
|||
|
||||
extern vec3_t player_mins, player_maxs;
|
||||
|
||||
extern int fp_messages, fp_persecond, fp_secondsdead;
|
||||
extern char fp_msg[];
|
||||
extern cvar_t pausable;
|
||||
|
||||
|
||||
|
@ -1864,40 +1865,46 @@ void SV_SayOne_f (void)
|
|||
|
||||
float SV_CheckFloodProt(client_t *client)
|
||||
{
|
||||
int tmp;
|
||||
if (!sv_floodprotect.value)
|
||||
return 0;
|
||||
if (fp_messages)
|
||||
{
|
||||
if (!sv.paused && realtime<client->lockedtill)
|
||||
{
|
||||
if (sv_floodprotect_messages.value < 0 || sv_floodprotect_interval.value < 0)
|
||||
return 0;
|
||||
if (sv.paused)
|
||||
return 0;
|
||||
if (realtime < client->lockedtill)
|
||||
return client->lockedtill - realtime;
|
||||
}
|
||||
tmp = client->whensaidhead - fp_messages + 1;
|
||||
if (tmp < 0)
|
||||
tmp = 10+tmp;
|
||||
if (!sv.paused &&
|
||||
client->whensaid[tmp] && (realtime-client->whensaid[tmp] < fp_persecond))
|
||||
|
||||
if (client->floodprotmessage > sv_floodprotect_messages.value)
|
||||
{
|
||||
client->lockedtill = realtime + fp_secondsdead;
|
||||
if (fp_msg[0])
|
||||
SV_ClientPrintf(client, PRINT_CHAT,
|
||||
"FloodProt: %s\n", fp_msg);
|
||||
return fp_secondsdead;
|
||||
}
|
||||
client->lockedtill = realtime + sv_floodprotect_silencetime.value;
|
||||
client->floodprotmessage = 0.0;
|
||||
client->lastspoke = 0.0;
|
||||
return sv_floodprotect_silencetime.value;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SV_PushFloodProt(client_t *client)
|
||||
{
|
||||
if (fp_messages)
|
||||
if (!sv_floodprotect.value)
|
||||
return;
|
||||
if (sv_floodprotect_messages.value < 0 || sv_floodprotect_interval.value < 0)
|
||||
return;
|
||||
if (sv.paused)
|
||||
return;
|
||||
|
||||
if (client->lastspoke)
|
||||
{
|
||||
client->whensaidhead++;
|
||||
if (client->whensaidhead > 9)
|
||||
client->whensaidhead = 0;
|
||||
client->whensaid[client->whensaidhead] = realtime;
|
||||
client->floodprotmessage -= (realtime - client->lastspoke)
|
||||
* sv_floodprotect_messages.value
|
||||
/ sv_floodprotect_interval.value;
|
||||
client->floodprotmessage = max(0, client->floodprotmessage);
|
||||
client->floodprotmessage++;
|
||||
}
|
||||
else
|
||||
client->floodprotmessage = 1.0;
|
||||
client->lastspoke = realtime;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2133,13 +2140,13 @@ void SV_Kill_f (void)
|
|||
float floodtime;
|
||||
if (sv_player->v->health <= 0)
|
||||
{
|
||||
SV_ClientTPrintf (host_client, PRINT_HIGH, STL_NOSUISIDEWHENDEAD);
|
||||
SV_ClientTPrintf (host_client, PRINT_HIGH, STL_NOSUICIDEWHENDEAD);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((floodtime = SV_CheckFloodProt(host_client)))
|
||||
{
|
||||
SV_ClientPrintf (host_client, PRINT_HIGH, "You can't suiside for %i seconds\n", (int)floodtime);
|
||||
SV_ClientPrintf (host_client, PRINT_HIGH, "You can't suicide for %i seconds\n", (int)floodtime);
|
||||
return;
|
||||
}
|
||||
SV_PushFloodProt(host_client);
|
||||
|
@ -5071,6 +5078,9 @@ void SV_UserInit (void)
|
|||
Cvar_Register (&sv_pushplayers, cvargroup_servercontrol);
|
||||
|
||||
Cvar_Register (&sv_floodprotect, cvargroup_servercontrol);
|
||||
Cvar_Register (&sv_floodprotect_interval, cvargroup_servercontrol);
|
||||
Cvar_Register (&sv_floodprotect_messages, cvargroup_servercontrol);
|
||||
Cvar_Register (&sv_floodprotect_silencetime, cvargroup_servercontrol);
|
||||
|
||||
Cvar_Register (&sv_cmdlikercon, cvargroup_serverpermissions);
|
||||
Cvar_Register(&cmd_gamecodelevel, "Access controls");
|
||||
|
|
Loading…
Reference in a new issue