mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-10 14:42:13 +00:00
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
This commit is contained in:
parent
dad5de099b
commit
5f7240316a
1 changed files with 53 additions and 17 deletions
|
@ -158,6 +158,8 @@ void DestFlush(qboolean compleate)
|
|||
break;
|
||||
|
||||
case DEST_STREAM:
|
||||
if (d->cacheused)
|
||||
{
|
||||
len = send(d->socket, d->cache, d->cacheused, 0);
|
||||
if (len == 0) //client died
|
||||
d->error = true;
|
||||
|
@ -168,9 +170,12 @@ void DestFlush(qboolean compleate)
|
|||
}
|
||||
else
|
||||
{ //error of some kind. would block or something
|
||||
if (qerrno != EWOULDBLOCK)
|
||||
int e;
|
||||
e = qerrno;
|
||||
if (e != EWOULDBLOCK)
|
||||
d->error = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DEST_NONE:
|
||||
|
@ -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<MAX_LIGHTSTYLES ; i++)
|
||||
for (i=0 ; i<MAX_STANDARDLIGHTSTYLES ; i++)
|
||||
{
|
||||
MSG_WriteByte (&buf, svc_lightstyle);
|
||||
MSG_WriteByte (&buf, (char)i);
|
||||
|
@ -1989,11 +1997,15 @@ void SV_MVDStream_Poll(void)
|
|||
{
|
||||
static int listensocket=INVALID_SOCKET;
|
||||
static int listenport;
|
||||
|
||||
int client;
|
||||
netadr_t na;
|
||||
struct sockaddr_qstorage addr;
|
||||
int addrlen;
|
||||
int count;
|
||||
qboolean wanted;
|
||||
mvddest_t *dest;
|
||||
|
||||
if (!sv.state || !mvd_streamport.value)
|
||||
wanted = false;
|
||||
else if (listenport && (int)mvd_streamport.value != listenport) //easy way to switch... disable for a frame. :)
|
||||
|
@ -2024,11 +2036,34 @@ void SV_MVDStream_Poll(void)
|
|||
if (client == INVALID_SOCKET)
|
||||
return;
|
||||
|
||||
if (sv.mvdrecording)
|
||||
if (mvd_maxstreams.value > 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);
|
||||
Con_Printf("MVD streaming client connected from %s\n", NET_AdrToString(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
|
||||
|
|
Loading…
Reference in a new issue