From 5f7240316a2b15ee0e54a11a7b44487ab79ce9d4 Mon Sep 17 00:00:00 2001 From: Spoike Date: Fri, 7 Oct 2005 02:03:17 +0000 Subject: [PATCH] Added a mvd_maxstreams cvar, to control the maximum number of proxies to allow to connect directly to the server. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1436 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/server/sv_mvd.c | 70 ++++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index c183a3ca5..ef41dc979 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -158,18 +158,23 @@ void DestFlush(qboolean compleate) break; case DEST_STREAM: - len = send(d->socket, d->cache, d->cacheused, 0); - if (len == 0) //client died - d->error = true; - else if (len > 0) //error of some kind + if (d->cacheused) { - d->cacheused -= len; - memmove(d->cache, d->cache+len, d->cacheused); - } - else - { //error of some kind. would block or something - if (qerrno != EWOULDBLOCK) + len = send(d->socket, d->cache, d->cacheused, 0); + if (len == 0) //client died d->error = true; + else if (len > 0) //error of some kind + { + d->cacheused -= len; + memmove(d->cache, d->cache+len, d->cacheused); + } + else + { //error of some kind. would block or something + int e; + e = qerrno; + if (e != EWOULDBLOCK) + d->error = true; + } } break; @@ -435,6 +440,7 @@ cvar_t sv_demoMaxSize = {"sv_demoMaxSize", ""}; cvar_t sv_demoExtraNames = {"sv_demoExtraNames", ""}; cvar_t mvd_streamport = {"mvd_streamport", "0"}; +cvar_t mvd_maxstreams = {"mvd_maxstreams", "1"}; cvar_t sv_demoPrefix = {"sv_demoPrefix", ""}; cvar_t sv_demoSuffix = {"sv_demoSuffix", ""}; @@ -1111,6 +1117,8 @@ mvddest_t *SV_InitStream(int socket) dst->maxcachesize = 0x8000; //is this too small? dst->cache = BZ_Malloc(dst->maxcachesize); + SV_BroadcastPrintf (PRINT_CHAT, "Smile, you're on QTV!\n"); + return dst; } @@ -1283,8 +1291,8 @@ static qboolean SV_MVD_Record (mvddest_t *dest) sv.mvdrecording = true; } - else - SV_WriteRecordMVDMessage(&buf, dem_read); +// else +// SV_WriteRecordMVDMessage(&buf, dem_read); demo.pingtime = demo.time = sv.time; dest->nextdest = demo.dest; @@ -1537,7 +1545,7 @@ static qboolean SV_MVD_Record (mvddest_t *dest) } // send all current light styles - for (i=0 ; i 0) + { + count = 0; + for (dest = demo.dest; dest; dest = dest->nextdest) + { + if (dest->desttype == DEST_STREAM) + { + count++; + } + } + + if (count > mvd_maxstreams.value) + { //sorry + char *goawaymessage = "This server enforces a limit on the number of proxies connected at any one time. Please try again later\n"; + char packetheader[6]; + packetheader[0] = 1; + packetheader[1] = dem_all; + packetheader[2] = strlen(goawaymessage)+1; + packetheader[3] = 0; + packetheader[4] = 0; + packetheader[5] = 0; + + send(client, packetheader, sizeof(packetheader), 0); + send(client, goawaymessage, strlen(goawaymessage)+1, 0); + closesocket(client); + return; + } } SockadrToNetadr(&addr, &na); @@ -2447,6 +2482,7 @@ void SV_MVDInit(void) Cmd_AddCommand ("rmdemonum", SV_MVDRemoveNum_f); Cvar_Register(&mvd_streamport, "MVD Streaming"); + Cvar_Register(&mvd_maxstreams, "MVD Streaming"); } #endif