From cd690a165a1e272db9a851b83155632f87ca1994 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sun, 24 Aug 2014 17:16:12 +0000 Subject: [PATCH] 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 --- engine/server/server.h | 2 ++ engine/server/sv_user.c | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/engine/server/server.h b/engine/server/server.h index 3b6df8971..5e136ce30 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -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); diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index beafb7d2c..9c869b251 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -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");