From 60eac6b894886d1b18cf41bc393db761c29a0300 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 24 Sep 2005 21:34:50 +0000 Subject: [PATCH] Code to start/stop demo recording (mvd writing). Also code to only open udp/tcp ports if neither was specified in a config/startup script. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1370 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- fteqtv/source.c | 73 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 15 deletions(-) diff --git a/fteqtv/source.c b/fteqtv/source.c index bb783dc17..d3822c215 100644 --- a/fteqtv/source.c +++ b/fteqtv/source.c @@ -268,11 +268,47 @@ void Net_FindProxies(sv_t *qtv) memset(prox, 0, sizeof(*prox)); prox->flushing = true; //allow the buffer overflow resumption code to send the connection info. prox->sock = sock; + prox->file = NULL; prox->next = qtv->proxies; qtv->proxies = prox; } +qboolean Net_FileProxy(sv_t *qtv, char *filename) +{ + oproxy_t *prox; + FILE *f; + + f = fopen(filename, "wb"); + if (!f) + return false; + + prox = malloc(sizeof(*prox)); + memset(prox, 0, sizeof(*prox)); + prox->flushing = true; //allow the buffer overflow resumption code to send the connection info. + prox->sock = INVALID_SOCKET; + prox->file = f; + + prox->next = qtv->proxies; + qtv->proxies = prox; + + return true; +} + +qboolean Net_StopFileProxy(sv_t *qtv) +{ + oproxy_t *prox; + for (prox = qtv->proxies; prox; prox = prox->next) + { + if (prox->file) + { + prox->drop = true; + return true; + } + } + return false; +} + #undef IN #define IN(x) buffer[(x)&(MAX_PROXY_BUFFER-1)] @@ -1013,23 +1049,30 @@ int main(int argc, char **argv) } - //make sure there's a use for this proxy. - if (qtv.qwdsocket == INVALID_SOCKET) - { //still not opened one? try again - qtv.qwdsocket = QW_InitUDPSocket(qtv.qwlistenportnum); - if (qtv.qwdsocket == INVALID_SOCKET) - printf("Warning: couldn't open udp socket\n"); - } - if (qtv.listenmvd == INVALID_SOCKET) - { - qtv.listenmvd = Net_MVDListen(qtv.tcplistenportnum); - if (qtv.listenmvd == INVALID_SOCKET) - printf("Warning: couldn't open mvd socket\n"); - } if (qtv.qwdsocket == INVALID_SOCKET && qtv.listenmvd == INVALID_SOCKET) { - printf("Shutting down, couldn't open listening ports (useless proxy)\n"); - return 0; + //make sure there's a use for this proxy. + if (qtv.qwdsocket == INVALID_SOCKET) + { //still not opened one? try again + qtv.qwdsocket = QW_InitUDPSocket(qtv.qwlistenportnum); + if (qtv.qwdsocket == INVALID_SOCKET) + printf("Warning: couldn't open udp socket\n"); + else + printf("Opened udp port %i\n", qtv.qwlistenportnum); + } + if (qtv.listenmvd == INVALID_SOCKET) + { + qtv.listenmvd = Net_MVDListen(qtv.tcplistenportnum); + if (qtv.listenmvd == INVALID_SOCKET) + printf("Warning: couldn't open mvd socket\n"); + else + printf("Opened tcp port %i\n", qtv.tcplistenportnum); + } + if (qtv.qwdsocket == INVALID_SOCKET && qtv.listenmvd == INVALID_SOCKET) + { + printf("Shutting down, couldn't open listening ports (useless proxy)\n"); + return 0; + } } qtv.parsingconnectiondata = true;