fix issues with join/observe spam by throttling it to no more than 1 per 2 seconds.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4730 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2014-08-24 17:16:12 +00:00
parent 0de3e18aad
commit cd690a165a
2 changed files with 26 additions and 0 deletions

View File

@ -494,6 +494,7 @@ typedef struct client_s
double floodprotmessage;
double lastspoke;
double lockedtill;
float joinobservelockeduntil;
qboolean upgradewarn; // did we warn him?
@ -983,6 +984,7 @@ int SV_ModelIndex (const char *name);
void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg);
void SVQW_WriteDelta (entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, unsigned int protext);
void SV_GetNewSpawnParms(client_t *cl);
void SV_SaveSpawnparms (void);
void SV_SaveSpawnparmsClient(client_t *client, float *transferparms); //if transferparms, calls SetTransferParms instead, and does not modify the player.
void SV_SaveLevelCache(char *savename, qboolean dontharmgame);

View File

@ -4397,6 +4397,18 @@ void Cmd_Join_f (void)
return;
}
if (!host_client->spectator)
{
SV_ClientTPrintf(host_client, PRINT_HIGH, "You are not currently spectating.\n");
return;
}
if (host_client->joinobservelockeduntil > realtime)
{
SV_TPrintToClient(host_client, PRINT_HIGH, va("Please wait %.1g more seconds\n", host_client->joinobservelockeduntil-realtime));
return;
}
host_client->joinobservelockeduntil = realtime + 2;
if (password.string[0] && stricmp(password.string, "none"))
{
SV_ClientTPrintf(host_client, PRINT_HIGH, "This server requires a %s password. Please disconnect, set the password and reconnect as %s.\n", "player", "player");
@ -4513,6 +4525,18 @@ void Cmd_Observe_f (void)
return;
}
if (host_client->spectator)
{
SV_ClientTPrintf(host_client, PRINT_HIGH, "You are already spectating.\n");
return;
}
if (host_client->joinobservelockeduntil > realtime)
{
SV_TPrintToClient(host_client, PRINT_HIGH, va("Please wait %.1g more seconds\n", host_client->joinobservelockeduntil-realtime));
return;
}
host_client->joinobservelockeduntil = realtime + 2;
if (spectator_password.string[0] && stricmp(spectator_password.string, "none"))
{
SV_ClientTPrintf(host_client, PRINT_HIGH, "This server requires a %s password. Please disconnect, set the password and reconnect as %s.\n", "spectator", "spectator");