From 8e656b4af8cd42aa865b32911ee81df0f6019236 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 20 Jan 2020 18:01:39 +0000 Subject: [PATCH] Fix some qtv proxy bugs, some serious some less so. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5604 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/Makefile | 3 +- fteqtv/Makefile | 6 +- fteqtv/control.c | 2 +- fteqtv/forward.c | 3 +- fteqtv/qw.c | 156 +++++++++++++++++++++++++++-------------------- fteqtv/source.c | 5 +- 6 files changed, 102 insertions(+), 73 deletions(-) diff --git a/engine/Makefile b/engine/Makefile index 2eed1e469..09ad66ded 100644 --- a/engine/Makefile +++ b/engine/Makefile @@ -2348,11 +2348,12 @@ QTV_OBJECTS= \ forward.c \ pmove.c \ menu.c \ + msg.c \ httpsv.c \ sha1.c \ libqtvc/glibc_sucks.c $(RELEASE_DIR)/qtv$(BITS)$(EXEPOSTFIX): $(QTV_OBJECTS) - $(CC) -o $@ $? -lstdc++ -lm $(BASE_INCLUDES) $(QTV_LDFLAGS) + $(CC) -o $@ $? -lstdc++ -lm $(BASE_INCLUDES) $(QTV_LDFLAGS) $(SVNREVISION) qtv-rel: @$(MAKE) $(RELEASE_DIR)/qtv$(BITS)$(EXEPOSTFIX) VPATH="$(BASE_DIR)/../fteqtv:$(VPATH)" qtv: qtv-rel diff --git a/fteqtv/Makefile b/fteqtv/Makefile index a5e8eaf88..54b5bdbb2 100644 --- a/fteqtv/Makefile +++ b/fteqtv/Makefile @@ -13,10 +13,14 @@ VPATH=../engine/common OBJS = netchan.o parse.o msg.o qw.o source.o bsp.o rcon.o mdfour.o crc.o control.o forward.o pmove.o menu.o httpsv.o sha1.o +#I hate this big long list. +INCLUDES=-I../engine/common -I../engine/client -I../engine/server -I../engine/qclib -I../engine/gl +REVISION:=-DSVNREVISION=$(shell svnversion) + all: qtv %.o: %.c - $(CC) $(SPIKEISALAZYBUGGERCFLAGS) $(CFLAGS) $< -c -o $@ + $(CC) $(SPIKEISALAZYBUGGERCFLAGS) $(CFLAGS) $(INCLUDES) $(REVISION) $< -c -o $@ libqtvc: $(MAKE) -C libqtvc CC="$(CC)" CFLAGS="$(CFLAGS) $(SPIKEISALAZYBUGGERCFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" diff --git a/fteqtv/control.c b/fteqtv/control.c index 179079c5a..99b085c57 100644 --- a/fteqtv/control.c +++ b/fteqtv/control.c @@ -197,7 +197,7 @@ void Cluster_BuildAvailableDemoList(cluster_t *cluster) closedir(dir); } else - Sys_Printf(cluster, "Couldn't open dir for demo listings\n"); + Sys_Printf(cluster, "Couldn't open dir %s for demo listings\n", cluster->demodir); } #endif diff --git a/fteqtv/forward.c b/fteqtv/forward.c index 7be453d7f..c93ec3f86 100644 --- a/fteqtv/forward.c +++ b/fteqtv/forward.c @@ -144,6 +144,7 @@ void Fwd_ParseCommands(cluster_t *cluster, oproxy_t *prox) break; packetlength = prox->inbuffer[0] + (prox->inbuffer[1]<<8); + packetlength -= 2; //qqshka's inconsistent-upstream-sizes stupidity. if (packetlength+2 > prox->inbuffersize) break; @@ -471,7 +472,7 @@ void Prox_SendInitialPlayers(sv_t *qtv, oproxy_t *prox, netmsg_t *msg) for (j = 0 ; j < 3 ; j++) if (flags & (DF_ORIGIN << j)) - WriteShort (msg, qtv->map.players[i].current.origin[j]); + WriteCoord (msg, qtv->map.players[i].current.origin[j], qtv->pext1); for (j = 0 ; j < 3 ; j++) if (flags & (DF_ANGLES << j)) diff --git a/fteqtv/qw.c b/fteqtv/qw.c index 560b41268..cc06df6e6 100644 --- a/fteqtv/qw.c +++ b/fteqtv/qw.c @@ -158,15 +158,31 @@ void BuildServerData(sv_t *tv, netmsg_t *msg, int servercount, viewer_t *viewer) { movevars_t movevars; WriteByte(msg, svc_serverdata); - if (viewer->pext1) - { - WriteLong(msg, PROTOCOL_VERSION_FTE); - WriteLong(msg, viewer->pext1); + if (viewer) + { //its for an actual viewer, tailor the extensions... + if (viewer->pext1) + { + WriteLong(msg, PROTOCOL_VERSION_FTE); + WriteLong(msg, viewer->pext1); + } + if (viewer->pext2) + { + WriteLong(msg, PROTOCOL_VERSION_FTE2); + WriteLong(msg, viewer->pext2); + } } - if (viewer->pext2) - { - WriteLong(msg, PROTOCOL_VERSION_FTE2); - WriteLong(msg, viewer->pext2); + else + { //we're just forwarding, use the same extensions our source used. + if (tv->pext1) + { + WriteLong(msg, PROTOCOL_VERSION_FTE); + WriteLong(msg, tv->pext1); + } + if (tv->pext2) + { + WriteLong(msg, PROTOCOL_VERSION_FTE2); + WriteLong(msg, tv->pext2); + } } WriteLong(msg, PROTOCOL_VERSION); WriteLong(msg, servercount); @@ -3107,10 +3123,73 @@ tuiadmin: } } -void QTV_Say(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *message, qboolean noupwards) +static void QTV_DoSay(cluster_t *cluster, sv_t *qtv, const char *viewername, char *message) { char buf[1024]; netmsg_t msg; + viewer_t *ov; + + if (cluster->notalking) + return; + + if (qtv) + SV_SayToUpstream(qtv, message); + + for (ov = cluster->viewers; ov; ov = ov->next) + { + if (ov->server != qtv) + continue; + + InitNetMsg(&msg, buf, sizeof(buf)); + + WriteByte(&msg, svc_print); + + if (ov->netchan.isnqprotocol) + { + WriteByte(&msg, 1); + WriteByte(&msg, '['); + WriteString2(&msg, "QTV"); + WriteByte(&msg, ']'); + } + else + { + if (ov->conmenussupported) + { + WriteByte(&msg, 2); //PRINT_HIGH + WriteByte(&msg, 91+128); + WriteString2(&msg, "QTV"); + WriteByte(&msg, 93+128); + WriteString2(&msg, "^5"); + } + else + { + WriteByte(&msg, 2); //PRINT_HIGH + WriteByte(&msg, 91+128); + WriteString2(&msg, "QTV"); + WriteByte(&msg, 93+128); + WriteByte(&msg, 0); + + WriteByte(&msg, svc_print); + WriteByte(&msg, 3); //PRINT_CHAT + + } + } + + WriteString2(&msg, viewername); + WriteString2(&msg, ": "); +// WriteString2(&msg, "\x8d "); + if (ov->conmenussupported) + WriteString2(&msg, "^s"); + WriteString2(&msg, message); + WriteString(&msg, "\n"); + + SendBufferToViewer(ov, msg.data, msg.cursize, true); + } +} + +void QTV_Say(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *message, qboolean noupwards) +{ + char buf[1024]; if (message[strlen(message)-1] == '\"') message[strlen(message)-1] = '\0'; @@ -3257,8 +3336,6 @@ void QTV_Say(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *message, qboolean } else { - viewer_t *ov; - // If the current viewer is the player, pass on the say_team if (qtv && qtv->controller == v) { @@ -3266,62 +3343,7 @@ void QTV_Say(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *message, qboolean return; } - if (cluster->notalking) - return; - - if (v->server) - SV_SayToUpstream(v->server, message); - - for (ov = cluster->viewers; ov; ov = ov->next) - { - if (ov->server != v->server) - continue; - - InitNetMsg(&msg, buf, sizeof(buf)); - - WriteByte(&msg, svc_print); - - if (ov->netchan.isnqprotocol) - { - WriteByte(&msg, 1); - WriteByte(&msg, '['); - WriteString2(&msg, "QTV"); - WriteByte(&msg, ']'); - } - else - { - if (ov->conmenussupported) - { - WriteByte(&msg, 2); //PRINT_HIGH - WriteByte(&msg, 91+128); - WriteString2(&msg, "QTV"); - WriteByte(&msg, 93+128); - WriteString2(&msg, "^5"); - } - else - { - WriteByte(&msg, 2); //PRINT_HIGH - WriteByte(&msg, 91+128); - WriteString2(&msg, "QTV"); - WriteByte(&msg, 93+128); - WriteByte(&msg, 0); - - WriteByte(&msg, svc_print); - WriteByte(&msg, 3); //PRINT_CHAT - - } - } - - WriteString2(&msg, v->name); - WriteString2(&msg, ": "); -// WriteString2(&msg, "\x8d "); - if (ov->conmenussupported) - WriteString2(&msg, "^s"); - WriteString2(&msg, message); - WriteString(&msg, "\n"); - - SendBufferToViewer(ov, msg.data, msg.cursize, true); - } + QTV_DoSay(cluster, v->server, v->name, message); } } diff --git a/fteqtv/source.c b/fteqtv/source.c index 3d5a8d382..b9def7b07 100644 --- a/fteqtv/source.c +++ b/fteqtv/source.c @@ -990,9 +990,10 @@ qboolean Net_WriteUpstream(sv_t *qtv) void SV_SendUpstream(sv_t *qtv, netmsg_t *nm) { char size[2]; + int ffs = nm->cursize+2; //qq fucked up and made his upstream inconsistent with downstream. ffs. - size[0] = (nm->cursize&0x00ff)>>0; - size[1] = (nm->cursize&0xff00)>>8; + size[0] = (ffs&0x00ff)>>0; + size[1] = (ffs&0xff00)>>8; Net_QueueUpstream(qtv, 2, size); Net_QueueUpstream(qtv, nm->cursize, nm->data); Net_WriteUpstream(qtv); //try and flush it