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
This commit is contained in:
Spoike 2020-01-20 18:01:39 +00:00
parent 3d54173ad1
commit 8e656b4af8
6 changed files with 102 additions and 73 deletions

View file

@ -2348,11 +2348,12 @@ QTV_OBJECTS= \
forward.c \ forward.c \
pmove.c \ pmove.c \
menu.c \ menu.c \
msg.c \
httpsv.c \ httpsv.c \
sha1.c \ sha1.c \
libqtvc/glibc_sucks.c libqtvc/glibc_sucks.c
$(RELEASE_DIR)/qtv$(BITS)$(EXEPOSTFIX): $(QTV_OBJECTS) $(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: qtv-rel:
@$(MAKE) $(RELEASE_DIR)/qtv$(BITS)$(EXEPOSTFIX) VPATH="$(BASE_DIR)/../fteqtv:$(VPATH)" @$(MAKE) $(RELEASE_DIR)/qtv$(BITS)$(EXEPOSTFIX) VPATH="$(BASE_DIR)/../fteqtv:$(VPATH)"
qtv: qtv-rel qtv: qtv-rel

View file

@ -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 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 all: qtv
%.o: %.c %.o: %.c
$(CC) $(SPIKEISALAZYBUGGERCFLAGS) $(CFLAGS) $< -c -o $@ $(CC) $(SPIKEISALAZYBUGGERCFLAGS) $(CFLAGS) $(INCLUDES) $(REVISION) $< -c -o $@
libqtvc: libqtvc:
$(MAKE) -C libqtvc CC="$(CC)" CFLAGS="$(CFLAGS) $(SPIKEISALAZYBUGGERCFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)" $(MAKE) -C libqtvc CC="$(CC)" CFLAGS="$(CFLAGS) $(SPIKEISALAZYBUGGERCFLAGS)" AR="$(AR)" RANLIB="$(RANLIB)"

View file

@ -197,7 +197,7 @@ void Cluster_BuildAvailableDemoList(cluster_t *cluster)
closedir(dir); closedir(dir);
} }
else 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 #endif

View file

@ -144,6 +144,7 @@ void Fwd_ParseCommands(cluster_t *cluster, oproxy_t *prox)
break; break;
packetlength = prox->inbuffer[0] + (prox->inbuffer[1]<<8); packetlength = prox->inbuffer[0] + (prox->inbuffer[1]<<8);
packetlength -= 2; //qqshka's inconsistent-upstream-sizes stupidity.
if (packetlength+2 > prox->inbuffersize) if (packetlength+2 > prox->inbuffersize)
break; break;
@ -471,7 +472,7 @@ void Prox_SendInitialPlayers(sv_t *qtv, oproxy_t *prox, netmsg_t *msg)
for (j = 0 ; j < 3 ; j++) for (j = 0 ; j < 3 ; j++)
if (flags & (DF_ORIGIN << 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++) for (j = 0 ; j < 3 ; j++)
if (flags & (DF_ANGLES << j)) if (flags & (DF_ANGLES << j))

View file

@ -158,15 +158,31 @@ void BuildServerData(sv_t *tv, netmsg_t *msg, int servercount, viewer_t *viewer)
{ {
movevars_t movevars; movevars_t movevars;
WriteByte(msg, svc_serverdata); WriteByte(msg, svc_serverdata);
if (viewer->pext1) if (viewer)
{ { //its for an actual viewer, tailor the extensions...
WriteLong(msg, PROTOCOL_VERSION_FTE); if (viewer->pext1)
WriteLong(msg, 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) else
{ { //we're just forwarding, use the same extensions our source used.
WriteLong(msg, PROTOCOL_VERSION_FTE2); if (tv->pext1)
WriteLong(msg, viewer->pext2); {
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, PROTOCOL_VERSION);
WriteLong(msg, servercount); 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]; char buf[1024];
netmsg_t msg; 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] == '\"') if (message[strlen(message)-1] == '\"')
message[strlen(message)-1] = '\0'; 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 else
{ {
viewer_t *ov;
// If the current viewer is the player, pass on the say_team // If the current viewer is the player, pass on the say_team
if (qtv && qtv->controller == v) 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; return;
} }
if (cluster->notalking) QTV_DoSay(cluster, v->server, v->name, message);
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);
}
} }
} }

View file

@ -990,9 +990,10 @@ qboolean Net_WriteUpstream(sv_t *qtv)
void SV_SendUpstream(sv_t *qtv, netmsg_t *nm) void SV_SendUpstream(sv_t *qtv, netmsg_t *nm)
{ {
char size[2]; 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[0] = (ffs&0x00ff)>>0;
size[1] = (nm->cursize&0xff00)>>8; size[1] = (ffs&0xff00)>>8;
Net_QueueUpstream(qtv, 2, size); Net_QueueUpstream(qtv, 2, size);
Net_QueueUpstream(qtv, nm->cursize, nm->data); Net_QueueUpstream(qtv, nm->cursize, nm->data);
Net_WriteUpstream(qtv); //try and flush it Net_WriteUpstream(qtv); //try and flush it