2005-09-24 04:48:20 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the included (GNU.txt) GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
#include "qtv.h"
|
2011-07-14 09:18:04 +00:00
|
|
|
#include <string.h>
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-12-27 15:17:05 +00:00
|
|
|
#include "bsd_string.h"
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
static const filename_t ConnectionlessModelList[] = {{""}, {"maps/start.bsp"}, {"progs/player.mdl"}, {""}};
|
|
|
|
static const filename_t ConnectionlessSoundList[] = {{""}, {""}};
|
|
|
|
|
2007-11-09 17:41:08 +00:00
|
|
|
const intermission_t nullstreamspot = {{544, 288, 64}, {0, 90, 0}};
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
void QTV_Say(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *message, qboolean noupwards);
|
|
|
|
|
2006-10-20 14:25:20 +00:00
|
|
|
void QTV_DefaultMovevars(movevars_t *vars)
|
|
|
|
{
|
|
|
|
vars->gravity = 800;
|
|
|
|
vars->maxspeed = 320;
|
|
|
|
vars->spectatormaxspeed = 500;
|
|
|
|
vars->accelerate = 10;
|
|
|
|
vars->airaccelerate = 0.7f;
|
|
|
|
vars->waterfriction = 4;
|
|
|
|
vars->entgrav = 1;
|
|
|
|
vars->stopspeed = 10;
|
|
|
|
vars->wateraccelerate = 10;
|
|
|
|
vars->friction = 4;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
|
2007-08-01 14:55:28 +00:00
|
|
|
const usercmd_t nullcmd = {0};
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
#define CM_ANGLE1 (1<<0)
|
|
|
|
#define CM_ANGLE3 (1<<1)
|
|
|
|
#define CM_FORWARD (1<<2)
|
|
|
|
#define CM_SIDE (1<<3)
|
|
|
|
#define CM_UP (1<<4)
|
|
|
|
#define CM_BUTTONS (1<<5)
|
|
|
|
#define CM_IMPULSE (1<<6)
|
|
|
|
#define CM_ANGLE2 (1<<7)
|
|
|
|
void ReadDeltaUsercmd (netmsg_t *m, const usercmd_t *from, usercmd_t *move)
|
|
|
|
{
|
|
|
|
int bits;
|
|
|
|
|
|
|
|
memcpy (move, from, sizeof(*move));
|
|
|
|
|
|
|
|
bits = ReadByte (m);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
// read current angles
|
|
|
|
if (bits & CM_ANGLE1)
|
2018-04-06 17:39:32 +00:00
|
|
|
move->angles[0] = (ReadShort (m)/(float)0x10000)*360;
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & CM_ANGLE2)
|
2018-04-06 17:39:32 +00:00
|
|
|
move->angles[1] = (ReadShort (m)/(float)0x10000)*360;
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & CM_ANGLE3)
|
2018-04-06 17:39:32 +00:00
|
|
|
move->angles[2] = (ReadShort (m)/(float)0x10000)*360;
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
// read movement
|
|
|
|
if (bits & CM_FORWARD)
|
|
|
|
move->forwardmove = ReadShort(m);
|
|
|
|
if (bits & CM_SIDE)
|
|
|
|
move->sidemove = ReadShort(m);
|
|
|
|
if (bits & CM_UP)
|
|
|
|
move->upmove = ReadShort(m);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
// read buttons
|
|
|
|
if (bits & CM_BUTTONS)
|
|
|
|
move->buttons = ReadByte (m);
|
|
|
|
|
|
|
|
if (bits & CM_IMPULSE)
|
|
|
|
move->impulse = ReadByte (m);
|
|
|
|
|
|
|
|
// read time to run command
|
|
|
|
move->msec = ReadByte (m); // always sent
|
|
|
|
}
|
|
|
|
|
|
|
|
void WriteDeltaUsercmd (netmsg_t *m, const usercmd_t *from, usercmd_t *move)
|
|
|
|
{
|
|
|
|
int bits = 0;
|
|
|
|
|
|
|
|
if (move->angles[0] != from->angles[0])
|
|
|
|
bits |= CM_ANGLE1;
|
|
|
|
if (move->angles[1] != from->angles[1])
|
|
|
|
bits |= CM_ANGLE2;
|
|
|
|
if (move->angles[2] != from->angles[2])
|
|
|
|
bits |= CM_ANGLE3;
|
|
|
|
|
|
|
|
if (move->forwardmove != from->forwardmove)
|
|
|
|
bits |= CM_FORWARD;
|
|
|
|
if (move->sidemove != from->sidemove)
|
|
|
|
bits |= CM_SIDE;
|
|
|
|
if (move->upmove != from->upmove)
|
|
|
|
bits |= CM_UP;
|
|
|
|
|
|
|
|
if (move->buttons != from->buttons)
|
|
|
|
bits |= CM_BUTTONS;
|
|
|
|
if (move->impulse != from->impulse)
|
|
|
|
bits |= CM_IMPULSE;
|
|
|
|
|
|
|
|
|
|
|
|
WriteByte (m, bits);
|
|
|
|
|
|
|
|
// read current angles
|
|
|
|
if (bits & CM_ANGLE1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteShort (m, (move->angles[0]/360.0)*0x10000);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & CM_ANGLE2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteShort (m, (move->angles[1]/360.0)*0x10000);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & CM_ANGLE3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteShort (m, (move->angles[2]/360.0)*0x10000);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
// read movement
|
|
|
|
if (bits & CM_FORWARD)
|
|
|
|
WriteShort(m, move->forwardmove);
|
|
|
|
if (bits & CM_SIDE)
|
|
|
|
WriteShort(m, move->sidemove);
|
|
|
|
if (bits & CM_UP)
|
|
|
|
WriteShort(m, move->upmove);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
// read buttons
|
|
|
|
if (bits & CM_BUTTONS)
|
|
|
|
WriteByte (m, move->buttons);
|
|
|
|
|
|
|
|
if (bits & CM_IMPULSE)
|
|
|
|
WriteByte (m, move->impulse);
|
|
|
|
|
|
|
|
// read time to run command
|
|
|
|
WriteByte (m, move->msec); // always sent
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
void BuildServerData(sv_t *tv, netmsg_t *msg, int servercount, viewer_t *viewer)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2006-10-20 14:25:20 +00:00
|
|
|
movevars_t movevars;
|
2005-09-06 01:09:36 +00:00
|
|
|
WriteByte(msg, svc_serverdata);
|
2020-01-20 18:01:39 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-03-01 22:39:30 +00:00
|
|
|
}
|
2020-01-20 18:01:39 +00:00
|
|
|
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);
|
|
|
|
}
|
2019-03-01 22:39:30 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
WriteLong(msg, PROTOCOL_VERSION);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteLong(msg, servercount);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (!tv)
|
|
|
|
{
|
|
|
|
//dummy connection, for choosing a game to watch.
|
|
|
|
WriteString(msg, "qw");
|
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
if (!viewer)
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteFloat(msg, 0);
|
|
|
|
else
|
2006-11-03 15:53:04 +00:00
|
|
|
WriteByte(msg, (MAX_CLIENTS-1) | (128));
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString(msg, "FTEQTV Proxy");
|
|
|
|
|
|
|
|
|
|
|
|
// get the movevars
|
2006-10-20 14:25:20 +00:00
|
|
|
QTV_DefaultMovevars(&movevars);
|
|
|
|
WriteFloat(msg, movevars.gravity);
|
|
|
|
WriteFloat(msg, movevars.stopspeed);
|
|
|
|
WriteFloat(msg, movevars.maxspeed);
|
|
|
|
WriteFloat(msg, movevars.spectatormaxspeed);
|
|
|
|
WriteFloat(msg, movevars.accelerate);
|
|
|
|
WriteFloat(msg, movevars.airaccelerate);
|
|
|
|
WriteFloat(msg, movevars.wateraccelerate);
|
|
|
|
WriteFloat(msg, movevars.friction);
|
|
|
|
WriteFloat(msg, movevars.waterfriction);
|
|
|
|
WriteFloat(msg, movevars.entgrav);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WriteByte(msg, svc_stufftext);
|
|
|
|
WriteString2(msg, "fullserverinfo \"");
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteString2(msg, "\\*QTV\\"QTV_VERSION_STRING);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString(msg, "\"\n");
|
|
|
|
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.gamedir);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
if (!viewer)
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteFloat(msg, 0);
|
|
|
|
else
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
|
|
|
if (tv->controller == viewer)
|
|
|
|
WriteByte(msg, viewer->thisplayer);
|
|
|
|
else
|
|
|
|
WriteByte(msg, viewer->thisplayer | 128);
|
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.mapname);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
// get the movevars
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteFloat(msg, tv->map.movevars.gravity);
|
|
|
|
WriteFloat(msg, tv->map.movevars.stopspeed);
|
|
|
|
WriteFloat(msg, tv->map.movevars.maxspeed);
|
|
|
|
WriteFloat(msg, tv->map.movevars.spectatormaxspeed);
|
|
|
|
WriteFloat(msg, tv->map.movevars.accelerate);
|
|
|
|
WriteFloat(msg, tv->map.movevars.airaccelerate);
|
|
|
|
WriteFloat(msg, tv->map.movevars.wateraccelerate);
|
|
|
|
WriteFloat(msg, tv->map.movevars.friction);
|
|
|
|
WriteFloat(msg, tv->map.movevars.waterfriction);
|
|
|
|
WriteFloat(msg, tv->map.movevars.entgrav);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteByte(msg, svc_stufftext);
|
|
|
|
WriteString2(msg, "fullserverinfo \"");
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString2(msg, tv->map.serverinfo);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString(msg, "\"\n");
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
2006-09-19 01:48:12 +00:00
|
|
|
void BuildNQServerData(sv_t *tv, netmsg_t *msg, qboolean mvd, int playernum)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
WriteByte(msg, svc_serverdata);
|
2018-04-06 17:39:32 +00:00
|
|
|
if (tv && tv->pext1 & PEXT_FLOATCOORDS)
|
|
|
|
{
|
|
|
|
WriteLong(msg, 999);
|
|
|
|
WriteLong(msg, (1<<1)|(1<<4)); //short angles, float coords, same as PEXT_FLOATCOORDS
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WriteLong(msg, PROTOCOL_VERSION_NQ);
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte(msg, 16); //MAX_CLIENTS
|
2006-09-19 01:48:12 +00:00
|
|
|
WriteByte(msg, 1); //game type
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
if (!tv || tv->parsingconnectiondata )
|
|
|
|
{
|
|
|
|
//dummy connection, for choosing a game to watch.
|
|
|
|
WriteString(msg, "FTEQTV Proxy");
|
|
|
|
|
|
|
|
|
|
|
|
//modellist
|
|
|
|
for (i = 1; *ConnectionlessModelList[i].name; i++)
|
|
|
|
{
|
|
|
|
WriteString(msg, ConnectionlessModelList[i].name);
|
|
|
|
}
|
|
|
|
WriteString(msg, "");
|
|
|
|
|
|
|
|
//soundlist
|
|
|
|
for (i = 1; *ConnectionlessSoundList[i].name; i++)
|
|
|
|
{
|
|
|
|
WriteString(msg, ConnectionlessSoundList[i].name);
|
|
|
|
}
|
|
|
|
WriteString(msg, "");
|
|
|
|
|
|
|
|
WriteByte(msg, svc_cdtrack);
|
|
|
|
WriteByte(msg, 0); //two of them, yeah... weird, eh?
|
|
|
|
WriteByte(msg, 0);
|
|
|
|
|
|
|
|
WriteByte(msg, svc_nqsetview);
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteShort(msg, playernum+1);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_nqsignonnum);
|
|
|
|
WriteByte(msg, 1);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//dummy connection, for choosing a game to watch.
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteString(msg, tv->map.mapname);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
//modellist
|
2009-07-07 23:40:06 +00:00
|
|
|
for (i = 1; *tv->map.modellist[i].name; i++)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.modellist[i].name);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
WriteString(msg, "");
|
|
|
|
|
|
|
|
//soundlist
|
2009-07-07 23:40:06 +00:00
|
|
|
for (i = 1; *tv->map.soundlist[i].name; i++)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.soundlist[i].name);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
WriteString(msg, "");
|
|
|
|
|
|
|
|
WriteByte(msg, svc_cdtrack);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.cdtrack); //two of them, yeah... weird, eh?
|
|
|
|
WriteByte(msg, tv->map.cdtrack);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_nqsetview);
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteShort(msg, playernum+1);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_nqsignonnum);
|
|
|
|
WriteByte(msg, 1);
|
|
|
|
}
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-09-10 19:27:39 +00:00
|
|
|
|
|
|
|
void QW_ClearViewerState(viewer_t *viewer)
|
|
|
|
{
|
|
|
|
memset(viewer->currentstats, 0, sizeof(viewer->currentstats));
|
|
|
|
}
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
void SendServerData(sv_t *tv, viewer_t *viewer)
|
|
|
|
{
|
|
|
|
netmsg_t msg;
|
2007-11-15 21:19:52 +00:00
|
|
|
char buffer[MAX_MSGLEN];
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-11-15 21:19:52 +00:00
|
|
|
InitNetMsg(&msg, buffer, viewer->netchan.maxreliablelen);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2019-03-01 22:39:30 +00:00
|
|
|
if (tv)
|
|
|
|
{
|
|
|
|
viewer->pext1 = tv->pext1;
|
|
|
|
viewer->pext2 = tv->pext2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
viewer->pext1 = viewer->pext2 = 0;
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
if (tv && (tv->controller == viewer || !tv->controller))
|
2009-07-07 23:40:06 +00:00
|
|
|
viewer->thisplayer = tv->map.thisplayer;
|
2006-04-11 22:15:09 +00:00
|
|
|
else
|
2006-10-07 22:29:31 +00:00
|
|
|
viewer->thisplayer = viewer->netchan.isnqprotocol?15:MAX_CLIENTS-1;
|
2006-09-17 01:27:32 +00:00
|
|
|
if (viewer->netchan.isnqprotocol)
|
2006-09-19 01:48:12 +00:00
|
|
|
BuildNQServerData(tv, &msg, false, viewer->thisplayer);
|
2006-09-17 01:27:32 +00:00
|
|
|
else
|
2006-11-03 15:53:04 +00:00
|
|
|
BuildServerData(tv, &msg, viewer->servercount, viewer);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
SendBufferToViewer(viewer, msg.data, msg.cursize, true);
|
|
|
|
|
|
|
|
viewer->thinksitsconnected = false;
|
2012-04-23 04:37:33 +00:00
|
|
|
if (tv && (tv->controller == viewer) && !viewer->netchan.isnqprotocol)
|
2007-09-08 20:15:59 +00:00
|
|
|
viewer->thinksitsconnected = true;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-09-10 19:27:39 +00:00
|
|
|
QW_ClearViewerState(viewer);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
void SendNQSpawnInfoToViewer(cluster_t *cluster, viewer_t *viewer, netmsg_t *msg)
|
|
|
|
{
|
2006-09-19 01:48:12 +00:00
|
|
|
char buffer[64];
|
2006-09-17 01:27:32 +00:00
|
|
|
int i;
|
2006-09-19 01:48:12 +00:00
|
|
|
int colours;
|
2006-09-17 01:27:32 +00:00
|
|
|
sv_t *tv = viewer->server;
|
|
|
|
WriteByte(msg, svc_nqtime);
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteFloat(msg, (cluster->curtime - (tv?tv->mapstarttime:0))/1000.0f);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
if (tv)
|
|
|
|
{
|
|
|
|
for (i=0; i<MAX_CLIENTS && i < 16; i++)
|
|
|
|
{
|
|
|
|
WriteByte (msg, svc_nqupdatename);
|
|
|
|
WriteByte (msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(tv->map.players[i].userinfo, "name", buffer, sizeof(buffer));
|
2006-09-19 01:48:12 +00:00
|
|
|
WriteString (msg, buffer); //fixme
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte (msg, svc_updatefrags);
|
|
|
|
WriteByte (msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort (msg, tv->map.players[i].frags);
|
2006-09-19 01:48:12 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(tv->map.players[i].userinfo, "bottomcolor", buffer, sizeof(buffer));
|
2006-09-19 01:48:12 +00:00
|
|
|
colours = atoi(buffer);
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(tv->map.players[i].userinfo, "topcolor", buffer, sizeof(buffer));
|
2006-09-19 01:48:12 +00:00
|
|
|
colours |= atoi(buffer)*16;
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte (msg, svc_nqupdatecolors);
|
|
|
|
WriteByte (msg, i);
|
2006-09-19 01:48:12 +00:00
|
|
|
WriteByte (msg, colours);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i=0; i < 16; i++)
|
|
|
|
{
|
|
|
|
WriteByte (msg, svc_nqupdatename);
|
|
|
|
WriteByte (msg, i);
|
|
|
|
WriteString (msg, "");
|
|
|
|
WriteByte (msg, svc_updatefrags);
|
|
|
|
WriteByte (msg, i);
|
|
|
|
WriteShort (msg, 0);
|
|
|
|
WriteByte (msg, svc_nqupdatecolors);
|
|
|
|
WriteByte (msg, i);
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteByte(msg, svc_nqsignonnum);
|
|
|
|
WriteByte(msg, 3);
|
|
|
|
}
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
int SendCurrentUserinfos(sv_t *tv, int cursize, netmsg_t *msg, int i, int thisplayer)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2019-02-16 19:09:07 +00:00
|
|
|
char name[1024];
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
if (i < 0)
|
|
|
|
return i;
|
|
|
|
if (i >= MAX_CLIENTS)
|
|
|
|
return i;
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
for (; i < MAX_CLIENTS; i++)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2006-09-17 01:27:32 +00:00
|
|
|
if (i == thisplayer && (!tv || !(tv->controller || tv->proxyplayer)))
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
|
|
|
WriteByte(msg, svc_updateuserinfo);
|
|
|
|
WriteByte(msg, i);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteLong(msg, i+1);
|
2006-04-11 22:15:09 +00:00
|
|
|
WriteString2(msg, "\\*spectator\\1\\name\\");
|
2006-06-10 22:15:24 +00:00
|
|
|
|
2007-08-03 19:57:56 +00:00
|
|
|
// Print the number of people on QTV along with the hostname
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv && tv->map.hostname[0])
|
2007-08-03 19:57:56 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.hostname[0])
|
|
|
|
snprintf(name, sizeof(name), "[%d] %s", tv->numviewers, tv->map.hostname);
|
2007-08-03 19:57:56 +00:00
|
|
|
else
|
|
|
|
snprintf(name, sizeof(name), "[%d] FTEQTV", tv->numviewers);
|
|
|
|
}
|
2006-06-10 22:15:24 +00:00
|
|
|
else
|
2007-08-03 19:57:56 +00:00
|
|
|
snprintf(name, sizeof(name), "FTEQTV");
|
2006-06-10 22:15:24 +00:00
|
|
|
|
2007-08-03 19:57:56 +00:00
|
|
|
/*
|
|
|
|
if (tv)
|
|
|
|
{
|
|
|
|
char tmp[MAX_QPATH];
|
|
|
|
snprintf(tmp
|
|
|
|
strlcat(name, itoa(tv->numviewers), sizeof(name));
|
|
|
|
//snprintf(name, sizeof(name), "%s %d", name, tv->numviewers);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
WriteString(msg, name);
|
2006-04-11 22:15:09 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_updatefrags);
|
|
|
|
WriteByte(msg, i);
|
|
|
|
WriteShort(msg, 9999);
|
|
|
|
|
|
|
|
WriteByte(msg, svc_updateping);
|
|
|
|
WriteByte(msg, i);
|
|
|
|
WriteShort(msg, 0);
|
|
|
|
|
|
|
|
WriteByte(msg, svc_updatepl);
|
|
|
|
WriteByte(msg, i);
|
|
|
|
WriteByte(msg, 0);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!tv)
|
|
|
|
continue;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (msg->cursize+cursize+strlen(tv->map.players[i].userinfo) > 768)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
WriteByte(msg, svc_updateuserinfo);
|
|
|
|
WriteByte(msg, i);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteLong(msg, i+1);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.players[i].userinfo);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-02-20 01:33:13 +00:00
|
|
|
WriteByte(msg, svc_updatefrags);
|
|
|
|
WriteByte(msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort(msg, tv->map.players[i].frags);
|
2006-02-20 01:33:13 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_updateping);
|
|
|
|
WriteByte(msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort(msg, tv->map.players[i].ping);
|
2006-02-20 01:33:13 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_updatepl);
|
|
|
|
WriteByte(msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[i].packetloss);
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
i++;
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
void WriteEntityState(netmsg_t *msg, entity_state_t *es, unsigned int pext)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
WriteByte(msg, es->modelindex);
|
|
|
|
WriteByte(msg, es->frame);
|
|
|
|
WriteByte(msg, es->colormap);
|
|
|
|
WriteByte(msg, es->skinnum);
|
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteCoord(msg, es->origin[i], pext);
|
|
|
|
WriteAngle(msg, es->angles[i], pext);
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
int SendCurrentBaselines(sv_t *tv, int cursize, netmsg_t *msg, int maxbuffersize, int i)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
if (i < 0 || i >= MAX_ENTITIES)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
for (; i < MAX_ENTITIES; i++)
|
|
|
|
{
|
2006-09-17 01:27:32 +00:00
|
|
|
if (msg->cursize+cursize+16 > maxbuffersize)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.entity[i].baseline.modelindex)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
|
|
|
WriteByte(msg, svc_spawnbaseline);
|
|
|
|
WriteShort(msg, i);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteEntityState(msg, &tv->map.entity[i].baseline, tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
int SendCurrentLightmaps(sv_t *tv, int cursize, netmsg_t *msg, int maxbuffersize, int i)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
if (i < 0 || i >= MAX_LIGHTSTYLES)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
for (; i < MAX_LIGHTSTYLES; i++)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (msg->cursize+cursize+strlen(tv->map.lightstyle[i].name) > maxbuffersize)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
WriteByte(msg, svc_lightstyle);
|
|
|
|
WriteByte(msg, i);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString(msg, tv->map.lightstyle[i].name);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
int SendStaticSounds(sv_t *tv, int cursize, netmsg_t *msg, int maxbuffersize, int i)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
|
|
|
if (i < 0 || i >= MAX_STATICSOUNDS)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
for (; i < MAX_STATICSOUNDS; i++)
|
|
|
|
{
|
2006-09-17 01:27:32 +00:00
|
|
|
if (msg->cursize+cursize+16 > maxbuffersize)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
if (!tv->map.staticsound[i].soundindex)
|
2005-09-24 04:48:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
WriteByte(msg, svc_spawnstaticsound);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, tv->map.staticsound[i].origin[0], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.staticsound[i].origin[1], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.staticsound[i].origin[2], tv->pext1);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.staticsound[i].soundindex);
|
|
|
|
WriteByte(msg, tv->map.staticsound[i].volume);
|
|
|
|
WriteByte(msg, tv->map.staticsound[i].attenuation);
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
int SendStaticEntities(sv_t *tv, int cursize, netmsg_t *msg, int maxbuffersize, int i)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
|
|
|
if (i < 0 || i >= MAX_STATICENTITIES)
|
|
|
|
return i;
|
|
|
|
|
|
|
|
for (; i < MAX_STATICENTITIES; i++)
|
|
|
|
{
|
2006-09-17 01:27:32 +00:00
|
|
|
if (msg->cursize+cursize+16 > maxbuffersize)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
if (!tv->map.spawnstatic[i].modelindex)
|
2005-09-24 04:48:20 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
WriteByte(msg, svc_spawnstatic);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteEntityState(msg, &tv->map.spawnstatic[i], tv->pext1);
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
int SendList(sv_t *qtv, int first, const filename_t *list, int svc, netmsg_t *msg)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
WriteByte(msg, svc);
|
|
|
|
WriteByte(msg, first);
|
|
|
|
for (i = first+1; i < 256; i++)
|
|
|
|
{
|
2005-09-24 04:48:20 +00:00
|
|
|
// printf("write %i: %s\n", i, list[i].name);
|
2005-09-06 01:09:36 +00:00
|
|
|
WriteString(msg, list[i].name);
|
|
|
|
if (!*list[i].name) //fixme: this probably needs testing for where we are close to the limit
|
|
|
|
{ //no more
|
|
|
|
WriteByte(msg, 0);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msg->cursize > 768)
|
|
|
|
{ //truncate
|
|
|
|
i--;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WriteByte(msg, 0);
|
|
|
|
WriteByte(msg, i);
|
|
|
|
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
void QW_StreamPrint(cluster_t *cluster, sv_t *server, viewer_t *allbut, char *message)
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
viewer_t *v;
|
|
|
|
|
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
|
|
|
{
|
|
|
|
if (v->server == server)
|
|
|
|
{
|
|
|
|
if (v == allbut)
|
|
|
|
continue;
|
|
|
|
QW_PrintfToViewer(v, "%s", message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-08 03:15:37 +00:00
|
|
|
|
|
|
|
void QW_StreamStuffcmd(cluster_t *cluster, sv_t *server, char *fmt, ...)
|
|
|
|
{
|
|
|
|
viewer_t *v;
|
|
|
|
va_list argptr;
|
|
|
|
char buf[1024];
|
|
|
|
char cmd[512];
|
|
|
|
|
|
|
|
netmsg_t msg;
|
|
|
|
|
|
|
|
va_start (argptr, fmt);
|
|
|
|
vsnprintf (cmd, sizeof(cmd), fmt, argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
WriteByte(&msg, svc_stufftext);
|
|
|
|
WriteString(&msg, cmd);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-01-08 03:15:37 +00:00
|
|
|
|
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
|
|
|
{
|
|
|
|
if (v->server == server)
|
|
|
|
{
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
void QW_SetViewersServer(cluster_t *cluster, viewer_t *viewer, sv_t *sv)
|
|
|
|
{
|
|
|
|
char buffer[1024];
|
|
|
|
sv_t *oldserver;
|
|
|
|
oldserver = viewer->server;
|
2006-02-21 19:55:12 +00:00
|
|
|
if (viewer->server)
|
|
|
|
viewer->server->numviewers--;
|
|
|
|
viewer->server = sv;
|
|
|
|
if (viewer->server)
|
|
|
|
viewer->server->numviewers++;
|
2006-04-11 22:15:09 +00:00
|
|
|
if (!sv || !sv->parsingconnectiondata)
|
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
if (sv != oldserver)
|
|
|
|
QW_StuffcmdToViewer(viewer, "cmd new\n");
|
2007-01-08 03:15:37 +00:00
|
|
|
viewer->thinksitsconnected = false;
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
viewer->servercount++;
|
|
|
|
viewer->origin[0] = 0;
|
|
|
|
viewer->origin[1] = 0;
|
|
|
|
viewer->origin[2] = 0;
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
if (sv != oldserver)
|
|
|
|
{
|
2012-04-23 04:37:33 +00:00
|
|
|
if (sv && oldserver)
|
2007-01-06 09:46:32 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
snprintf(buffer, sizeof(buffer), "%cQTV%c%s leaves to watch %s (%i)\n", 91+128, 93+128, viewer->name, *sv->map.hostname?sv->map.hostname:sv->server, sv->streamid);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_StreamPrint(cluster, oldserver, viewer, buffer);
|
|
|
|
}
|
|
|
|
snprintf(buffer, sizeof(buffer), "%cQTV%c%s joins the stream\n", 91+128, 93+128, viewer->name);
|
|
|
|
QW_StreamPrint(cluster, sv, viewer, buffer);
|
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
//fixme: will these want to have state?..
|
|
|
|
int NewChallenge(netadr_t *addr)
|
|
|
|
{
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
qboolean ChallengePasses(netadr_t *addr, int challenge)
|
|
|
|
{
|
|
|
|
if (challenge == 4)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
void NewClient(cluster_t *cluster, viewer_t *viewer)
|
|
|
|
{
|
2012-04-23 04:37:33 +00:00
|
|
|
sv_t *initialserver;
|
|
|
|
initialserver = NULL;
|
|
|
|
if (*cluster->autojoinadr)
|
|
|
|
{
|
|
|
|
initialserver = QTV_NewServerConnection(cluster, 0, cluster->autojoinadr, "", false, AD_WHENEMPTY, true, false);
|
|
|
|
if (initialserver && initialserver->sourcetype == SRC_UDP)
|
|
|
|
initialserver->controller = viewer;
|
|
|
|
}
|
|
|
|
else if (cluster->nouserconnects && cluster->numservers == 1)
|
|
|
|
{
|
|
|
|
initialserver = cluster->servers;
|
|
|
|
if (!initialserver->map.modellist[1].name[0])
|
|
|
|
initialserver = NULL; //damn, that server isn't ready
|
|
|
|
}
|
|
|
|
|
|
|
|
QW_SetViewersServer(cluster, viewer, initialserver);
|
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer->userid = ++cluster->nextuserid;
|
2006-10-22 19:18:15 +00:00
|
|
|
viewer->timeout = cluster->curtime + 15*1000;
|
2006-09-17 01:27:32 +00:00
|
|
|
viewer->trackplayer = -1;
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
viewer->menunum = -1;
|
|
|
|
QW_SetMenu(viewer, MENU_NONE);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
#ifndef LIBQTV
|
2018-04-06 17:39:32 +00:00
|
|
|
QW_PrintfToViewer(viewer, "Welcome to FTEQTV %s\n", QTV_VERSION_STRING);
|
2006-09-17 01:27:32 +00:00
|
|
|
QW_StuffcmdToViewer(viewer, "alias admin \"cmd admin\"\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:up\" \"say proxy:menu up\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:down\" \"say proxy:menu down\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:right\" \"say proxy:menu right\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:left\" \"say proxy:menu left\"\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:select\" \"say proxy:menu select\"\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:home\" \"say proxy:menu home\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:end\" \"say proxy:menu end\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:menu\" \"say proxy:menu\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \"proxy:backspace\" \"say proxy:menu backspace\"\n");
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".help\" \"say .help\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".disconnect\" \"say .disconnect\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".menu\" \"say .menu\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".admin\" \"say .admin\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".reset\" \"say .reset\"\n");
|
|
|
|
QW_StuffcmdToViewer(viewer, "alias \".clients\" \"say .clients\"\n");
|
|
|
|
// QW_StuffcmdToViewer(viewer, "alias \".qtv\" \"say .qtv\"\n");
|
|
|
|
// QW_StuffcmdToViewer(viewer, "alias \".join\" \"say .join\"\n");
|
|
|
|
// QW_StuffcmdToViewer(viewer, "alias \".observe\" \"say .observe\"\n");
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
QW_PrintfToViewer(viewer, "Type admin for the admin menu\n");
|
2012-04-23 04:37:33 +00:00
|
|
|
#endif
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
|
2006-10-22 20:33:12 +00:00
|
|
|
void ParseUserInfo(cluster_t *cluster, viewer_t *viewer)
|
2006-10-20 14:25:20 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
char buf[1024];
|
2006-10-20 14:25:20 +00:00
|
|
|
float rate;
|
|
|
|
char temp[64];
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
viewer->isproxy = false;
|
|
|
|
|
|
|
|
Info_ValueForKey(viewer->userinfo, "*qtv", temp, sizeof(temp));
|
|
|
|
if (*temp)
|
|
|
|
viewer->isproxy = true;
|
|
|
|
Info_ValueForKey(viewer->userinfo, "Qizmo", temp, sizeof(temp));
|
|
|
|
if (*temp)
|
|
|
|
viewer->isproxy = true;
|
|
|
|
|
2006-10-22 20:33:12 +00:00
|
|
|
Info_ValueForKey(viewer->userinfo, "name", temp, sizeof(temp));
|
|
|
|
|
|
|
|
if (!*temp)
|
|
|
|
strcpy(temp, "unnamed");
|
|
|
|
if (!*viewer->name)
|
|
|
|
Sys_Printf(cluster, "Viewer %s connected\n", temp);
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
if (strcmp(viewer->name, temp))
|
|
|
|
{
|
|
|
|
if (*viewer->name)
|
|
|
|
{
|
2011-07-14 09:18:04 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%cQTV%c%s changed name to %cQTV%c%s\n",
|
2007-01-06 09:46:32 +00:00
|
|
|
91+128, 93+128, viewer->name,
|
|
|
|
91+128, 93+128, temp
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-07-14 09:18:04 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%cQTV%c%s joins the stream\n",
|
2007-01-06 09:46:32 +00:00
|
|
|
91+128, 93+128, temp
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
if (!viewer->server || viewer->server->controller != viewer)
|
|
|
|
QW_StreamPrint(cluster, viewer->server, NULL, buf);
|
2007-01-06 09:46:32 +00:00
|
|
|
}
|
|
|
|
|
2007-12-27 15:17:05 +00:00
|
|
|
strlcpy(viewer->name, temp, sizeof(viewer->name));
|
2006-10-20 14:25:20 +00:00
|
|
|
|
|
|
|
Info_ValueForKey(viewer->userinfo, "rate", temp, sizeof(temp));
|
|
|
|
rate = atof(temp);
|
|
|
|
if (!rate)
|
|
|
|
rate = 2500;
|
|
|
|
if (rate < 250)
|
|
|
|
rate = 250;
|
|
|
|
if (rate > 10000)
|
|
|
|
rate = 10000;
|
|
|
|
viewer->netchan.rate = 1000.0f / rate;
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
void NewNQClient(cluster_t *cluster, netadr_t *addr)
|
|
|
|
{
|
2015-03-03 07:54:10 +00:00
|
|
|
// sv_t *initialserver;
|
2006-09-17 01:27:32 +00:00
|
|
|
int header;
|
|
|
|
int len;
|
2007-09-08 20:15:59 +00:00
|
|
|
int i;
|
2006-09-17 01:27:32 +00:00
|
|
|
unsigned char buffer[64];
|
|
|
|
viewer_t *viewer = NULL;;
|
|
|
|
|
|
|
|
|
|
|
|
if (cluster->numviewers >= cluster->maxviewers && cluster->maxviewers)
|
|
|
|
{
|
|
|
|
buffer[4] = CCREP_REJECT;
|
2007-07-23 10:53:59 +00:00
|
|
|
strcpy((char*)buffer+5, "Sorry, proxy is full.\n");
|
|
|
|
len = strlen((char*)buffer+5)+5;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
/* else
|
|
|
|
{
|
|
|
|
buffer[4] = CCREP_REJECT;
|
2007-07-23 10:53:59 +00:00
|
|
|
strcpy((char*)buffer+5, "NQ not supported yet\n");
|
|
|
|
len = strlen((char*)buffer+5)+5;
|
2006-09-17 01:27:32 +00:00
|
|
|
}*/
|
|
|
|
else if (!(viewer = malloc(sizeof(viewer_t))))
|
|
|
|
{
|
|
|
|
buffer[4] = CCREP_REJECT;
|
2007-07-23 10:53:59 +00:00
|
|
|
strcpy((char*)buffer+5, "Out of memory\n");
|
|
|
|
len = strlen((char*)buffer+5)+5;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer[4] = CCREP_ACCEPT;
|
|
|
|
buffer[5] = (cluster->qwlistenportnum&0x00ff)>>0;
|
|
|
|
buffer[6] = (cluster->qwlistenportnum&0xff00)>>8;
|
|
|
|
buffer[7] = 0;
|
|
|
|
buffer[8] = 0;
|
|
|
|
len = 4+1+4;
|
|
|
|
}
|
|
|
|
|
|
|
|
*(int*)buffer = NETFLAG_CTL | len;
|
|
|
|
header = (buffer[0]<<24) + (buffer[1]<<16) + (buffer[2]<<8) + buffer[3];
|
|
|
|
*(int*)buffer = header;
|
|
|
|
|
2015-04-21 04:12:00 +00:00
|
|
|
NET_SendPacket (cluster, NET_ChooseSocket(cluster->qwdsocket, addr, *addr), len, buffer, *addr);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
if (!viewer)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
memset(viewer, 0, sizeof(*viewer));
|
|
|
|
|
|
|
|
|
2015-04-21 04:12:00 +00:00
|
|
|
Netchan_Setup (NET_ChooseSocket(cluster->qwdsocket, addr, *addr), &viewer->netchan, *addr, 0, false);
|
2006-09-17 01:27:32 +00:00
|
|
|
viewer->netchan.isnqprotocol = true;
|
2007-11-15 21:19:52 +00:00
|
|
|
viewer->netchan.maxdatagramlen = MAX_NQDATAGRAM;
|
|
|
|
viewer->netchan.maxreliablelen = MAX_NQMSGLEN;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2008-10-05 16:18:17 +00:00
|
|
|
viewer->firstconnect = true;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
viewer->next = cluster->viewers;
|
|
|
|
cluster->viewers = viewer;
|
2007-09-08 20:15:59 +00:00
|
|
|
for (i = 0; i < ENTITY_FRAMES; i++)
|
|
|
|
viewer->delta_frames[i] = -1;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
cluster->numviewers++;
|
|
|
|
|
2006-10-20 14:25:20 +00:00
|
|
|
sprintf(viewer->userinfo, "\\name\\%s", "unnamed");
|
|
|
|
|
2006-10-22 20:33:12 +00:00
|
|
|
ParseUserInfo(cluster, viewer);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
NewClient(cluster, viewer);
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
if (!viewer->server)
|
|
|
|
QW_StuffcmdToViewer(viewer, "cmd new\n");
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
void NewQWClient(cluster_t *cluster, netadr_t *addr, char *connectmessage)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2015-03-03 07:54:10 +00:00
|
|
|
// sv_t *initialserver;
|
2005-09-06 01:09:36 +00:00
|
|
|
viewer_t *viewer;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
|
|
|
char qport[32];
|
|
|
|
char challenge[32];
|
|
|
|
char infostring[256];
|
2007-09-08 20:15:59 +00:00
|
|
|
int i;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
|
|
|
connectmessage+=11;
|
|
|
|
|
|
|
|
connectmessage = COM_ParseToken(connectmessage, qport, sizeof(qport), "");
|
|
|
|
connectmessage = COM_ParseToken(connectmessage, challenge, sizeof(challenge), "");
|
|
|
|
connectmessage = COM_ParseToken(connectmessage, infostring, sizeof(infostring), "");
|
|
|
|
|
|
|
|
if (!ChallengePasses(addr, atoi(challenge)))
|
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *addr, "n" "Bad challenge");
|
2005-09-24 04:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
viewer = malloc(sizeof(viewer_t));
|
2006-02-21 19:55:12 +00:00
|
|
|
if (!viewer)
|
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *addr, "n" "Out of memory");
|
2006-02-21 19:55:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
memset(viewer, 0, sizeof(viewer_t));
|
|
|
|
|
2015-04-21 04:12:00 +00:00
|
|
|
Netchan_Setup (NET_ChooseSocket(cluster->qwdsocket, addr, *addr), &viewer->netchan, *addr, atoi(qport), false);
|
2007-11-15 21:19:52 +00:00
|
|
|
viewer->netchan.message.maxsize = MAX_QWMSGLEN;
|
|
|
|
viewer->netchan.maxdatagramlen = MAX_QWMSGLEN;
|
|
|
|
viewer->netchan.maxreliablelen = MAX_QWMSGLEN;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2008-10-05 16:18:17 +00:00
|
|
|
viewer->firstconnect = true;
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
viewer->next = cluster->viewers;
|
|
|
|
cluster->viewers = viewer;
|
2007-09-08 20:15:59 +00:00
|
|
|
for (i = 0; i < ENTITY_FRAMES; i++)
|
|
|
|
viewer->delta_frames[i] = -1;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
cluster->numviewers++;
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2007-12-27 15:17:05 +00:00
|
|
|
strlcpy(viewer->userinfo, infostring, sizeof(viewer->userinfo));
|
2006-10-22 20:33:12 +00:00
|
|
|
ParseUserInfo(cluster, viewer);
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *addr, "j");
|
2006-02-20 01:33:13 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
NewClient(cluster, viewer);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2006-02-22 02:06:24 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
void QW_SetMenu(viewer_t *v, int menunum)
|
|
|
|
{
|
|
|
|
if ((v->menunum==MENU_NONE) != (menunum==MENU_NONE))
|
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
if (v->isproxy)
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
if (menunum != MENU_NONE)
|
|
|
|
QW_StuffcmdToViewer(v, "//set prox_inmenu 1\n");
|
|
|
|
else
|
|
|
|
QW_StuffcmdToViewer(v, "//set prox_inmenu 0\n");
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
if (menunum != MENU_NONE)
|
|
|
|
{
|
|
|
|
QW_StuffcmdToViewer(v, "//set prox_inmenu 1\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxjump\" \"say proxy:menu enter\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxfwd\" \"say proxy:menu up\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxback\" \"say proxy:menu down\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxleft\" \"say proxy:menu left\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxright\" \"say proxy:menu right\"\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxjump\" \" \"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxfwd\" \" \"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxback\" \" \"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxleft\" \" \"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxright\" \" \"\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QW_StuffcmdToViewer(v, "//set prox_inmenu 0\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxjump\" \"+jump\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxfwd\" \"+forward\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxback\" \"+back\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxleft\" \"+moveleft\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"+proxright\" \"+moveright\"\n");
|
|
|
|
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxjump\" \"-jump\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxfwd\" \"-forward\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxback\" \"-back\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxleft\" \"-moveleft\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "alias \"-proxright\" \"-moveright\"\n");
|
|
|
|
}
|
|
|
|
QW_StuffcmdToViewer(v, "-forward\n");
|
|
|
|
QW_StuffcmdToViewer(v, "-back\n");
|
|
|
|
QW_StuffcmdToViewer(v, "-moveleft\n");
|
|
|
|
QW_StuffcmdToViewer(v, "-moveright\n");
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
|
|
|
if (menunum==MENU_NONE || menunum==MENU_FORWARDING)
|
|
|
|
v->server->proxyisselected = false;
|
|
|
|
else
|
|
|
|
v->server->proxyisselected = true;
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
v->menunum = menunum;
|
|
|
|
v->menuop = 0;
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
v->menuspamtime = 0;
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
void QTV_Rcon(cluster_t *cluster, char *message, netadr_t *from)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2005-09-24 04:48:20 +00:00
|
|
|
char buffer[8192];
|
|
|
|
|
|
|
|
char *command;
|
|
|
|
int passlen;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (!*cluster->adminpassword)
|
2005-09-24 11:42:38 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "n" "Bad rcon_password.\n");
|
2005-09-24 11:42:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
while(*message > '\0' && *message <= ' ')
|
|
|
|
message++;
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
command = strchr(message, ' ');
|
|
|
|
passlen = command-message;
|
2006-09-17 01:27:32 +00:00
|
|
|
if (passlen != strlen(cluster->adminpassword) || strncmp(message, cluster->adminpassword, passlen))
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "n" "Bad rcon_password.\n");
|
2005-09-24 04:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "n%s", Rcon_Command(cluster, NULL, command, buffer, sizeof(buffer), false));
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
|
|
|
|
void QTV_Status(cluster_t *cluster, netadr_t *from)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2005-09-24 21:32:31 +00:00
|
|
|
int i;
|
2005-09-24 04:48:20 +00:00
|
|
|
char buffer[8192];
|
2005-10-07 02:02:15 +00:00
|
|
|
sv_t *sv;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
|
|
|
netmsg_t msg;
|
2005-09-24 21:32:31 +00:00
|
|
|
char elem[256];
|
2005-09-24 04:48:20 +00:00
|
|
|
InitNetMsg(&msg, buffer, sizeof(buffer));
|
|
|
|
WriteLong(&msg, -1);
|
|
|
|
WriteByte(&msg, 'n');
|
2005-09-24 21:32:31 +00:00
|
|
|
|
2006-10-07 22:29:31 +00:00
|
|
|
WriteString2(&msg, "\\*QTV\\");
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteString2(&msg, QTV_VERSION_STRING);
|
2006-10-07 22:29:31 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (cluster->numservers==1)
|
|
|
|
{ //show this server's info
|
|
|
|
sv = cluster->servers;
|
2005-09-24 21:32:31 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteString2(&msg, sv->map.serverinfo);
|
2005-09-24 21:32:31 +00:00
|
|
|
WriteString2(&msg, "\n");
|
2005-10-07 02:02:15 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
for (i = 0;i < MAX_CLIENTS; i++)
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (i == sv->map.thisplayer)
|
2006-04-11 22:15:09 +00:00
|
|
|
continue;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (!sv->map.players[i].active)
|
2005-10-07 02:02:15 +00:00
|
|
|
continue;
|
|
|
|
//userid
|
|
|
|
sprintf(elem, "%i", i);
|
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//frags
|
2009-07-07 23:40:06 +00:00
|
|
|
sprintf(elem, "%i", sv->map.players[i].frags);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//time (minuites)
|
|
|
|
sprintf(elem, "%i", 0);
|
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//ping
|
2009-07-07 23:40:06 +00:00
|
|
|
sprintf(elem, "%i", sv->map.players[i].ping);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//name
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(sv->map.players[i].userinfo, "name", elem, sizeof(elem));
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, "\"");
|
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, "\" ");
|
|
|
|
|
|
|
|
//skin
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(sv->map.players[i].userinfo, "skin", elem, sizeof(elem));
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, "\"");
|
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, "\" ");
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//tc
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(sv->map.players[i].userinfo, "topcolor", elem, sizeof(elem));
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
//bc
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(sv->map.players[i].userinfo, "bottomcolor", elem, sizeof(elem));
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, elem);
|
|
|
|
WriteString2(&msg, " ");
|
|
|
|
|
|
|
|
WriteString2(&msg, "\n");
|
|
|
|
}
|
2005-09-24 21:32:31 +00:00
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteString2(&msg, "\\hostname\\");
|
|
|
|
WriteString2(&msg, cluster->hostname);
|
2005-09-24 21:32:31 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
for (sv = cluster->servers, i = 0; sv; sv = sv->next, i++)
|
|
|
|
{
|
2006-10-07 22:29:31 +00:00
|
|
|
sprintf(elem, "\\%i\\", sv->streamid);
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteString2(&msg, elem);
|
2010-03-14 14:35:56 +00:00
|
|
|
WriteString2(&msg, sv->server);
|
|
|
|
// sprintf(elem, " (%s)", sv->serveraddress);
|
|
|
|
// WriteString2(&msg, elem);
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-08-03 19:57:56 +00:00
|
|
|
WriteString2(&msg, "\n");
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
2005-09-24 21:32:31 +00:00
|
|
|
|
|
|
|
WriteByte(&msg, 0);
|
2015-04-21 04:12:00 +00:00
|
|
|
NET_SendPacket(cluster, NET_ChooseSocket(cluster->qwdsocket, from, *from), msg.cursize, msg.data, *from);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
void QTV_StatusResponse(cluster_t *cluster, char *msg, netadr_t *from)
|
|
|
|
{
|
|
|
|
int p, tc, bc;
|
|
|
|
char name[64], skin[64], token[64];
|
|
|
|
sv_t *sv;
|
|
|
|
|
|
|
|
char *eol;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
for (sv = cluster->servers; sv; sv = sv->next)
|
|
|
|
{
|
|
|
|
/*ignore connected streams*/
|
|
|
|
if (sv->isconnected)
|
|
|
|
continue;
|
|
|
|
/*and only streams that we could have requested this from*/
|
|
|
|
if (sv->autodisconnect != AD_STATUSPOLL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (Net_CompareAddress(&sv->serveraddress, from, 0, 1))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*not a valid server... weird.*/
|
|
|
|
if (!sv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*skip the n directive*/
|
|
|
|
msg++;
|
|
|
|
eol = strchr(msg, '\n');
|
|
|
|
if (!eol)
|
|
|
|
return;
|
|
|
|
*eol = 0;
|
|
|
|
|
|
|
|
strlcpy(sv->map.serverinfo, msg, sizeof(sv->map.serverinfo));
|
|
|
|
QTV_UpdatedServerInfo(sv);
|
|
|
|
|
2020-02-11 18:06:10 +00:00
|
|
|
// Info_ValueForKey(sv->map.serverinfo, "map", sv->map.mapname, sizeof(sv->map.mapname));
|
2010-03-14 14:35:56 +00:00
|
|
|
Info_ValueForKey(sv->map.serverinfo, "*gamedir", sv->map.gamedir, sizeof(sv->map.gamedir));
|
|
|
|
if (!*sv->map.gamedir)
|
|
|
|
strlcpy(sv->map.gamedir, "qw", sizeof(sv->map.gamedir));
|
|
|
|
|
|
|
|
for(p = 0; p < MAX_CLIENTS; p++)
|
|
|
|
{
|
|
|
|
msg = eol+1;
|
|
|
|
eol = strchr(msg, '\n');
|
|
|
|
if (!eol)
|
|
|
|
break;
|
|
|
|
*eol = 0;
|
|
|
|
|
|
|
|
sv->map.players[p].active = false;
|
|
|
|
|
|
|
|
//userid
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
|
|
|
|
//frags
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
sv->map.players[p].frags = atoi(token);
|
|
|
|
|
|
|
|
//time (minuites)
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
|
|
|
|
//ping
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
sv->map.players[p].ping = atoi(token);
|
|
|
|
|
|
|
|
//name
|
|
|
|
msg = COM_ParseToken(msg, name, sizeof(name), NULL);
|
|
|
|
|
|
|
|
//skin
|
|
|
|
msg = COM_ParseToken(msg, skin, sizeof(skin), NULL);
|
|
|
|
|
|
|
|
//tc
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
tc = atoi(token);
|
|
|
|
|
|
|
|
//bc
|
|
|
|
msg = COM_ParseToken(msg, token, sizeof(token), NULL);
|
|
|
|
bc = atoi(token);
|
|
|
|
|
|
|
|
snprintf(sv->map.players[p].userinfo, sizeof(sv->map.players[p].userinfo), "\\name\\%s\\skin\\%s\\topcolor\\%i\\bottomcolor\\%i", name, skin, tc, bc);
|
|
|
|
}
|
|
|
|
for(; p < MAX_CLIENTS; p++)
|
|
|
|
{
|
|
|
|
sv->map.players[p].active = false;
|
|
|
|
*sv->map.players[p].userinfo = 0;
|
|
|
|
}
|
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
void ConnectionlessPacket(cluster_t *cluster, netadr_t *from, netmsg_t *m)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2007-11-15 21:19:52 +00:00
|
|
|
char buffer[MAX_QWMSGLEN];
|
2005-09-06 01:09:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
ReadLong(m);
|
|
|
|
ReadString(m, buffer, sizeof(buffer));
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
if (!strncmp(buffer, "n\\", 2))
|
|
|
|
{
|
|
|
|
QTV_StatusResponse(cluster, buffer, from);
|
|
|
|
return;
|
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
if (!strncmp(buffer, "rcon ", 5))
|
|
|
|
{
|
2005-10-07 02:02:15 +00:00
|
|
|
QTV_Rcon(cluster, buffer+5, from);
|
2005-09-24 04:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-09-24 12:14:42 +00:00
|
|
|
if (!strncmp(buffer, "ping", 4))
|
|
|
|
{ //ack
|
2015-04-21 04:12:00 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "l");
|
2005-09-24 12:14:42 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
if (!strncmp(buffer, "status", 6))
|
|
|
|
{
|
2005-10-07 02:02:15 +00:00
|
|
|
QTV_Status(cluster, from);
|
2005-09-24 04:48:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
if (!strncmp(buffer, "getchallenge", 12))
|
|
|
|
{
|
|
|
|
i = NewChallenge(from);
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "c%i", i);
|
2005-09-06 01:09:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!strncmp(buffer, "connect 28 ", 11))
|
|
|
|
{
|
2005-10-07 02:02:15 +00:00
|
|
|
if (cluster->numviewers >= cluster->maxviewers && cluster->maxviewers)
|
2012-04-20 14:41:40 +00:00
|
|
|
Netchan_OutOfBandPrint(cluster, *from, "n" "Sorry, proxy is full.\n");
|
2005-09-24 04:48:20 +00:00
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
NewQWClient(cluster, from, buffer);
|
2005-09-06 01:09:36 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-21 04:12:00 +00:00
|
|
|
// if (buffer[0] == 'l' && (!buffer[1] || buffer[1] == '\n'))
|
|
|
|
// {
|
|
|
|
// Sys_Printf(cluster, "Ack from %s\n", );
|
|
|
|
// }
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
void SV_WriteDelta(int entnum, const entity_state_t *from, const entity_state_t *to, netmsg_t *msg, qboolean force, unsigned int pext)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int bits;
|
|
|
|
|
|
|
|
bits = 0;
|
|
|
|
if (from->angles[0] != to->angles[0])
|
|
|
|
bits |= U_ANGLE1;
|
|
|
|
if (from->angles[1] != to->angles[1])
|
|
|
|
bits |= U_ANGLE2;
|
|
|
|
if (from->angles[2] != to->angles[2])
|
|
|
|
bits |= U_ANGLE3;
|
|
|
|
|
|
|
|
if (from->origin[0] != to->origin[0])
|
|
|
|
bits |= U_ORIGIN1;
|
|
|
|
if (from->origin[1] != to->origin[1])
|
|
|
|
bits |= U_ORIGIN2;
|
|
|
|
if (from->origin[2] != to->origin[2])
|
|
|
|
bits |= U_ORIGIN3;
|
|
|
|
|
|
|
|
if (from->colormap != to->colormap)
|
|
|
|
bits |= U_COLORMAP;
|
|
|
|
if (from->skinnum != to->skinnum)
|
|
|
|
bits |= U_SKIN;
|
|
|
|
if (from->modelindex != to->modelindex)
|
2018-04-06 17:39:32 +00:00
|
|
|
{
|
|
|
|
if (to->modelindex > 0xff)
|
|
|
|
{
|
|
|
|
if (to->modelindex <= 0x1ff)
|
|
|
|
bits |= U_MODEL|UX_MODELDBL; //0x100|byte
|
|
|
|
else
|
|
|
|
bits |= UX_MODELDBL; //short
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bits |= U_MODEL;
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
if (from->frame != to->frame)
|
|
|
|
bits |= U_FRAME;
|
2018-04-06 17:39:32 +00:00
|
|
|
if ((from->effects&0xff) != (to->effects&0xff))
|
2005-09-06 01:09:36 +00:00
|
|
|
bits |= U_EFFECTS;
|
2018-04-06 17:39:32 +00:00
|
|
|
if ((from->effects&0xff00) != (to->effects&0xff00))
|
|
|
|
bits |= UX_EFFECTS16;
|
|
|
|
if (from->alpha != to->alpha)
|
|
|
|
bits |= UX_ALPHA;
|
|
|
|
if (from->scale != to->scale)
|
|
|
|
bits |= UX_SCALE;
|
|
|
|
|
|
|
|
if (bits & 0xff000000)
|
|
|
|
bits |= UX_YETMORE;
|
|
|
|
if (bits & 0x00ff0000)
|
|
|
|
bits |= UX_EVENMORE;
|
|
|
|
if (bits & 0x000000ff)
|
2005-09-06 01:09:36 +00:00
|
|
|
bits |= U_MOREBITS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!bits && !force)
|
|
|
|
return;
|
|
|
|
|
|
|
|
i = (entnum&511) | (bits&~511);
|
|
|
|
WriteShort (msg, i);
|
|
|
|
|
|
|
|
if (bits & U_MOREBITS)
|
|
|
|
WriteByte (msg, bits&255);
|
2018-04-06 17:39:32 +00:00
|
|
|
|
|
|
|
if (bits & UX_EVENMORE)
|
|
|
|
WriteByte (msg, bits>>16);
|
|
|
|
if (bits & UX_YETMORE)
|
|
|
|
WriteByte (msg, bits>>24);
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_MODEL)
|
|
|
|
WriteByte (msg, to->modelindex&255);
|
2018-04-06 17:39:32 +00:00
|
|
|
else if (bits & UX_MODELDBL)
|
|
|
|
WriteShort(msg, to->modelindex&0xffff);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_FRAME)
|
|
|
|
WriteByte (msg, to->frame);
|
|
|
|
if (bits & U_COLORMAP)
|
|
|
|
WriteByte (msg, to->colormap);
|
|
|
|
if (bits & U_SKIN)
|
|
|
|
WriteByte (msg, to->skinnum);
|
|
|
|
if (bits & U_EFFECTS)
|
|
|
|
WriteByte (msg, to->effects&0x00ff);
|
|
|
|
if (bits & U_ORIGIN1)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteCoord(msg, to->origin[0], pext);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_ANGLE1)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteAngle(msg, to->angles[0], pext);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_ORIGIN2)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteCoord(msg, to->origin[1], pext);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_ANGLE2)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteAngle(msg, to->angles[1], pext);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_ORIGIN3)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteCoord(msg, to->origin[2], pext);
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bits & U_ANGLE3)
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
WriteAngle(msg, to->angles[2], pext);
|
2018-04-06 17:39:32 +00:00
|
|
|
|
|
|
|
if (bits & UX_SCALE)
|
|
|
|
WriteByte (msg, to->scale);
|
|
|
|
if (bits & UX_ALPHA)
|
|
|
|
WriteByte (msg, to->alpha);
|
|
|
|
/* if (bits & UX_FATNESS)
|
|
|
|
WriteByte (msg, to->fatness);
|
|
|
|
if (bits & UX_DRAWFLAGS)
|
|
|
|
WriteByte (msg, to->hexen2flags);
|
|
|
|
if (bits & UX_ABSLIGHT)
|
|
|
|
WriteByte (msg, to->abslight);
|
|
|
|
if (bits & UX_COLOURMOD)
|
|
|
|
{
|
|
|
|
WriteByte (msg, to->colormod[0]);
|
|
|
|
WriteByte (msg, to->colormod[1]);
|
|
|
|
WriteByte (msg, to->colormod[2]);
|
|
|
|
}
|
|
|
|
if (bits & UX_DPFLAGS)
|
|
|
|
{ // these are bits for the 'flags' field of the entity_state_t
|
|
|
|
WriteByte (msg, to->dpflags);
|
|
|
|
}
|
|
|
|
if (bits & UX_TAGINFO)
|
|
|
|
{
|
|
|
|
WriteShort (msg, to->tagentity);
|
|
|
|
WriteShort (msg, to->tagindex);
|
|
|
|
}
|
|
|
|
if (bits & UX_LIGHT)
|
|
|
|
{
|
|
|
|
WriteShort (msg, to->light[0]);
|
|
|
|
WriteShort (msg, to->light[1]);
|
|
|
|
WriteShort (msg, to->light[2]);
|
|
|
|
WriteShort (msg, to->light[3]);
|
|
|
|
WriteByte (msg, to->lightstyle);
|
|
|
|
WriteByte (msg, to->lightpflags);
|
|
|
|
}*/
|
|
|
|
if (bits & UX_EFFECTS16)
|
|
|
|
WriteByte (msg, to->effects>>8);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2007-08-01 14:55:28 +00:00
|
|
|
const entity_state_t nullentstate = {0};
|
2005-09-06 01:09:36 +00:00
|
|
|
void SV_EmitPacketEntities (const sv_t *qtv, const viewer_t *v, const packet_entities_t *to, netmsg_t *msg)
|
|
|
|
{
|
|
|
|
const entity_state_t *baseline;
|
|
|
|
const packet_entities_t *from;
|
|
|
|
int oldindex, newindex;
|
|
|
|
int oldnum, newnum;
|
|
|
|
int oldmax;
|
2007-09-08 20:15:59 +00:00
|
|
|
int delta_frame;
|
|
|
|
|
|
|
|
delta_frame = v->delta_frames[v->netchan.outgoing_sequence&(ENTITY_FRAMES-1)];
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
// this is the frame that we are going to delta update from
|
2007-09-08 20:15:59 +00:00
|
|
|
if (delta_frame != -1)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2007-09-08 20:15:59 +00:00
|
|
|
from = &v->frame[delta_frame & (ENTITY_FRAMES-1)];
|
2005-09-06 01:09:36 +00:00
|
|
|
oldmax = from->numents;
|
|
|
|
|
|
|
|
WriteByte (msg, svc_deltapacketentities);
|
2007-09-08 20:15:59 +00:00
|
|
|
WriteByte (msg, delta_frame);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldmax = 0; // no delta update
|
|
|
|
from = NULL;
|
|
|
|
|
|
|
|
WriteByte (msg, svc_packetentities);
|
|
|
|
}
|
|
|
|
|
|
|
|
newindex = 0;
|
|
|
|
oldindex = 0;
|
|
|
|
//Con_Printf ("---%i to %i ----\n", client->delta_sequence & UPDATE_MASK
|
|
|
|
// , client->netchan.outgoing_sequence & UPDATE_MASK);
|
|
|
|
while (newindex < to->numents || oldindex < oldmax)
|
|
|
|
{
|
|
|
|
newnum = newindex >= to->numents ? 9999 : to->entnum[newindex];
|
|
|
|
oldnum = oldindex >= oldmax ? 9999 : from->entnum[oldindex];
|
|
|
|
|
|
|
|
if (newnum == oldnum)
|
|
|
|
{ // delta update from old position
|
|
|
|
//Con_Printf ("delta %i\n", newnum);
|
2018-04-06 17:39:32 +00:00
|
|
|
SV_WriteDelta (newnum, &from->ents[oldindex], &to->ents[newindex], msg, false, qtv->pext1);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
oldindex++;
|
|
|
|
newindex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newnum < oldnum)
|
|
|
|
{ // this is a new entity, send it from the baseline
|
2009-07-07 23:40:06 +00:00
|
|
|
baseline = &qtv->map.entity[newnum].baseline;
|
2005-09-06 01:09:36 +00:00
|
|
|
//Con_Printf ("baseline %i\n", newnum);
|
2018-04-06 17:39:32 +00:00
|
|
|
SV_WriteDelta (newnum, baseline, &to->ents[newindex], msg, true, qtv->pext1);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
newindex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newnum > oldnum)
|
|
|
|
{ // the old entity isn't present in the new message
|
|
|
|
//Con_Printf ("remove %i\n", oldnum);
|
|
|
|
WriteShort (msg, oldnum | U_REMOVE);
|
|
|
|
oldindex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteShort (msg, 0); // end of packetentities
|
|
|
|
}
|
|
|
|
|
|
|
|
void Prox_SendInitialEnts(sv_t *qtv, oproxy_t *prox, netmsg_t *msg)
|
|
|
|
{
|
2006-12-26 21:26:10 +00:00
|
|
|
frame_t *frame;
|
|
|
|
int i, entnum;
|
2005-09-06 01:09:36 +00:00
|
|
|
WriteByte(msg, svc_packetentities);
|
2009-07-07 23:40:06 +00:00
|
|
|
frame = &qtv->map.frame[qtv->netchan.incoming_sequence & (ENTITY_FRAMES-1)];
|
2006-12-26 21:26:10 +00:00
|
|
|
for (i = 0; i < frame->numents; i++)
|
2005-09-24 14:48:43 +00:00
|
|
|
{
|
2006-12-26 21:26:10 +00:00
|
|
|
entnum = frame->entnums[i];
|
2018-04-06 17:39:32 +00:00
|
|
|
SV_WriteDelta(entnum, &qtv->map.entity[entnum].baseline, &frame->ents[i], msg, true, qtv->pext1);
|
2005-09-24 14:48:43 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
WriteShort(msg, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static float InterpolateAngle(float current, float ideal, float fraction)
|
|
|
|
{
|
|
|
|
float move;
|
|
|
|
|
|
|
|
move = ideal - current;
|
2018-04-06 17:39:32 +00:00
|
|
|
if (move >= 180)
|
|
|
|
move -= 360;
|
|
|
|
else if (move <= -180)
|
|
|
|
move += 360;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
return current + fraction * move;
|
|
|
|
}
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
void SendLocalPlayerState(sv_t *tv, viewer_t *v, int playernum, netmsg_t *msg)
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
int j;
|
2018-04-06 17:39:32 +00:00
|
|
|
unsigned int pext1 = tv?tv->pext1:0;
|
2006-04-11 22:15:09 +00:00
|
|
|
|
|
|
|
WriteByte(msg, svc_playerinfo);
|
|
|
|
WriteByte(msg, playernum);
|
|
|
|
|
|
|
|
if (tv && tv->controller == v)
|
2007-09-10 18:56:01 +00:00
|
|
|
{ //we're the one that is actually playing.
|
2009-07-07 23:40:06 +00:00
|
|
|
v->trackplayer = tv->map.thisplayer;
|
2006-04-11 22:15:09 +00:00
|
|
|
flags = 0;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[tv->map.thisplayer].current.weaponframe)
|
2006-04-11 22:15:09 +00:00
|
|
|
flags |= PF_WEAPONFRAME;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[tv->map.thisplayer].current.effects)
|
2006-04-11 22:15:09 +00:00
|
|
|
flags |= PF_EFFECTS;
|
2007-09-10 18:56:01 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[tv->map.thisplayer].dead)
|
2007-09-10 18:56:01 +00:00
|
|
|
flags |= PF_DEAD;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[tv->map.thisplayer].gibbed)
|
2007-09-10 18:56:01 +00:00
|
|
|
flags |= PF_GIB;
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
for (j=0 ; j<3 ; j++)
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[tv->map.thisplayer].current.velocity[j])
|
2006-04-11 22:15:09 +00:00
|
|
|
flags |= (PF_VELOCITY1<<j);
|
|
|
|
|
|
|
|
WriteShort(msg, flags);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, tv->map.players[tv->map.thisplayer].current.origin[0], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.players[tv->map.thisplayer].current.origin[1], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.players[tv->map.thisplayer].current.origin[2], tv->pext1);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[tv->map.thisplayer].current.frame);
|
2006-04-11 22:15:09 +00:00
|
|
|
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
if (flags & (PF_VELOCITY1<<j) )
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort (msg, tv->map.players[tv->map.thisplayer].current.velocity[j]);
|
2006-04-11 22:15:09 +00:00
|
|
|
|
|
|
|
if (flags & PF_MODEL)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[tv->map.thisplayer].current.modelindex);
|
2006-04-11 22:15:09 +00:00
|
|
|
if (flags & PF_SKINNUM)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[tv->map.thisplayer].current.skinnum);
|
2006-04-11 22:15:09 +00:00
|
|
|
if (flags & PF_EFFECTS)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[tv->map.thisplayer].current.effects);
|
2006-04-11 22:15:09 +00:00
|
|
|
if (flags & PF_WEAPONFRAME)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[tv->map.thisplayer].current.weaponframe);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-10-20 14:25:20 +00:00
|
|
|
flags = 0;
|
|
|
|
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
if ((int)v->velocity[j])
|
|
|
|
flags |= (PF_VELOCITY1<<j);
|
|
|
|
|
|
|
|
WriteShort(msg, flags);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, v->origin[0], pext1);
|
|
|
|
WriteCoord(msg, v->origin[1], pext1);
|
|
|
|
WriteCoord(msg, v->origin[2], pext1);
|
2006-04-11 22:15:09 +00:00
|
|
|
WriteByte(msg, 0);
|
2006-10-20 14:25:20 +00:00
|
|
|
|
|
|
|
for (j=0 ; j<3 ; j++)
|
|
|
|
if (flags & (PF_VELOCITY1<<j) )
|
|
|
|
WriteShort (msg, v->velocity[j]);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
#define UNQ_MOREBITS (1<<0)
|
|
|
|
#define UNQ_ORIGIN1 (1<<1)
|
|
|
|
#define UNQ_ORIGIN2 (1<<2)
|
|
|
|
#define UNQ_ORIGIN3 (1<<3)
|
|
|
|
#define UNQ_ANGLE2 (1<<4)
|
|
|
|
#define UNQ_NOLERP (1<<5) // don't interpolate movement
|
|
|
|
#define UNQ_FRAME (1<<6)
|
|
|
|
#define UNQ_SIGNAL (1<<7) // just differentiates from other updates
|
|
|
|
|
|
|
|
// svc_update can pass all of the fast update bits, plus more
|
|
|
|
#define UNQ_ANGLE1 (1<<8)
|
|
|
|
#define UNQ_ANGLE3 (1<<9)
|
|
|
|
#define UNQ_MODEL (1<<10)
|
|
|
|
#define UNQ_COLORMAP (1<<11)
|
|
|
|
#define UNQ_SKIN (1<<12)
|
|
|
|
#define UNQ_EFFECTS (1<<13)
|
|
|
|
#define UNQ_LONGENTITY (1<<14)
|
|
|
|
#define UNQ_UNUSED (1<<15)
|
|
|
|
|
|
|
|
|
|
|
|
#define SU_VIEWHEIGHT (1<<0)
|
|
|
|
#define SU_IDEALPITCH (1<<1)
|
|
|
|
#define SU_PUNCH1 (1<<2)
|
|
|
|
#define SU_PUNCH2 (1<<3)
|
|
|
|
#define SU_PUNCH3 (1<<4)
|
|
|
|
#define SU_VELOCITY1 (1<<5)
|
|
|
|
#define SU_VELOCITY2 (1<<6)
|
|
|
|
#define SU_VELOCITY3 (1<<7)
|
|
|
|
//define SU_AIMENT (1<<8) AVAILABLE BIT
|
|
|
|
#define SU_ITEMS (1<<9)
|
|
|
|
#define SU_ONGROUND (1<<10) // no data follows, the bit is it
|
|
|
|
#define SU_INWATER (1<<11) // no data follows, the bit is it
|
|
|
|
#define SU_WEAPONFRAME (1<<12)
|
|
|
|
#define SU_ARMOR (1<<13)
|
|
|
|
#define SU_WEAPON (1<<14)
|
|
|
|
|
|
|
|
void SendNQClientData(sv_t *tv, viewer_t *v, netmsg_t *msg)
|
|
|
|
{
|
|
|
|
playerinfo_t *pl;
|
|
|
|
int bits;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!tv)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (v->trackplayer < 0)
|
2006-09-19 01:48:12 +00:00
|
|
|
{
|
|
|
|
WriteByte (msg, svc_nqclientdata);
|
|
|
|
WriteShort (msg, SU_VIEWHEIGHT|SU_ITEMS);
|
2007-03-03 18:46:43 +00:00
|
|
|
WriteByte (msg, 22); //viewheight
|
|
|
|
WriteLong (msg, 0); //items
|
|
|
|
WriteShort (msg, 1000); //health
|
|
|
|
WriteByte (msg, 0); //currentammo
|
|
|
|
WriteByte (msg, 0); //shells
|
|
|
|
WriteByte (msg, 0); //nails
|
|
|
|
WriteByte (msg, 0); //rockets
|
|
|
|
WriteByte (msg, 0); //cells
|
|
|
|
WriteByte (msg, 0); //active weapon
|
2006-09-19 01:48:12 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
else
|
2009-07-07 23:40:06 +00:00
|
|
|
pl = &tv->map.players[v->trackplayer];
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
bits = 0;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (!pl->dead)
|
|
|
|
bits |= SU_VIEWHEIGHT;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (0)
|
|
|
|
bits |= SU_IDEALPITCH;
|
|
|
|
|
|
|
|
bits |= SU_ITEMS;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if ( 0)
|
|
|
|
bits |= SU_ONGROUND;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if ( 0 )
|
|
|
|
bits |= SU_INWATER;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
if (0)
|
|
|
|
bits |= (SU_PUNCH1<<i);
|
|
|
|
if (0)
|
|
|
|
bits |= (SU_VELOCITY1<<i);
|
|
|
|
}
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (pl->current.weaponframe)
|
|
|
|
bits |= SU_WEAPONFRAME;
|
|
|
|
|
|
|
|
if (pl->stats[STAT_ARMOR])
|
|
|
|
bits |= SU_ARMOR;
|
|
|
|
|
|
|
|
// if (pl->stats[STAT_WEAPON])
|
|
|
|
bits |= SU_WEAPON;
|
|
|
|
|
|
|
|
// send the data
|
|
|
|
|
|
|
|
WriteByte (msg, svc_nqclientdata);
|
|
|
|
WriteShort (msg, bits);
|
|
|
|
|
|
|
|
if (bits & SU_VIEWHEIGHT)
|
|
|
|
WriteByte (msg, 22);
|
|
|
|
|
|
|
|
if (bits & SU_IDEALPITCH)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
|
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
if (bits & (SU_PUNCH1<<i))
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & (SU_VELOCITY1<<i))
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
}
|
|
|
|
|
2016-02-15 06:01:17 +00:00
|
|
|
if (bits & SU_ITEMS)
|
|
|
|
WriteLong (msg, pl->stats[STAT_ITEMS]);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
if (bits & SU_WEAPONFRAME)
|
|
|
|
WriteByte (msg, pl->current.weaponframe);
|
|
|
|
if (bits & SU_ARMOR)
|
|
|
|
WriteByte (msg, pl->stats[STAT_ARMOR]);
|
|
|
|
if (bits & SU_WEAPON)
|
2015-03-03 07:54:10 +00:00
|
|
|
WriteByte (msg, pl->stats[STAT_WEAPONMODELI]);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteShort (msg, pl->stats[STAT_HEALTH]);
|
|
|
|
WriteByte (msg, pl->stats[STAT_AMMO]);
|
|
|
|
WriteByte (msg, pl->stats[STAT_SHELLS]);
|
|
|
|
WriteByte (msg, pl->stats[STAT_NAILS]);
|
|
|
|
WriteByte (msg, pl->stats[STAT_ROCKETS]);
|
|
|
|
WriteByte (msg, pl->stats[STAT_CELLS]);
|
|
|
|
|
|
|
|
WriteByte (msg, pl->stats[STAT_ACTIVEWEAPON]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SendNQPlayerStates(cluster_t *cluster, sv_t *tv, viewer_t *v, netmsg_t *msg)
|
|
|
|
{
|
|
|
|
int e;
|
|
|
|
int i;
|
|
|
|
usercmd_t to;
|
|
|
|
float lerp;
|
|
|
|
int bits;
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
float org[3];
|
2006-09-17 01:27:32 +00:00
|
|
|
entity_t *ent;
|
|
|
|
playerinfo_t *pl;
|
2018-04-06 17:39:32 +00:00
|
|
|
unsigned int pext1;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
memset(&to, 0, sizeof(to));
|
|
|
|
|
|
|
|
if (tv)
|
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
pext1 = tv->pext1;
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte(msg, svc_nqtime);
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteFloat(msg, (tv->physicstime - tv->mapstarttime)/1000.0f);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
BSP_SetupForPosition(tv->map.bsp, v->origin[0], v->origin[1], v->origin[2]);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
lerp = ((tv->simtime - tv->oldpackettime)/1000.0f) / ((tv->nextpackettime - tv->oldpackettime)/1000.0f);
|
2012-04-23 04:37:33 +00:00
|
|
|
lerp = 1;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
// if (tv->controller == v)
|
|
|
|
// lerp = 1;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteByte(msg, svc_nqtime);
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteFloat(msg, (cluster->curtime)/1000.0f);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
lerp = 1;
|
2018-04-06 17:39:32 +00:00
|
|
|
pext1 = 0;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SendNQClientData(tv, v, msg);
|
|
|
|
|
|
|
|
if (tv)
|
|
|
|
{
|
2012-04-23 04:37:33 +00:00
|
|
|
if (v != tv->controller)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2012-04-23 04:37:33 +00:00
|
|
|
if (v->trackplayer >= 0)
|
|
|
|
{
|
|
|
|
WriteByte(msg, svc_nqsetview);
|
|
|
|
WriteShort(msg, v->trackplayer+1);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
WriteByte(msg, svc_setangle);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, InterpolateAngle(tv->map.players[v->trackplayer].old.angles[0], tv->map.players[v->trackplayer].current.angles[0], lerp), tv->pext1);
|
|
|
|
WriteAngle(msg, InterpolateAngle(tv->map.players[v->trackplayer].old.angles[1], tv->map.players[v->trackplayer].current.angles[1], lerp), tv->pext1);
|
|
|
|
WriteAngle(msg, InterpolateAngle(tv->map.players[v->trackplayer].old.angles[2], tv->map.players[v->trackplayer].current.angles[2], lerp), tv->pext1);
|
2012-04-23 04:37:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteByte(msg, svc_nqsetview);
|
|
|
|
WriteShort(msg, v->thisplayer+1);
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (e = 0; e < MAX_CLIENTS; e++)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
pl = &tv->map.players[e];
|
|
|
|
ent = &tv->map.entity[e+1];
|
2006-09-19 01:48:12 +00:00
|
|
|
|
|
|
|
if (e == v->thisplayer && v->trackplayer < 0)
|
|
|
|
{
|
|
|
|
bits = UNQ_ORIGIN1 | UNQ_ORIGIN2 | UNQ_ORIGIN3 | UNQ_COLORMAP;
|
|
|
|
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (e+1 > 255)
|
2006-09-19 01:48:12 +00:00
|
|
|
bits |= UNQ_LONGENTITY;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (bits > 255)
|
2006-09-19 01:48:12 +00:00
|
|
|
bits |= UNQ_MOREBITS;
|
|
|
|
WriteByte (msg,bits | UNQ_SIGNAL);
|
|
|
|
if (bits & UNQ_MOREBITS)
|
|
|
|
WriteByte (msg, bits>>8);
|
|
|
|
if (bits & UNQ_LONGENTITY)
|
|
|
|
WriteShort (msg,e+1);
|
|
|
|
else
|
|
|
|
WriteByte (msg,e+1);
|
|
|
|
|
|
|
|
if (bits & UNQ_MODEL)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & UNQ_FRAME)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & UNQ_COLORMAP)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & UNQ_SKIN)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & UNQ_EFFECTS)
|
|
|
|
WriteByte (msg, 0);
|
|
|
|
if (bits & UNQ_ORIGIN1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, v->origin[0], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
if (bits & UNQ_ANGLE1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, -v->ucmds[2].angles[0], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
if (bits & UNQ_ORIGIN2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, v->origin[1], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
if (bits & UNQ_ANGLE2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, v->ucmds[2].angles[1], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
if (bits & UNQ_ORIGIN3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, v->origin[2], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
if (bits & UNQ_ANGLE3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, v->ucmds[2].angles[2], tv->pext1);
|
2006-09-19 01:48:12 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (!pl->active)
|
|
|
|
continue;
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (v != tv->controller && e != v->trackplayer)
|
|
|
|
if (pl->current.modelindex >= tv->map.numinlines && !BSP_Visible(tv->map.bsp, pl->leafcount, pl->leafs)) //don't cull bsp objects, like nq...
|
2012-04-23 04:37:33 +00:00
|
|
|
continue;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
|
|
|
// send an update
|
|
|
|
bits = 0;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
|
|
|
org[i] = (lerp)*pl->current.origin[i] + (1-lerp)*pl->old.origin[i];
|
|
|
|
bits |= UNQ_ORIGIN1<<i;
|
|
|
|
}
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if ( pl->current.angles[0] != ent->baseline.angles[0] )
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_ANGLE1;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if ( pl->current.angles[1] != ent->baseline.angles[1] )
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_ANGLE2;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if ( pl->current.angles[2] != ent->baseline.angles[2] )
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_ANGLE3;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
// if (pl->v.movetype == MOVETYPE_STEP)
|
|
|
|
// bits |= UNQ_NOLERP; // don't mess up the step animation
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-19 01:48:12 +00:00
|
|
|
if (ent->baseline.colormap != e+1 || ent->baseline.colormap > 15)
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_COLORMAP;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (ent->baseline.skinnum != pl->current.skinnum)
|
|
|
|
bits |= UNQ_SKIN;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (ent->baseline.frame != pl->current.frame)
|
|
|
|
bits |= UNQ_FRAME;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (ent->baseline.effects != pl->current.effects)
|
|
|
|
bits |= UNQ_EFFECTS;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (ent->baseline.modelindex != pl->current.modelindex)
|
|
|
|
bits |= UNQ_MODEL;
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (e+1 > 255)
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_LONGENTITY;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (bits > 255)
|
2006-09-17 01:27:32 +00:00
|
|
|
bits |= UNQ_MOREBITS;
|
|
|
|
|
|
|
|
//
|
|
|
|
// write the message
|
|
|
|
//
|
|
|
|
WriteByte (msg,bits | UNQ_SIGNAL);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_MOREBITS)
|
|
|
|
WriteByte (msg, bits>>8);
|
|
|
|
if (bits & UNQ_LONGENTITY)
|
|
|
|
WriteShort (msg,e+1);
|
|
|
|
else
|
|
|
|
WriteByte (msg,e+1);
|
|
|
|
|
|
|
|
if (bits & UNQ_MODEL)
|
|
|
|
WriteByte (msg, pl->current.modelindex);
|
|
|
|
if (bits & UNQ_FRAME)
|
|
|
|
WriteByte (msg, pl->current.frame);
|
|
|
|
if (bits & UNQ_COLORMAP)
|
|
|
|
WriteByte (msg, (e>=15)?0:(e+1));
|
|
|
|
if (bits & UNQ_SKIN)
|
|
|
|
WriteByte (msg, pl->current.skinnum);
|
|
|
|
if (bits & UNQ_EFFECTS)
|
|
|
|
WriteByte (msg, pl->current.effects);
|
|
|
|
if (bits & UNQ_ORIGIN1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, org[0], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_ANGLE1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, -pl->current.angles[0], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_ORIGIN2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, org[1], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_ANGLE2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, pl->current.angles[1], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_ORIGIN3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, org[2], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
if (bits & UNQ_ANGLE3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, pl->current.angles[2], tv->pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
2007-03-03 18:46:43 +00:00
|
|
|
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
int newindex = 0;
|
|
|
|
entity_state_t *newstate;
|
|
|
|
int newnum;
|
|
|
|
frame_t *topacket;
|
|
|
|
int snapdist = 128; //in quake units
|
|
|
|
int miss;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
snapdist = snapdist*8;
|
|
|
|
snapdist = snapdist*snapdist;
|
2006-12-26 21:26:10 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
topacket = &tv->map.frame[tv->netchan.incoming_sequence&(ENTITY_FRAMES-1)];
|
2006-09-19 01:48:12 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
for (newindex = 0; newindex < topacket->numents; newindex++)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
//don't pvs cull bsp models
|
|
|
|
//pvs cull everything else
|
|
|
|
newstate = &topacket->ents[newindex];
|
|
|
|
newnum = topacket->entnums[newindex];
|
2012-04-23 04:37:33 +00:00
|
|
|
if (v != tv->controller)
|
|
|
|
if (newstate->modelindex >= tv->map.numinlines && !BSP_Visible(tv->map.bsp, tv->map.entity[newnum].leafcount, tv->map.entity[newnum].leafs))
|
|
|
|
continue;
|
2007-03-03 18:46:43 +00:00
|
|
|
|
|
|
|
if (msg->cursize + 128 > msg->maxsize)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// send an update
|
|
|
|
bits = 0;
|
|
|
|
|
2006-09-19 01:48:12 +00:00
|
|
|
for (i=0 ; i<3 ; i++)
|
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
miss = (newstate->origin[i]) - ent->baseline.origin[i];
|
|
|
|
if ( miss <= -1/8.0 || miss >= 1/8.0 )
|
2006-09-19 01:48:12 +00:00
|
|
|
bits |= UNQ_ORIGIN1<<i;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->angles[0] != ent->baseline.angles[0])
|
|
|
|
bits |= UNQ_ANGLE1;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->angles[1] != ent->baseline.angles[1])
|
|
|
|
bits |= UNQ_ANGLE2;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->angles[2] != ent->baseline.angles[2])
|
|
|
|
bits |= UNQ_ANGLE3;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
// if (ent->v.movetype == MOVETYPE_STEP)
|
|
|
|
// bits |= UNQ_NOLERP; // don't mess up the step animation
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->colormap != ent->baseline.colormap || ent->baseline.colormap > 15)
|
|
|
|
bits |= UNQ_COLORMAP;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->skinnum != ent->baseline.skinnum)
|
|
|
|
bits |= UNQ_SKIN;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->frame != ent->baseline.frame)
|
|
|
|
bits |= UNQ_FRAME;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->effects != ent->baseline.effects)
|
|
|
|
bits |= UNQ_EFFECTS;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newstate->modelindex != ent->baseline.modelindex)
|
|
|
|
bits |= UNQ_MODEL;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (newnum >= 256)
|
|
|
|
bits |= UNQ_LONGENTITY;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits >= 256)
|
|
|
|
bits |= UNQ_MOREBITS;
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
//
|
|
|
|
// write the message
|
|
|
|
//
|
|
|
|
WriteByte (msg,bits | UNQ_SIGNAL);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_MOREBITS)
|
|
|
|
WriteByte (msg, bits>>8);
|
|
|
|
if (bits & UNQ_LONGENTITY)
|
|
|
|
WriteShort (msg,newnum);
|
|
|
|
else
|
|
|
|
WriteByte (msg,newnum);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_MODEL)
|
|
|
|
WriteByte (msg, newstate->modelindex);
|
|
|
|
if (bits & UNQ_FRAME)
|
|
|
|
WriteByte (msg, newstate->frame);
|
|
|
|
if (bits & UNQ_COLORMAP)
|
|
|
|
WriteByte (msg, (newstate->colormap>15)?0:(newstate->colormap));
|
|
|
|
if (bits & UNQ_SKIN)
|
|
|
|
WriteByte (msg, newstate->skinnum);
|
|
|
|
if (bits & UNQ_EFFECTS)
|
|
|
|
WriteByte (msg, newstate->effects);
|
|
|
|
if (bits & UNQ_ORIGIN1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, newstate->origin[0], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_ANGLE1)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, newstate->angles[0], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_ORIGIN2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, newstate->origin[1], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_ANGLE2)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, newstate->angles[1], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_ORIGIN3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, newstate->origin[2], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (bits & UNQ_ANGLE3)
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(msg, newstate->angles[2], pext1);
|
2007-03-03 18:46:43 +00:00
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
WriteByte(msg, svc_nqsetview);
|
|
|
|
WriteShort(msg, v->thisplayer+1);
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteShort (msg,UNQ_MOREBITS|UNQ_MODEL|UNQ_ORIGIN1 | UNQ_ORIGIN2 | UNQ_ORIGIN3 | UNQ_SIGNAL);
|
2007-03-03 18:46:43 +00:00
|
|
|
WriteByte (msg, v->thisplayer+1);
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte (msg, 2); //model
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord (msg, v->origin[0], pext1);
|
|
|
|
WriteCoord (msg, v->origin[1], pext1);
|
|
|
|
WriteCoord (msg, v->origin[2], pext1);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-09 05:24:03 +00:00
|
|
|
//returns self, or the final commentator
|
|
|
|
viewer_t *GetCommentator(viewer_t *v)
|
|
|
|
{
|
|
|
|
viewer_t *orig = v;
|
|
|
|
int runaway = 10;
|
|
|
|
|
|
|
|
while(runaway-- > 0)
|
|
|
|
{
|
|
|
|
if (!v->commentator)
|
|
|
|
break;
|
|
|
|
if (v->commentator->thinksitsconnected == false)
|
|
|
|
break;
|
|
|
|
if (v->commentator->server != orig->server)
|
|
|
|
break;
|
|
|
|
v = v->commentator;
|
|
|
|
}
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
void SendPlayerStates(sv_t *tv, viewer_t *v, netmsg_t *msg)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
bsp_t *bsp = (!tv || tv->controller == v ? NULL : tv->map.bsp);
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *cv;
|
2005-09-06 01:09:36 +00:00
|
|
|
packet_entities_t *e;
|
2006-06-10 22:15:24 +00:00
|
|
|
int i;
|
2005-09-06 01:09:36 +00:00
|
|
|
usercmd_t to;
|
|
|
|
unsigned short flags;
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
float interp;
|
2005-09-06 01:09:36 +00:00
|
|
|
float lerp;
|
2006-11-03 15:53:04 +00:00
|
|
|
int track;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-12-26 21:26:10 +00:00
|
|
|
int snapdist = 128; //in quake units
|
|
|
|
|
|
|
|
snapdist = snapdist*8;
|
|
|
|
snapdist = snapdist*snapdist;
|
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
memset(&to, 0, sizeof(to));
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
if (tv)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
if (tv->physicstime != v->settime)// && tv->cluster->chokeonnotupdated)
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
|
|
|
WriteByte(msg, svc_updatestatlong);
|
|
|
|
WriteByte(msg, STAT_TIME);
|
|
|
|
WriteLong(msg, v->settime);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
v->settime = tv->physicstime;
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-10-10 18:01:27 +00:00
|
|
|
BSP_SetupForPosition(bsp, v->origin[0], v->origin[1], v->origin[2]);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-02-21 23:25:54 +00:00
|
|
|
lerp = ((tv->simtime - tv->oldpackettime)/1000.0f) / ((tv->nextpackettime - tv->oldpackettime)/1000.0f);
|
2005-10-07 02:02:15 +00:00
|
|
|
if (lerp < 0)
|
|
|
|
lerp = 0;
|
|
|
|
if (lerp > 1)
|
|
|
|
lerp = 1;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
if (tv->controller == v)
|
2007-09-08 20:15:59 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
lerp = 1;
|
2009-07-07 23:40:06 +00:00
|
|
|
track = tv->map.thisplayer;
|
|
|
|
v->trackplayer = tv->map.thisplayer;
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
cv = GetCommentator(v);
|
|
|
|
track = cv->trackplayer;
|
2007-01-09 05:24:03 +00:00
|
|
|
|
2007-09-08 20:15:59 +00:00
|
|
|
if (cv != v && track < 0)
|
|
|
|
{ //following a commentator
|
|
|
|
track = MAX_CLIENTS-2;
|
|
|
|
}
|
2007-01-09 05:24:03 +00:00
|
|
|
|
2007-09-08 20:15:59 +00:00
|
|
|
if (v->trackplayer != track)
|
|
|
|
QW_StuffcmdToViewer (v, "track %i\n", track);
|
|
|
|
|
|
|
|
if (!v->commentator && track >= 0 && !v->backbuffered)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (v->trackplayer != tv->map.trackplayer && tv->usequakeworldprotocols)
|
|
|
|
if (!tv->map.players[v->trackplayer].active && tv->map.players[tv->map.trackplayer].active)
|
2007-09-08 20:15:59 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
QW_StuffcmdToViewer (v, "track %i\n", tv->map.trackplayer);
|
2007-09-08 20:15:59 +00:00
|
|
|
}
|
|
|
|
}
|
2007-01-09 05:24:03 +00:00
|
|
|
}
|
2006-11-03 15:53:04 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
if (i == v->thisplayer)
|
|
|
|
{
|
|
|
|
SendLocalPlayerState(tv, v, i, msg);
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-03 15:53:04 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
if (!tv->map.players[i].active && track != i)
|
2005-10-07 02:02:15 +00:00
|
|
|
continue;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
//bsp cull. currently tracked player is always visible
|
2009-07-07 23:40:06 +00:00
|
|
|
if (track != i && !BSP_Visible(bsp, tv->map.players[i].leafcount, tv->map.players[i].leafs))
|
2005-10-07 02:02:15 +00:00
|
|
|
continue;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
flags = PF_COMMAND;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (track == i && tv->map.players[i].current.weaponframe)
|
2005-10-07 02:02:15 +00:00
|
|
|
flags |= PF_WEAPONFRAME;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.modelindex != tv->map.modelindex_player)
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_MODEL;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].dead || !tv->map.players[i].active)
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_DEAD;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].gibbed || !tv->map.players[i].active)
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_GIB;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.effects != 0)
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_EFFECTS;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.skinnum != 0)
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_SKINNUM;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.velocity[0])
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_VELOCITY1;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.velocity[1])
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_VELOCITY2;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv->map.players[i].current.velocity[2])
|
2007-03-03 18:46:43 +00:00
|
|
|
flags |= PF_VELOCITY3;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteByte(msg, svc_playerinfo);
|
|
|
|
WriteByte(msg, i);
|
|
|
|
WriteShort(msg, flags);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
if (!tv->map.players[i].active || !tv->map.players[i].oldactive ||
|
2009-07-07 23:40:06 +00:00
|
|
|
(tv->map.players[i].current.origin[0] - tv->map.players[i].old.origin[0])*(tv->map.players[i].current.origin[0] - tv->map.players[i].old.origin[0]) > snapdist ||
|
|
|
|
(tv->map.players[i].current.origin[1] - tv->map.players[i].old.origin[1])*(tv->map.players[i].current.origin[1] - tv->map.players[i].old.origin[1]) > snapdist ||
|
|
|
|
(tv->map.players[i].current.origin[2] - tv->map.players[i].old.origin[2])*(tv->map.players[i].current.origin[2] - tv->map.players[i].old.origin[2]) > snapdist)
|
2006-12-26 21:26:10 +00:00
|
|
|
{ //teleported (or respawned), so don't interpolate
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, tv->map.players[i].current.origin[0], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.players[i].current.origin[1], tv->pext1);
|
|
|
|
WriteCoord(msg, tv->map.players[i].current.origin[2], tv->pext1);
|
2006-12-26 21:26:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //send interpolated angles
|
2009-07-07 23:40:06 +00:00
|
|
|
interp = (lerp)*tv->map.players[i].current.origin[0] + (1-lerp)*tv->map.players[i].old.origin[0];
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, interp, tv->pext1);
|
2009-07-07 23:40:06 +00:00
|
|
|
interp = (lerp)*tv->map.players[i].current.origin[1] + (1-lerp)*tv->map.players[i].old.origin[1];
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, interp, tv->pext1);
|
2009-07-07 23:40:06 +00:00
|
|
|
interp = (lerp)*tv->map.players[i].current.origin[2] + (1-lerp)*tv->map.players[i].old.origin[2];
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteCoord(msg, interp, tv->pext1);
|
2006-12-26 21:26:10 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[i].current.frame);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (flags & PF_MSEC)
|
|
|
|
{
|
|
|
|
WriteByte(msg, 0);
|
|
|
|
}
|
|
|
|
if (flags & PF_COMMAND)
|
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
if (!tv->map.players[i].active || !tv->map.players[i].oldactive)
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
to.angles[0] = tv->map.players[i].current.angles[0];
|
|
|
|
to.angles[1] = tv->map.players[i].current.angles[1];
|
|
|
|
to.angles[2] = tv->map.players[i].current.angles[2];
|
2007-03-03 18:46:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
to.angles[0] = InterpolateAngle(tv->map.players[i].old.angles[0], tv->map.players[i].current.angles[0], lerp);
|
|
|
|
to.angles[1] = InterpolateAngle(tv->map.players[i].old.angles[1], tv->map.players[i].current.angles[1], lerp);
|
|
|
|
to.angles[2] = InterpolateAngle(tv->map.players[i].old.angles[2], tv->map.players[i].current.angles[2], lerp);
|
2007-03-03 18:46:43 +00:00
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
WriteDeltaUsercmd(msg, &nullcmd, &to);
|
|
|
|
}
|
|
|
|
//vel
|
2007-03-03 18:46:43 +00:00
|
|
|
if (flags & PF_VELOCITY1)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort(msg, tv->map.players[i].current.velocity[0]);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (flags & PF_VELOCITY2)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort(msg, tv->map.players[i].current.velocity[1]);
|
2007-03-03 18:46:43 +00:00
|
|
|
if (flags & PF_VELOCITY3)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteShort(msg, tv->map.players[i].current.velocity[2]);
|
2005-10-07 02:02:15 +00:00
|
|
|
//model
|
2006-09-17 01:27:32 +00:00
|
|
|
if (flags & PF_MODEL)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[i].current.modelindex);
|
2005-10-07 02:02:15 +00:00
|
|
|
//skin
|
2007-03-03 18:46:43 +00:00
|
|
|
if (flags & PF_SKINNUM)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte (msg, tv->map.players[i].current.skinnum);
|
2005-10-07 02:02:15 +00:00
|
|
|
//effects
|
2007-03-03 18:46:43 +00:00
|
|
|
if (flags & PF_EFFECTS)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte (msg, tv->map.players[i].current.effects);
|
2005-10-07 02:02:15 +00:00
|
|
|
//weaponframe
|
|
|
|
if (flags & PF_WEAPONFRAME)
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.players[i].current.weaponframe);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lerp = 1;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
SendLocalPlayerState(tv, v, v->thisplayer, msg);
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
e = &v->frame[v->netchan.outgoing_sequence&(ENTITY_FRAMES-1)];
|
|
|
|
e->numents = 0;
|
2006-04-11 22:15:09 +00:00
|
|
|
if (tv)
|
2006-12-26 21:26:10 +00:00
|
|
|
{
|
|
|
|
int oldindex = 0, newindex = 0;
|
|
|
|
entity_state_t *newstate;
|
|
|
|
int newnum, oldnum;
|
|
|
|
frame_t *frompacket, *topacket;
|
2009-07-07 23:40:06 +00:00
|
|
|
topacket = &tv->map.frame[tv->netchan.incoming_sequence&(ENTITY_FRAMES-1)];
|
2007-07-23 10:53:59 +00:00
|
|
|
if (tv->usequakeworldprotocols)
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
frompacket = &tv->map.frame[(topacket->oldframe)&(ENTITY_FRAMES-1)];
|
2006-12-26 21:26:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
frompacket = &tv->map.frame[(tv->netchan.incoming_sequence-1)&(ENTITY_FRAMES-1)];
|
2006-12-26 21:26:10 +00:00
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-12-26 21:26:10 +00:00
|
|
|
for (newindex = 0; newindex < topacket->numents; newindex++)
|
|
|
|
{
|
|
|
|
//don't pvs cull bsp models
|
|
|
|
//pvs cull everything else
|
|
|
|
newstate = &topacket->ents[newindex];
|
|
|
|
newnum = topacket->entnums[newindex];
|
2009-07-07 23:40:06 +00:00
|
|
|
if (newstate->modelindex >= tv->map.numinlines && !BSP_Visible(bsp, tv->map.entity[newnum].leafcount, tv->map.entity[newnum].leafs))
|
2005-10-07 02:02:15 +00:00
|
|
|
continue;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-12-26 21:26:10 +00:00
|
|
|
e->entnum[e->numents] = newnum;
|
|
|
|
memcpy(&e->ents[e->numents], newstate, sizeof(entity_state_t));
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-12-26 21:26:10 +00:00
|
|
|
if (frompacket != topacket) //optimisation for qw protocols
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2006-12-26 21:26:10 +00:00
|
|
|
entity_state_t *oldstate;
|
|
|
|
|
|
|
|
if (oldindex < frompacket->numents)
|
|
|
|
{
|
|
|
|
oldnum = frompacket->entnums[oldindex];
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-12-26 21:26:10 +00:00
|
|
|
while(oldnum < newnum)
|
|
|
|
{
|
|
|
|
oldindex++;
|
|
|
|
if (oldindex >= frompacket->numents)
|
|
|
|
break; //no more
|
|
|
|
oldnum = frompacket->entnums[oldindex];
|
|
|
|
}
|
|
|
|
if (oldnum == newnum)
|
|
|
|
{
|
|
|
|
//ent exists in old packet
|
|
|
|
oldstate = &frompacket->ents[oldindex];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = newstate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //reached end, definatly not in packet
|
|
|
|
oldstate = newstate;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((newstate->origin[0] - oldstate->origin[0])*(newstate->origin[0] - oldstate->origin[0]) > snapdist ||
|
|
|
|
(newstate->origin[1] - oldstate->origin[1])*(newstate->origin[1] - oldstate->origin[1]) > snapdist ||
|
|
|
|
(newstate->origin[2] - oldstate->origin[2])*(newstate->origin[2] - oldstate->origin[2]) > snapdist)
|
|
|
|
{ //teleported (or respawned), so don't interpolate
|
|
|
|
e->ents[e->numents].origin[0] = newstate->origin[0];
|
|
|
|
e->ents[e->numents].origin[1] = newstate->origin[1];
|
|
|
|
e->ents[e->numents].origin[2] = newstate->origin[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
e->ents[e->numents].origin[0] = (lerp)*newstate->origin[0] + (1-lerp)*oldstate->origin[0];
|
|
|
|
e->ents[e->numents].origin[1] = (lerp)*newstate->origin[1] + (1-lerp)*oldstate->origin[1];
|
|
|
|
e->ents[e->numents].origin[2] = (lerp)*newstate->origin[2] + (1-lerp)*oldstate->origin[2];
|
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
e->numents++;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (e->numents == ENTS_PER_FRAME)
|
|
|
|
break;
|
|
|
|
}
|
2006-12-26 21:26:10 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
SV_EmitPacketEntities(tv, v, e, msg);
|
2006-04-11 22:15:09 +00:00
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
if (tv && tv->map.nailcount)
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
|
|
|
WriteByte(msg, svc_nails);
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.nailcount);
|
|
|
|
for (i = 0; i < tv->map.nailcount; i++)
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
WriteByte(msg, tv->map.nails[i].bits[0]);
|
|
|
|
WriteByte(msg, tv->map.nails[i].bits[1]);
|
|
|
|
WriteByte(msg, tv->map.nails[i].bits[2]);
|
|
|
|
WriteByte(msg, tv->map.nails[i].bits[3]);
|
|
|
|
WriteByte(msg, tv->map.nails[i].bits[4]);
|
|
|
|
WriteByte(msg, tv->map.nails[i].bits[5]);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateStats(sv_t *qtv, viewer_t *v)
|
|
|
|
{
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *cv;
|
2005-09-06 01:09:36 +00:00
|
|
|
netmsg_t msg;
|
|
|
|
char buf[6];
|
|
|
|
int i;
|
2019-02-16 19:09:07 +00:00
|
|
|
static const unsigned int nullstats[MAX_STATS] = {1000};
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
const unsigned int *stats;
|
|
|
|
|
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
|
2007-01-08 03:15:37 +00:00
|
|
|
if (v->commentator && v->thinksitsconnected)
|
2006-11-03 15:53:04 +00:00
|
|
|
cv = v->commentator;
|
|
|
|
else
|
|
|
|
cv = v;
|
|
|
|
|
|
|
|
if (qtv && qtv->controller == cv)
|
2009-07-07 23:40:06 +00:00
|
|
|
stats = qtv->map.players[qtv->map.thisplayer].stats;
|
2006-11-03 15:53:04 +00:00
|
|
|
else if (cv->trackplayer == -1 || !qtv)
|
2005-09-06 01:09:36 +00:00
|
|
|
stats = nullstats;
|
|
|
|
else
|
2009-07-07 23:40:06 +00:00
|
|
|
stats = qtv->map.players[cv->trackplayer].stats;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_STATS; i++)
|
|
|
|
{
|
|
|
|
if (v->currentstats[i] != stats[i])
|
|
|
|
{
|
2006-09-17 01:27:32 +00:00
|
|
|
if (v->netchan.isnqprotocol)
|
|
|
|
{ //nq only supports 32bit stats
|
|
|
|
WriteByte(&msg, svc_updatestat);
|
|
|
|
WriteByte(&msg, i);
|
|
|
|
WriteLong(&msg, stats[i]);
|
|
|
|
}
|
|
|
|
else if (stats[i] < 256)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
WriteByte(&msg, svc_updatestat);
|
|
|
|
WriteByte(&msg, i);
|
|
|
|
WriteByte(&msg, stats[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteByte(&msg, svc_updatestatlong);
|
|
|
|
WriteByte(&msg, i);
|
|
|
|
WriteLong(&msg, stats[i]);
|
|
|
|
}
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
msg.cursize = 0;
|
|
|
|
v->currentstats[i] = stats[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//returns the next prespawn 'buffer' number to use, or -1 if no more
|
2006-04-11 22:15:09 +00:00
|
|
|
int Prespawn(sv_t *qtv, int curmsgsize, netmsg_t *msg, int bufnum, int thisplayer)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
int r, ni;
|
|
|
|
r = bufnum;
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
ni = SendCurrentUserinfos(qtv, curmsgsize, msg, bufnum, thisplayer);
|
2005-09-06 01:09:36 +00:00
|
|
|
r += ni - bufnum;
|
2005-09-24 04:48:20 +00:00
|
|
|
bufnum = ni;
|
2005-09-06 01:09:36 +00:00
|
|
|
bufnum -= MAX_CLIENTS;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
ni = SendCurrentBaselines(qtv, curmsgsize, msg, 768, bufnum);
|
2005-09-06 01:09:36 +00:00
|
|
|
r += ni - bufnum;
|
|
|
|
bufnum = ni;
|
|
|
|
bufnum -= MAX_ENTITIES;
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
ni = SendCurrentLightmaps(qtv, curmsgsize, msg, 768, bufnum);
|
2005-09-06 01:09:36 +00:00
|
|
|
r += ni - bufnum;
|
|
|
|
bufnum = ni;
|
|
|
|
bufnum -= MAX_LIGHTSTYLES;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
ni = SendStaticSounds(qtv, curmsgsize, msg, 768, bufnum);
|
2005-09-24 04:48:20 +00:00
|
|
|
r += ni - bufnum;
|
|
|
|
bufnum = ni;
|
|
|
|
bufnum -= MAX_STATICSOUNDS;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
ni = SendStaticEntities(qtv, curmsgsize, msg, 768, bufnum);
|
2005-09-24 04:48:20 +00:00
|
|
|
r += ni - bufnum;
|
|
|
|
bufnum = ni;
|
|
|
|
bufnum -= MAX_STATICENTITIES;
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
if (bufnum == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PMove(viewer_t *v, usercmd_t *cmd)
|
|
|
|
{
|
2006-10-20 14:25:20 +00:00
|
|
|
sv_t *qtv;
|
|
|
|
pmove_t pmove;
|
2006-04-11 22:15:09 +00:00
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
v->origin[0] = v->server->map.players[v->server->map.thisplayer].current.origin[0];
|
|
|
|
v->origin[1] = v->server->map.players[v->server->map.thisplayer].current.origin[1];
|
|
|
|
v->origin[2] = v->server->map.players[v->server->map.thisplayer].current.origin[2];
|
2006-10-20 14:25:20 +00:00
|
|
|
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
v->velocity[0] = v->server->map.players[v->server->map.thisplayer].current.velocity[0];
|
|
|
|
v->velocity[1] = v->server->map.players[v->server->map.thisplayer].current.velocity[1];
|
|
|
|
v->velocity[2] = v->server->map.players[v->server->map.thisplayer].current.velocity[2];
|
2006-04-11 22:15:09 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-10-20 14:25:20 +00:00
|
|
|
pmove.origin[0] = v->origin[0];
|
|
|
|
pmove.origin[1] = v->origin[1];
|
|
|
|
pmove.origin[2] = v->origin[2];
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2006-10-20 14:25:20 +00:00
|
|
|
pmove.velocity[0] = v->velocity[0];
|
|
|
|
pmove.velocity[1] = v->velocity[1];
|
|
|
|
pmove.velocity[2] = v->velocity[2];
|
|
|
|
|
|
|
|
pmove.cmd = *cmd;
|
|
|
|
qtv = v->server;
|
|
|
|
if (qtv)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
pmove.movevars = qtv->map.movevars;
|
2006-10-20 14:25:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QTV_DefaultMovevars(&pmove.movevars);
|
|
|
|
}
|
|
|
|
PM_PlayerMove(&pmove);
|
|
|
|
|
|
|
|
v->origin[0] = pmove.origin[0];
|
|
|
|
v->origin[1] = pmove.origin[1];
|
|
|
|
v->origin[2] = pmove.origin[2];
|
|
|
|
|
|
|
|
v->velocity[0] = pmove.velocity[0];
|
|
|
|
v->velocity[1] = pmove.velocity[1];
|
|
|
|
v->velocity[2] = pmove.velocity[2];
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
void QW_SetCommentator(cluster_t *cluster, viewer_t *v, viewer_t *commentator)
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
|
|
|
// if (v->commentator == commentator)
|
|
|
|
// return;
|
|
|
|
|
|
|
|
WriteByte(&v->netchan.message, svc_setinfo);
|
|
|
|
WriteByte(&v->netchan.message, MAX_CLIENTS-2);
|
|
|
|
WriteString(&v->netchan.message, "name");
|
|
|
|
if (commentator)
|
|
|
|
{
|
|
|
|
WriteString(&v->netchan.message, commentator->name);
|
2007-01-08 03:15:37 +00:00
|
|
|
QW_StuffcmdToViewer(v, "track %i\n", MAX_CLIENTS-2);
|
2006-11-03 15:53:04 +00:00
|
|
|
QW_PrintfToViewer(v, "Following commentator %s\n", commentator->name);
|
|
|
|
|
|
|
|
if (v->server != commentator->server)
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, commentator->server);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteString(&v->netchan.message, "");
|
|
|
|
if (v->commentator )
|
|
|
|
QW_PrintfToViewer(v, "Commentator disabled\n");
|
|
|
|
}
|
|
|
|
v->commentator = commentator;
|
|
|
|
}
|
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
void QTV_SayCommand(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *fullcommand)
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
char command[256];
|
|
|
|
char *args;
|
|
|
|
args = COM_ParseToken(fullcommand, command, sizeof(command), NULL);
|
|
|
|
if (!args)
|
|
|
|
args = "";
|
|
|
|
while(*args && *args <= ' ')
|
|
|
|
args++;
|
|
|
|
|
2019-02-16 19:09:07 +00:00
|
|
|
#pragma message("fixme: These all need testing")
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!strcmp(command, "help"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2015-04-21 04:12:00 +00:00
|
|
|
QW_PrintfToViewer(v, "Website: "PROXYWEBSITE"\n"
|
2007-10-10 21:09:05 +00:00
|
|
|
"Commands:\n"
|
|
|
|
".bind\n"
|
2012-04-20 14:41:40 +00:00
|
|
|
" Bind your keys to drive the menu.\n"
|
2007-10-10 21:09:05 +00:00
|
|
|
".clients\n"
|
|
|
|
" Lists the users connected to this\n"
|
|
|
|
" proxy.\n"
|
|
|
|
".qtvinfo\n"
|
|
|
|
" Print info about the current QTV\n"
|
|
|
|
" you're on.\n"
|
|
|
|
".demo gamedir/demoname.mvd \n"
|
|
|
|
" Start a new stream on the specified\n"
|
|
|
|
" demo.\n"
|
|
|
|
".disconnect\n"
|
|
|
|
" Disconnect from any server or\n"
|
|
|
|
" stream you're on.\n"
|
|
|
|
".join qwserver:port\n"
|
|
|
|
" Play on the specified server.\n"
|
|
|
|
".observe qwserver:port\n"
|
|
|
|
" Spectate on the specified server.\n"
|
|
|
|
".qtv tcpserver:port\n"
|
|
|
|
" Start a new stream on the specified\n"
|
|
|
|
" server.\n"
|
|
|
|
".guimenu\n"
|
|
|
|
" Bring up the GUI-based menu\n"
|
|
|
|
" interface.\n"
|
|
|
|
".tuimenu\n"
|
|
|
|
" Bring up the text-based menu\n"
|
|
|
|
" interface.\n"
|
|
|
|
".menu\n"
|
|
|
|
" Automatically chooses an interface\n"
|
|
|
|
" that your client supports.\n"
|
|
|
|
".admin\n"
|
|
|
|
" Log in to administrate this QTV\n"
|
|
|
|
" proxy.\n"
|
|
|
|
);
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(command, "qtvinfo"))
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
netadr_t addr;
|
|
|
|
unsigned char *ip;
|
|
|
|
gethostname(buf, sizeof(buf)); //ask the operating system for the local dns name
|
|
|
|
NET_StringToAddr(buf, &addr, 0); //look that up
|
2007-07-23 10:53:59 +00:00
|
|
|
ip = (unsigned char*)&((struct sockaddr_in *)&addr)->sin_addr;
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "[QuakeTV] %s | %i.%i.%i.%i\n", cluster->hostname, ip[0], ip[1], ip[2], ip[3]);
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "menu"))
|
|
|
|
{
|
|
|
|
v->menuspamtime = cluster->curtime-1;
|
|
|
|
|
|
|
|
COM_ParseToken(args, command, sizeof(command), NULL);
|
|
|
|
if (!strcmp(command, "up"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
v->menuop -= 1;
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "down"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
v->menuop += 1;
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "enter"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
Menu_Enter(cluster, v, 0);
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "use"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
Menu_Enter(cluster, v, 0);
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "right"))
|
2007-01-06 09:46:32 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
Menu_Enter(cluster, v, 1);
|
2007-01-06 09:46:32 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "left"))
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
Menu_Enter(cluster, v, -1);
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "select"))
|
|
|
|
{
|
|
|
|
Menu_Enter(cluster, v, 0);
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "home"))
|
|
|
|
{
|
|
|
|
v->menuop -= 100000;
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "end"))
|
|
|
|
{
|
|
|
|
v->menuop += 100000;
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "back"))
|
|
|
|
{
|
|
|
|
QW_SetMenu(v, MENU_DEFAULT);
|
|
|
|
}
|
|
|
|
else if (!strcmp(command, "enter"))
|
|
|
|
{
|
|
|
|
if (v->menunum)
|
|
|
|
Menu_Enter(cluster, v, 0);
|
2006-02-20 01:33:13 +00:00
|
|
|
else
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetMenu(v, MENU_SERVERS);
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "bind") || !strcmp(command, "bindstd"))
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_StuffcmdToViewer(v, "bind uparrow \"say proxy:menu up\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind downarrow \"say proxy:menu down\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind rightarrow \"say proxy:menu right\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind leftarrow \"say proxy:menu left\"\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_StuffcmdToViewer(v, "bind enter \"say proxy:menu select\"\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_StuffcmdToViewer(v, "bind home \"say proxy:menu home\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind end \"say proxy:menu end\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind pause \"say proxy:menu\"\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind backspace \"say proxy:menu back\"\n");
|
2007-01-09 05:24:03 +00:00
|
|
|
|
2011-01-04 02:56:16 +00:00
|
|
|
QW_PrintfToViewer(v, "All keys bound\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!*command)
|
2006-02-20 01:33:13 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
if (v->menunum)
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
else if (v->conmenussupported)
|
|
|
|
goto guimenu;
|
|
|
|
else
|
|
|
|
goto tuimenu;
|
2006-02-20 01:33:13 +00:00
|
|
|
}
|
2007-01-06 09:46:32 +00:00
|
|
|
else
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "\"menu %s\" not recognised\n", command);
|
2007-01-06 09:46:32 +00:00
|
|
|
}
|
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "tuimenu"))
|
2007-01-06 09:46:32 +00:00
|
|
|
{
|
|
|
|
tuimenu:
|
|
|
|
if (v->menunum)
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
else
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetMenu(v, MENU_MAIN);
|
2007-01-06 09:46:32 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "guimenu"))
|
2006-10-07 22:29:31 +00:00
|
|
|
{
|
|
|
|
sv_t *sv;
|
|
|
|
int y;
|
2007-01-06 09:46:32 +00:00
|
|
|
qboolean shownheader;
|
|
|
|
|
|
|
|
guimenu:
|
|
|
|
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
|
|
|
|
shownheader = false;
|
|
|
|
|
2011-07-15 12:51:05 +00:00
|
|
|
/*
|
|
|
|
I've removed the following from this function as it covered the menu (~Moodles):
|
|
|
|
"menupic 0 4 gfx/qplaque.lmp\n"
|
|
|
|
"menupic 96 4 gfx/p_option.lmp\n"
|
|
|
|
*/
|
2011-07-14 09:18:04 +00:00
|
|
|
QW_StuffcmdToViewer(v,
|
2006-10-07 22:29:31 +00:00
|
|
|
|
|
|
|
"alias menucallback\n"
|
|
|
|
"{\n"
|
|
|
|
"menuclear\n"
|
|
|
|
"if (option == \"OBSERVE\")\n"
|
|
|
|
"{\necho Spectating server $_server\nsay .observe $_server\n}\n"
|
|
|
|
"if (option == \"QTV\")\n"
|
|
|
|
"{\necho Streaming from qtv at $_server\nsay .qtv $_server\n}\n"
|
|
|
|
"if (option == \"JOIN\")\n"
|
|
|
|
"{\necho Joining game at $_server\nsay .join $_server\n}\n"
|
|
|
|
"if (option == \"ADMIN\")\n"
|
|
|
|
"{\nsay .guiadmin\n}\n"
|
2007-03-03 18:46:43 +00:00
|
|
|
"if (option == \"DEMOS\")\n"
|
|
|
|
"{\nsay .demos\n}\n"
|
2006-10-07 22:29:31 +00:00
|
|
|
"if (\"stream \" isin option)\n"
|
|
|
|
"{\necho Changing stream\nsay .$option\n}\n"
|
|
|
|
"}\n"
|
|
|
|
|
|
|
|
"conmenu menucallback\n"
|
|
|
|
|
2019-03-01 22:39:30 +00:00
|
|
|
"menuedit 48 36 \"^aServer:\" \"_server\"\n"
|
2006-10-07 22:29:31 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
"menutext 48 52 \"Demos\" DEMOS\n"
|
|
|
|
|
2006-10-07 22:29:31 +00:00
|
|
|
"menutext 104 52 \"Join\" JOIN\n"
|
|
|
|
|
|
|
|
"menutext 152 52 \"Observe\" OBSERVE\n"
|
|
|
|
|
|
|
|
"menutext 224 52 \"QTV\" QTV\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"menutext 48 84 \"Admin\" ADMIN\n"
|
|
|
|
|
|
|
|
"menutext 48 92 \"Close Menu\" cancel\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"menutext 48 116 \"Type in a server address and\"\n"
|
|
|
|
"menutext 48 124 \"click join to play in the game,\"\n"
|
|
|
|
"menutext 48 132 \"observe(udp) to watch, or qtv(tcp)\"\n"
|
|
|
|
"menutext 48 140 \"to connect to a stream or proxy.\"\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
y = 140+16;
|
|
|
|
for (sv = cluster->servers; sv; sv = sv->next)
|
|
|
|
{
|
|
|
|
if (!shownheader)
|
|
|
|
{
|
|
|
|
shownheader = true;
|
2019-03-01 22:39:30 +00:00
|
|
|
|
|
|
|
QW_StuffcmdToViewer(v, "menutext 72 %i \"^aActive Games:\"\n", y);
|
2006-10-07 22:29:31 +00:00
|
|
|
y+=8;
|
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
QW_StuffcmdToViewer(v, "menutext 32 %i \"%30s\" \"stream %i\"\n", y, *sv->map.hostname?sv->map.hostname:sv->server, sv->streamid);
|
2006-10-07 22:29:31 +00:00
|
|
|
y+=8;
|
|
|
|
}
|
|
|
|
if (!shownheader)
|
|
|
|
QW_StuffcmdToViewer(v, "menutext 72 %i \"There are no active games\"\n", y);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2006-10-07 22:29:31 +00:00
|
|
|
}
|
2007-03-03 18:46:43 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "demos"))
|
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
if (v->conmenussupported)
|
|
|
|
goto guidemos;
|
|
|
|
else
|
|
|
|
goto tuidemos;
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "guidemos"))
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
|
|
|
int maxshowndemos;
|
|
|
|
char sizestr[7];
|
|
|
|
int start;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
guidemos:
|
|
|
|
maxshowndemos = 12;
|
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!*args)
|
2007-03-03 18:46:43 +00:00
|
|
|
Cluster_BuildAvailableDemoList(cluster);
|
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
start = atoi(args); //FIXME
|
2007-03-03 18:46:43 +00:00
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
|
2011-07-15 12:51:05 +00:00
|
|
|
/*
|
|
|
|
I've removed the following from this function as it covered the menu (~Moodles):
|
|
|
|
"menupic 0 4 gfx/qplaque.lmp\n"
|
|
|
|
"menupic 96 4 gfx/p_option.lmp\n"
|
|
|
|
*/
|
2011-07-14 09:18:04 +00:00
|
|
|
QW_StuffcmdToViewer(v,
|
2007-03-03 18:46:43 +00:00
|
|
|
|
|
|
|
"alias menucallback\n"
|
|
|
|
"{\n"
|
|
|
|
"menuclear\n"
|
|
|
|
"if (option == \"PREV\")\n"
|
|
|
|
"{\nsay .demos %i\n}\n"
|
|
|
|
"if (option == \"NEXT\")\n"
|
|
|
|
"{\nsay .demos %i\n}\n"
|
|
|
|
"if (\"demo \" isin option)\n"
|
|
|
|
"{\necho Changing stream\nsay .$option\n}\n"
|
|
|
|
"}\n"
|
|
|
|
|
2011-07-15 12:51:05 +00:00
|
|
|
"conmenu menucallback\n",
|
2007-03-03 18:46:43 +00:00
|
|
|
start - maxshowndemos, start + maxshowndemos
|
|
|
|
);
|
|
|
|
|
|
|
|
if (start < 0)
|
|
|
|
start = 0;
|
|
|
|
|
|
|
|
if (start-maxshowndemos >= 0)
|
|
|
|
QW_StuffcmdToViewer(v, "menutext 48 52 \"Prev\" \"PREV\"\n");
|
|
|
|
if (start+maxshowndemos <= cluster->availdemoscount)
|
|
|
|
QW_StuffcmdToViewer(v, "menutext 152 52 \"Next\" \"NEXT\"\n");
|
|
|
|
|
|
|
|
for (i = start; i < start+maxshowndemos; i++)
|
|
|
|
{
|
|
|
|
if (i >= cluster->availdemoscount)
|
|
|
|
break;
|
|
|
|
if (cluster->availdemos[i].size < 1024)
|
|
|
|
sprintf(sizestr, "%4ib", cluster->availdemos[i].size);
|
|
|
|
else if (cluster->availdemos[i].size < 1024*1024)
|
|
|
|
sprintf(sizestr, "%4ikb", cluster->availdemos[i].size/1024);
|
|
|
|
else if (cluster->availdemos[i].size < 1024*1024*1024)
|
|
|
|
sprintf(sizestr, "%4imb", cluster->availdemos[i].size/(1024*1024));
|
|
|
|
else// if (cluster->availdemos[i].size < 1024*1024*1024*1024)
|
|
|
|
sprintf(sizestr, "%4igb", cluster->availdemos[i].size/(1024*1024*1024));
|
|
|
|
// else
|
|
|
|
// *sizestr = 0;
|
|
|
|
QW_StuffcmdToViewer(v, "menutext 32 %i \"%6s %-30s\" \"demo %s\"\n", (i-start)*8 + 52+16, sizestr, cluster->availdemos[i].name, cluster->availdemos[i].name);
|
|
|
|
}
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strncmp(command, ".tuidemos", 9))
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
|
|
|
tuidemos:
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!*args)
|
2007-03-03 18:46:43 +00:00
|
|
|
Cluster_BuildAvailableDemoList(cluster);
|
|
|
|
|
|
|
|
if (v->menunum == MENU_DEMOS)
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
else
|
|
|
|
QW_SetMenu(v, MENU_DEMOS);
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
else if (!strcmp(command, "admin"))
|
|
|
|
{
|
|
|
|
if (v->conmenussupported)
|
|
|
|
goto guiadmin;
|
|
|
|
else
|
|
|
|
goto tuiadmin;
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (!strcmp(command, "guiadmin"))
|
2006-10-07 22:29:31 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
guiadmin:
|
2006-10-07 22:29:31 +00:00
|
|
|
if (!*cluster->adminpassword)
|
|
|
|
{
|
2011-07-15 12:51:05 +00:00
|
|
|
/*
|
|
|
|
I've removed the following from this function as it covered the menu (~Moodles):
|
|
|
|
"menupic 16 4 gfx/qplaque.lmp\n"
|
|
|
|
"menupic - 4 gfx/p_option.lmp\n"
|
|
|
|
*/
|
2011-07-14 09:18:04 +00:00
|
|
|
QW_StuffcmdToViewer(v,
|
2006-10-07 22:29:31 +00:00
|
|
|
|
|
|
|
"alias menucallback\n"
|
|
|
|
"{\n"
|
|
|
|
"menuclear\n"
|
|
|
|
"}\n"
|
|
|
|
|
|
|
|
"conmenu menucallback\n"
|
|
|
|
|
|
|
|
"menutext 72 48 \"No admin password is set\"\n"
|
|
|
|
"menutext 72 56 \"Admin access is prohibited\"\n"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else if (v->isadmin)
|
|
|
|
//already an admin, so don't show admin login screen
|
|
|
|
QW_SetMenu(v, MENU_ADMIN);
|
|
|
|
else
|
|
|
|
{
|
2011-07-15 12:51:05 +00:00
|
|
|
/*
|
|
|
|
I've removed the following from this function as it covered the menu (~Moodles):
|
|
|
|
"menupic 16 4 gfx/qplaque.lmp\n"
|
|
|
|
"menupic - 4 gfx/p_option.lmp\n"
|
|
|
|
*/
|
2011-07-14 09:18:04 +00:00
|
|
|
QW_StuffcmdToViewer(v,
|
2006-10-07 22:29:31 +00:00
|
|
|
|
|
|
|
"alias menucallback\n"
|
|
|
|
"{\n"
|
|
|
|
"menuclear\n"
|
|
|
|
"if (option == \"log\")\n"
|
|
|
|
"{\nsay $_password\n}\n"
|
|
|
|
"set _password \"\"\n"
|
|
|
|
"}\n"
|
|
|
|
|
|
|
|
"conmenu menucallback\n"
|
|
|
|
|
|
|
|
"menuedit 16 32 \" Password\" \"_password\"\n"
|
|
|
|
|
|
|
|
"menutext 72 48 \"Log in QW\" log\n"
|
|
|
|
"menutext 192 48 \"Cancel\" cancel\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
strcpy(v->expectcommand, "admin");
|
|
|
|
}
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
else if (!strcmp(command, "tuiadmin"))
|
2006-09-19 01:48:12 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
tuiadmin:
|
2006-09-19 01:48:12 +00:00
|
|
|
if (!*cluster->adminpassword)
|
|
|
|
{
|
2013-03-31 04:21:08 +00:00
|
|
|
/*if (Netchan_IsLocal(v->netchan.remote_address))
|
2006-09-19 01:48:12 +00:00
|
|
|
{
|
|
|
|
Sys_Printf(cluster, "Local player %s logs in as admin\n", v->name);
|
|
|
|
QW_SetMenu(v, MENU_ADMIN);
|
|
|
|
v->isadmin = true;
|
|
|
|
}
|
2013-03-31 04:21:08 +00:00
|
|
|
else*/
|
2006-09-19 01:48:12 +00:00
|
|
|
QW_PrintfToViewer(v, "There is no admin password set\nYou may not log in.\n");
|
|
|
|
}
|
|
|
|
else if (v->isadmin)
|
|
|
|
QW_SetMenu(v, MENU_ADMIN);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
strcpy(v->expectcommand, "admin");
|
|
|
|
QW_StuffcmdToViewer(v, "echo Please enter the rcon password\nmessagemode\n");
|
|
|
|
}
|
2006-02-21 23:25:54 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
else if (!strcmp(command, "reset"))
|
2006-02-21 23:25:54 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetCommentator(cluster, v, NULL);
|
|
|
|
QW_SetViewersServer(cluster, v, NULL);
|
|
|
|
QW_SetMenu(v, MENU_SERVERS);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "connect") || !strcmp(command, "qw") || !strcmp(command, "observe") || !strcmp(command, "join"))
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
char buf[256];
|
|
|
|
int isjoin = false;
|
|
|
|
|
|
|
|
if (!strcmp(command, "join") || !strcmp(command, "connect"))
|
|
|
|
isjoin = true;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
snprintf(buf, sizeof(buf), "udp:%s", args);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_WHENEMPTY, !isjoin, false);
|
2006-02-21 19:55:12 +00:00
|
|
|
if (qtv)
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
QW_SetMenu(v, MENU_NONE);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-03-18 05:07:10 +00:00
|
|
|
if (isjoin)
|
|
|
|
qtv->controller = v;
|
|
|
|
QW_PrintfToViewer(v, "Connected to %s\n", qtv->server);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-07-23 10:53:59 +00:00
|
|
|
else if (cluster->nouserconnects)
|
|
|
|
QW_PrintfToViewer(v, "you may not do that here\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
else
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Failed to connect to server \"%s\", connection aborted\n", buf);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "qtv"))
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "tcp:%s", args);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_WHENEMPTY, true, false);
|
2006-02-21 19:55:12 +00:00
|
|
|
if (qtv)
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
QW_SetMenu(v, MENU_NONE);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Connected to %s\n", qtv->server);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-07-23 10:53:59 +00:00
|
|
|
else if (cluster->nouserconnects)
|
|
|
|
QW_PrintfToViewer(v, "Ask an admin to connect first\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
else
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Failed to connect to server \"%s\", connection aborted\n", buf);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-08-03 19:57:56 +00:00
|
|
|
else if (!strcmp(command, "qtvinfo"))
|
|
|
|
{
|
|
|
|
char buf[256];
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2019-02-16 19:09:07 +00:00
|
|
|
snprintf(buf, sizeof(buf), "[QuakeTV] %s\n", qtv->server);
|
2007-08-03 19:57:56 +00:00
|
|
|
// Print a short line with info about the server
|
2020-06-27 19:32:16 +00:00
|
|
|
QW_PrintfToViewer(v, "%s", buf);
|
2007-08-03 19:57:56 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "stream"))
|
2006-10-07 22:29:31 +00:00
|
|
|
{
|
|
|
|
int id;
|
2007-03-18 05:07:10 +00:00
|
|
|
id = atoi(args);
|
2006-10-07 22:29:31 +00:00
|
|
|
for (qtv = cluster->servers; qtv; qtv = qtv->next)
|
|
|
|
{
|
|
|
|
if (qtv->streamid == id)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (qtv)
|
|
|
|
{
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Watching to %s\n", qtv->server);
|
2006-10-07 22:29:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-16 14:53:45 +00:00
|
|
|
QW_PrintfToViewer(v, "Stream \"%s\" not recognised. Stream id is invalid or terminated.\n", args);
|
2006-10-07 22:29:31 +00:00
|
|
|
}
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "demo"))
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
char buf[256];
|
|
|
|
snprintf(buf, sizeof(buf), "file:%s", args);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_WHENEMPTY, true, false);
|
2006-02-21 19:55:12 +00:00
|
|
|
if (qtv)
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
QW_SetMenu(v, MENU_NONE);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Streaming from %s\n", qtv->server);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
|
|
|
else
|
2007-11-16 14:53:45 +00:00
|
|
|
QW_PrintfToViewer(v, "Demo \"%s\" does not exist on proxy\n", buf);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "disconnect"))
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
QW_SetMenu(v, MENU_SERVERS);
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetViewersServer(cluster, v, NULL);
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Connected\n");
|
2006-02-21 23:25:54 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "clients"))
|
2006-10-20 14:25:20 +00:00
|
|
|
{
|
|
|
|
viewer_t *ov;
|
|
|
|
int skipfirst = 0;
|
|
|
|
int printable = 30;
|
|
|
|
int remaining = 0;
|
|
|
|
for (ov = cluster->viewers; ov; ov = ov->next)
|
|
|
|
{
|
|
|
|
if (skipfirst > 0)
|
|
|
|
{
|
|
|
|
skipfirst--;
|
|
|
|
}
|
|
|
|
else if (printable > 0)
|
|
|
|
{
|
|
|
|
printable--;
|
|
|
|
if (ov->server)
|
|
|
|
{
|
|
|
|
if (ov->server->controller == ov)
|
2007-01-09 05:24:03 +00:00
|
|
|
QW_PrintfToViewer(v, "%i: %s: *%s\n", ov->userid, ov->name, ov->server->server);
|
2006-10-20 14:25:20 +00:00
|
|
|
else
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_PrintfToViewer(v, "%i: %s: %s\n", ov->userid, ov->name, ov->server->server);
|
2006-10-20 14:25:20 +00:00
|
|
|
}
|
|
|
|
else
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_PrintfToViewer(v, "%i: %s: %s\n", ov->userid, ov->name, "None");
|
2006-10-20 14:25:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
remaining++;
|
|
|
|
}
|
|
|
|
if (remaining)
|
|
|
|
QW_PrintfToViewer(v, "%i clients not shown\n", remaining);
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "followid"))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
int id = atoi(args);
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *cv;
|
|
|
|
|
|
|
|
for (cv = cluster->viewers; cv; cv = cv->next)
|
|
|
|
{
|
|
|
|
if (cv->userid == id)
|
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, v, cv);
|
2006-11-03 15:53:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QW_PrintfToViewer(v, "Couldn't find that player\n");
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, v, NULL);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "follow"))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
int id = atoi(args);
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *cv;
|
|
|
|
|
|
|
|
for (cv = cluster->viewers; cv; cv = cv->next)
|
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!strcmp(cv->name, args))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, v, cv);
|
2006-11-03 15:53:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
if (id)
|
|
|
|
{
|
|
|
|
for (cv = cluster->viewers; cv; cv = cv->next)
|
|
|
|
{
|
|
|
|
if (cv->userid == id)
|
|
|
|
{
|
|
|
|
QW_SetCommentator(cluster, v, cv);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-03 15:53:04 +00:00
|
|
|
QW_PrintfToViewer(v, "Couldn't find that player\n");
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, v, NULL);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "follow"))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, v, NULL);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "bind"))
|
2006-09-19 01:48:12 +00:00
|
|
|
{
|
|
|
|
QW_StuffcmdToViewer(v, "bind uparrow +proxfwd\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind downarrow +proxback\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind rightarrow +proxright\n");
|
|
|
|
QW_StuffcmdToViewer(v, "bind leftarrow +proxleft\n");
|
2018-04-06 17:39:32 +00:00
|
|
|
QW_PrintfToViewer(v, "Keys bound\n");
|
2006-09-19 01:48:12 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(command, "bsay"))
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
char buf[1024];
|
|
|
|
netmsg_t msg;
|
2006-04-11 22:15:09 +00:00
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
viewer_t *ov;
|
|
|
|
if (cluster->notalking)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (ov = cluster->viewers; ov; ov = ov->next)
|
|
|
|
{
|
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
|
|
|
|
WriteByte(&msg, svc_print);
|
|
|
|
|
|
|
|
if (ov->netchan.isnqprotocol)
|
|
|
|
WriteByte(&msg, 1);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ov->conmenussupported)
|
|
|
|
{
|
|
|
|
WriteByte(&msg, 3); //PRINT_CHAT
|
|
|
|
WriteString2(&msg, "[^sBQTV^s]^s^5");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WriteByte(&msg, 2); //PRINT_HIGH
|
|
|
|
WriteByte(&msg, 91+128);
|
|
|
|
WriteString2(&msg, "BQTV");
|
|
|
|
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 ");
|
2007-03-18 05:07:10 +00:00
|
|
|
WriteString2(&msg, args);
|
2007-01-06 09:46:32 +00:00
|
|
|
WriteString(&msg, "\n");
|
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
if (msg.maxsize == msg.cursize)
|
|
|
|
return;
|
2007-01-06 09:46:32 +00:00
|
|
|
SendBufferToViewer(ov, msg.data, msg.cursize, true);
|
|
|
|
}
|
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
else
|
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "QTV Proxy command not recognised\n");
|
|
|
|
}
|
|
|
|
}
|
2006-02-22 02:06:24 +00:00
|
|
|
|
2020-01-20 18:01:39 +00:00
|
|
|
static void QTV_DoSay(cluster_t *cluster, sv_t *qtv, const char *viewername, char *message)
|
2007-03-18 05:07:10 +00:00
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
netmsg_t msg;
|
2020-01-20 18:01:39 +00:00
|
|
|
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];
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
if (message[strlen(message)-1] == '\"')
|
|
|
|
message[strlen(message)-1] = '\0';
|
|
|
|
|
|
|
|
if (*v->expectcommand)
|
|
|
|
{
|
|
|
|
buf[sizeof(buf)-1] = '\0';
|
|
|
|
if (!strcmp(v->expectcommand, "hostname"))
|
|
|
|
{
|
2007-12-27 15:17:05 +00:00
|
|
|
strlcpy(cluster->hostname, message, sizeof(cluster->hostname));
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(v->expectcommand, "master"))
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2007-12-27 15:17:05 +00:00
|
|
|
strlcpy(cluster->master, message, sizeof(cluster->master));
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!strcmp(cluster->master, "."))
|
|
|
|
*cluster->master = '\0';
|
|
|
|
cluster->mastersendtime = cluster->curtime;
|
|
|
|
}
|
|
|
|
else if (!strcmp(v->expectcommand, "addserver"))
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "tcp:%s", message);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_NO, false, false);
|
2007-03-18 05:07:10 +00:00
|
|
|
if (qtv)
|
2006-10-07 22:29:31 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-11-16 14:53:45 +00:00
|
|
|
QW_PrintfToViewer(v, "Connected to \"%s\"\n", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
QW_PrintfToViewer(v, "Failed to connect to server \"%s\", connection aborted\n", message);
|
|
|
|
}
|
|
|
|
else if (!strcmp(v->expectcommand, "admin"))
|
|
|
|
{
|
|
|
|
if (!strcmp(message, cluster->adminpassword))
|
|
|
|
{
|
|
|
|
QW_SetMenu(v, MENU_ADMIN);
|
|
|
|
v->isadmin = true;
|
|
|
|
Sys_Printf(cluster, "Player %s logs in as admin\n", v->name);
|
2006-10-07 22:29:31 +00:00
|
|
|
}
|
2006-04-11 22:15:09 +00:00
|
|
|
else
|
2006-10-07 22:29:31 +00:00
|
|
|
{
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Admin password incorrect\n");
|
|
|
|
Sys_Printf(cluster, "Player %s gets incorrect admin password\n", v->name);
|
2006-10-07 22:29:31 +00:00
|
|
|
}
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(v->expectcommand, "insecadddemo"))
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "file:%s", message);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_NO, false, false);
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!qtv)
|
|
|
|
QW_PrintfToViewer(v, "Failed to play demo \"%s\"\n", message);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-11-16 14:53:45 +00:00
|
|
|
QW_PrintfToViewer(v, "Opened demo file \"%s\".\n", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
else if (!strcmp(v->expectcommand, "adddemo"))
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "file:%s", message);
|
2010-03-14 14:35:56 +00:00
|
|
|
qtv = QTV_NewServerConnection(cluster, 0, buf, "", false, AD_NO, false, false);
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!qtv)
|
|
|
|
QW_PrintfToViewer(v, "Failed to play demo \"%s\"\n", message);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QW_SetViewersServer(cluster, v, qtv);
|
2007-11-16 14:53:45 +00:00
|
|
|
QW_PrintfToViewer(v, "Opened demo file \"%s\".\n", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strcmp(v->expectcommand, "setmvdport"))
|
|
|
|
{
|
2012-09-30 05:52:03 +00:00
|
|
|
int newp = atoi(message);
|
2007-03-18 05:07:10 +00:00
|
|
|
|
2012-09-30 05:52:03 +00:00
|
|
|
Net_TCPListen(cluster, newp, true);
|
|
|
|
Net_TCPListen(cluster, newp, false);
|
|
|
|
cluster->tcplistenportnum = newp;
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QW_PrintfToViewer(v, "Command %s was not recognised\n", v->expectcommand);
|
|
|
|
}
|
|
|
|
|
|
|
|
*v->expectcommand = '\0';
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*message == '.')
|
|
|
|
{
|
|
|
|
if (message[1] == '.') //double it up to say it
|
|
|
|
message++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//this is always execed (. is local server)
|
|
|
|
QTV_SayCommand(cluster, qtv, v, message+1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(message, "proxy:", 6))
|
|
|
|
{
|
|
|
|
//this is execed on the 'active' server
|
|
|
|
if (qtv && (qtv->controller == v && !qtv->proxyisselected))
|
2007-10-29 11:39:13 +00:00
|
|
|
SendClientCommand(qtv, "say \"%s\"", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
else
|
|
|
|
QTV_SayCommand(cluster, qtv, v, message+6);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (*message == ',')
|
|
|
|
{
|
|
|
|
if (message[1] == ',') //double up to say it
|
|
|
|
message++;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (qtv && (qtv->controller == v && qtv->serverisproxy))
|
2007-10-29 11:39:13 +00:00
|
|
|
SendClientCommand(qtv, "say \"%s\"", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
else
|
|
|
|
QTV_SayCommand(cluster, qtv, v, message+1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!strncmp(message, ".", 1))
|
|
|
|
message++;
|
|
|
|
*v->expectcommand = '\0';
|
|
|
|
|
2007-07-23 10:53:59 +00:00
|
|
|
if (qtv && qtv->usequakeworldprotocols && !noupwards)
|
2007-03-18 05:07:10 +00:00
|
|
|
{
|
2007-11-16 14:53:45 +00:00
|
|
|
if (qtv->controller == v)
|
2007-03-18 05:07:10 +00:00
|
|
|
{
|
2007-10-29 11:39:13 +00:00
|
|
|
SendClientCommand(qtv, "say \"%s\"", message);
|
2007-03-18 05:07:10 +00:00
|
|
|
|
|
|
|
if (cluster->notalking)
|
|
|
|
return;
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2006-02-22 02:06:24 +00:00
|
|
|
else
|
|
|
|
{
|
2006-10-07 22:29:31 +00:00
|
|
|
if (cluster->notalking)
|
|
|
|
return;
|
2007-10-29 11:39:13 +00:00
|
|
|
SendClientCommand(qtv, "say \"[%s]: %s\"", v->name, message);
|
2007-03-18 05:07:10 +00:00
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
//FIXME: we ought to broadcast this to everyone not watching that qtv.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-10-31 19:56:51 +00:00
|
|
|
// If the current viewer is the player, pass on the say_team
|
2007-10-10 18:01:27 +00:00
|
|
|
if (qtv && qtv->controller == v)
|
|
|
|
{
|
2007-10-29 11:39:13 +00:00
|
|
|
SendClientCommand(qtv, "say_team \"%s\"", message);
|
2007-10-10 18:01:27 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-20 18:01:39 +00:00
|
|
|
QTV_DoSay(cluster, v->server, v->name, message);
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
viewer_t *QW_IsOn(cluster_t *cluster, char *name)
|
2005-09-24 21:32:31 +00:00
|
|
|
{
|
|
|
|
viewer_t *v;
|
2005-10-07 02:02:15 +00:00
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
2006-09-19 01:48:12 +00:00
|
|
|
if (!stricmp(v->name, name)) //this needs to allow dequakified names.
|
2005-10-07 02:02:15 +00:00
|
|
|
return v;
|
2005-09-24 21:32:31 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
return NULL;
|
2005-09-24 21:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QW_PrintfToViewer(viewer_t *v, char *format, ...)
|
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
int pos = 0;
|
2005-09-24 21:32:31 +00:00
|
|
|
va_list argptr;
|
|
|
|
char buf[1024];
|
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
buf[pos++] = svc_print;
|
|
|
|
if (!v->netchan.isnqprotocol)
|
|
|
|
buf[pos++] = 2; //PRINT_HIGH
|
|
|
|
|
2005-09-24 21:32:31 +00:00
|
|
|
va_start (argptr, format);
|
2007-03-03 18:46:43 +00:00
|
|
|
vsnprintf (buf+pos, sizeof(buf)-pos, format, argptr);
|
2005-09-24 21:32:31 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
SendBufferToViewer(v, buf, strlen(buf)+1, true);
|
|
|
|
}
|
|
|
|
|
2006-02-20 01:33:13 +00:00
|
|
|
|
|
|
|
void QW_StuffcmdToViewer(viewer_t *v, char *format, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
char buf[1024];
|
|
|
|
|
|
|
|
va_start (argptr, format);
|
|
|
|
vsnprintf (buf+1, sizeof(buf)-1, format, argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
buf[0] = svc_stufftext;
|
|
|
|
SendBufferToViewer(v, buf, strlen(buf)+1, true);
|
|
|
|
}
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
void QW_PositionAtIntermission(sv_t *qtv, viewer_t *v)
|
|
|
|
{
|
|
|
|
netmsg_t msg;
|
2018-04-06 17:39:32 +00:00
|
|
|
char buf[7];
|
2007-01-06 09:46:32 +00:00
|
|
|
const intermission_t *spot;
|
2018-04-06 17:39:32 +00:00
|
|
|
unsigned int pext1;
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (qtv)
|
2018-04-06 17:39:32 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
spot = BSP_IntermissionSpot(qtv->map.bsp);
|
2018-04-06 17:39:32 +00:00
|
|
|
pext1 = qtv->pext1;
|
|
|
|
}
|
2007-01-06 09:46:32 +00:00
|
|
|
else
|
2018-04-06 17:39:32 +00:00
|
|
|
{
|
2007-11-09 17:41:08 +00:00
|
|
|
spot = &nullstreamspot;
|
2018-04-06 17:39:32 +00:00
|
|
|
pext1 = 0;
|
|
|
|
}
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
v->origin[0] = spot->pos[0];
|
|
|
|
v->origin[1] = spot->pos[1];
|
|
|
|
v->origin[2] = spot->pos[2];
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
WriteByte (&msg, svc_setangle);
|
2018-04-06 17:39:32 +00:00
|
|
|
WriteAngle(&msg, spot->angle[0], pext1);
|
|
|
|
WriteAngle(&msg, spot->angle[1], pext1);
|
|
|
|
WriteAngle(&msg, 0, pext1);
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
void ParseNQC(cluster_t *cluster, sv_t *qtv, viewer_t *v, netmsg_t *m)
|
|
|
|
{
|
|
|
|
char buf[MAX_NQMSGLEN];
|
|
|
|
netmsg_t msg;
|
|
|
|
int mtype;
|
|
|
|
|
|
|
|
while (m->readpos < m->cursize)
|
|
|
|
{
|
|
|
|
switch ((mtype=ReadByte(m)))
|
|
|
|
{
|
|
|
|
case clc_nop:
|
|
|
|
break;
|
|
|
|
case clc_stringcmd:
|
|
|
|
ReadString (m, buf, sizeof(buf));
|
|
|
|
printf("stringcmd: %s\n", buf);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
if (!strcmp(buf, "new"))
|
|
|
|
{
|
|
|
|
if (qtv && qtv->parsingconnectiondata)
|
|
|
|
QW_StuffcmdToViewer(v, "cmd new\n");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendServerData(qtv, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!strncmp(buf, "prespawn", 8))
|
|
|
|
{
|
|
|
|
msg.data = buf;
|
|
|
|
msg.maxsize = sizeof(buf);
|
|
|
|
msg.cursize = 0;
|
|
|
|
msg.overflowed = 0;
|
|
|
|
|
2006-09-19 01:48:12 +00:00
|
|
|
if (qtv)
|
|
|
|
{
|
|
|
|
SendCurrentBaselines(qtv, 64, &msg, msg.maxsize, 0);
|
|
|
|
SendCurrentLightmaps(qtv, 64, &msg, msg.maxsize, 0);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
2006-09-19 01:48:12 +00:00
|
|
|
SendStaticSounds(qtv, 64, &msg, msg.maxsize, 0);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2006-09-19 01:48:12 +00:00
|
|
|
SendStaticEntities(qtv, 64, &msg, msg.maxsize, 0);
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
WriteByte (&msg, svc_nqsignonnum);
|
|
|
|
WriteByte (&msg, 2);
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
2006-10-20 14:25:20 +00:00
|
|
|
|
|
|
|
else if (!strncmp(buf, "setinfo", 5))
|
|
|
|
{
|
|
|
|
#define TOKENIZE_PUNCTUATION ""
|
|
|
|
|
|
|
|
int i;
|
2007-07-23 10:53:59 +00:00
|
|
|
char arg[3][ARG_LEN];
|
2006-10-20 14:25:20 +00:00
|
|
|
char *command = buf;
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2006-10-20 14:25:20 +00:00
|
|
|
{
|
|
|
|
command = COM_ParseToken(command, arg[i], ARG_LEN, TOKENIZE_PUNCTUATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
Info_SetValueForStarKey(v->userinfo, arg[1], arg[2], sizeof(v->userinfo));
|
2006-10-22 20:33:12 +00:00
|
|
|
ParseUserInfo(cluster, v);
|
2006-10-20 14:25:20 +00:00
|
|
|
// Info_ValueForKey(v->userinfo, "name", v->name, sizeof(v->name));
|
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
SendClientCommand(v->server, "%s", buf);
|
|
|
|
}
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
else if (!strncmp(buf, "name ", 5))
|
|
|
|
{
|
2006-10-20 14:25:20 +00:00
|
|
|
Info_SetValueForStarKey(v->userinfo, "name", buf+5, sizeof(v->userinfo));
|
2006-10-22 20:33:12 +00:00
|
|
|
ParseUserInfo(cluster, v);
|
2006-10-20 14:25:20 +00:00
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
SendClientCommand(v->server, "setinfo name \"%s\"", v->name);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
else if (!strncmp(buf, "color ", 6))
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
fixme
|
|
|
|
*/
|
|
|
|
}
|
2006-10-07 22:29:31 +00:00
|
|
|
else if (!strncmp(buf, "spawn", 5))
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
|
|
|
msg.data = buf;
|
|
|
|
msg.maxsize = sizeof(buf);
|
|
|
|
msg.cursize = 0;
|
|
|
|
msg.overflowed = 0;
|
|
|
|
SendNQSpawnInfoToViewer(cluster, v, &msg);
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_PositionAtIntermission(qtv, v);
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
v->thinksitsconnected = true;
|
|
|
|
}
|
|
|
|
else if (!strncmp(buf, "begin", 5))
|
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
int oldmenu;
|
2006-09-17 01:27:32 +00:00
|
|
|
v->thinksitsconnected = true;
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
oldmenu = v->menunum;
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
QW_SetMenu(v, oldmenu);
|
|
|
|
|
|
|
|
if (!v->server)
|
|
|
|
QTV_Say(cluster, v->server, v, ".menu", false);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
else if (!strncmp(buf, "say \".", 6))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+5, false);
|
|
|
|
else if (!strncmp(buf, "say .", 5))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+4, false);
|
|
|
|
|
|
|
|
else if (v->server && v == v->server->controller)
|
|
|
|
SendClientCommand(v->server, "%s", buf);
|
|
|
|
|
2009-07-07 23:40:06 +00:00
|
|
|
// else if (!strcmp(buf, "pause"))
|
|
|
|
// qtv->errored = ERR_PAUSED;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
else if (!strncmp(buf, "say \"", 5))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+5, false);
|
|
|
|
else if (!strncmp(buf, "say ", 4))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+4, false);
|
|
|
|
|
|
|
|
else if (!strncmp(buf, "say_team \"", 10))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+10, true);
|
|
|
|
else if (!strncmp(buf, "say_team ", 9))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+9, true);
|
|
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QW_PrintfToViewer(v, "Command not recognised\n");
|
2007-11-18 14:55:27 +00:00
|
|
|
Sys_Printf(cluster, "NQ client sent unrecognized stringcmd %s\n", buf);
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case clc_disconnect:
|
2006-10-22 20:33:12 +00:00
|
|
|
if (!v->drop)
|
|
|
|
Sys_Printf(cluster, "NQ viewer %s disconnects\n", v->name);
|
2006-09-17 01:27:32 +00:00
|
|
|
v->drop = true;
|
|
|
|
return;
|
|
|
|
case clc_move:
|
2018-04-06 17:39:32 +00:00
|
|
|
v->ucmds[0] = v->ucmds[1];
|
|
|
|
v->ucmds[1] = v->ucmds[2];
|
2006-09-17 01:27:32 +00:00
|
|
|
ReadFloat(m); //time, for pings
|
|
|
|
//three angles
|
2018-04-06 17:39:32 +00:00
|
|
|
{
|
|
|
|
unsigned int pext1;
|
|
|
|
if (v->server)
|
|
|
|
pext1 = v->server->pext1;
|
|
|
|
else
|
|
|
|
pext1 = 0;
|
|
|
|
v->ucmds[2].angles[0] = ReadAngle(m, pext1);
|
|
|
|
v->ucmds[2].angles[1] = ReadAngle(m, pext1);
|
|
|
|
v->ucmds[2].angles[2] = ReadAngle(m, pext1);
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
//three direction values
|
|
|
|
v->ucmds[2].forwardmove = ReadShort(m);
|
|
|
|
v->ucmds[2].sidemove = ReadShort(m);
|
|
|
|
v->ucmds[2].upmove = ReadShort(m);
|
|
|
|
|
|
|
|
//one button
|
2006-09-19 01:48:12 +00:00
|
|
|
v->ucmds[2].buttons = ReadByte(m);
|
2006-09-17 01:27:32 +00:00
|
|
|
//one impulse
|
|
|
|
v->ucmds[2].impulse = ReadByte(m);
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
v->ucmds[2].msec = cluster->curtime - v->lasttime;
|
|
|
|
v->lasttime = cluster->curtime;
|
|
|
|
|
2018-04-06 17:39:32 +00:00
|
|
|
if (v->menunum)
|
|
|
|
{
|
|
|
|
int mb = 0;
|
|
|
|
if (v->ucmds[2].forwardmove > 0) mb = MBTN_UP;
|
|
|
|
if (v->ucmds[2].forwardmove < 0) mb = MBTN_DOWN;
|
|
|
|
if (v->ucmds[2].sidemove > 0) mb = MBTN_RIGHT;
|
|
|
|
if (v->ucmds[2].sidemove < 0) mb = MBTN_LEFT;
|
|
|
|
if (v->ucmds[2].buttons & 2) mb = MBTN_ENTER;
|
|
|
|
if (mb & ~v->menubuttons & MBTN_UP) v->menuop -= 1;
|
|
|
|
if (mb & ~v->menubuttons & MBTN_DOWN) v->menuop += 1;
|
|
|
|
if (mb & ~v->menubuttons & MBTN_RIGHT) Menu_Enter(cluster, v, 1);
|
|
|
|
if (mb & ~v->menubuttons & MBTN_LEFT) Menu_Enter(cluster, v, -1);
|
|
|
|
if (mb & ~v->menubuttons & MBTN_ENTER) Menu_Enter(cluster, v, 0);
|
|
|
|
if (v->menubuttons != mb)
|
|
|
|
v->menuspamtime = cluster->curtime-1;
|
|
|
|
v->ucmds[2].forwardmove = 0;
|
|
|
|
v->ucmds[2].sidemove = 0;
|
|
|
|
v->ucmds[2].buttons = 0;
|
|
|
|
v->menubuttons = mb;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
v->menubuttons = ~0; //so nothing gets instantly flagged once we enter a menu.
|
|
|
|
|
2012-04-23 04:37:33 +00:00
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
return;
|
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
PMove(v, &v->ucmds[2]);
|
2006-09-19 01:48:12 +00:00
|
|
|
|
|
|
|
if ((v->ucmds[1].buttons&1) != (v->ucmds[2].buttons&1) && (v->ucmds[2].buttons&1))
|
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
if(v->server)
|
|
|
|
{
|
|
|
|
int t;
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
for (t = v->trackplayer+1; t < MAX_CLIENTS; t++)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (v->server->map.players[t].active)
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}/*
|
|
|
|
if (t == MAX_CLIENTS)
|
|
|
|
for (t = 0; t <= v->trackplayer; t++)
|
|
|
|
{
|
|
|
|
if (v->server->players[t].active)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if (t >= MAX_CLIENTS)
|
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
if (v->trackplayer >= 0)
|
|
|
|
QW_PrintfToViewer(v, "Stopped tracking\n");
|
|
|
|
else
|
|
|
|
QW_PrintfToViewer(v, "Not tracking\n");
|
2007-03-03 18:46:43 +00:00
|
|
|
v->trackplayer = -1; //no trackable players found
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v->trackplayer = t;
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(v->server->map.players[t].userinfo, "name", buf, sizeof(buf));
|
2007-03-03 18:46:43 +00:00
|
|
|
QW_PrintfToViewer(v, "Now tracking: %s\n", buf);
|
|
|
|
}
|
|
|
|
}
|
2006-09-19 01:48:12 +00:00
|
|
|
}
|
|
|
|
if ((v->ucmds[1].buttons&2) != (v->ucmds[2].buttons&2) && (v->ucmds[2].buttons&2))
|
|
|
|
{
|
2007-01-09 05:24:03 +00:00
|
|
|
if (!v->server && !v->menunum)
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetMenu(v, MENU_DEFAULT);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if(v->server)
|
|
|
|
{
|
|
|
|
int t;
|
|
|
|
if (v->trackplayer < 0)
|
|
|
|
{
|
|
|
|
for (t = MAX_CLIENTS-1; t >= v->trackplayer; t--)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (v->server->map.players[t].active)
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (t = v->trackplayer-1; t >= 0; t--)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (v->server->map.players[t].active)
|
2007-03-03 18:46:43 +00:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (t < 0)
|
|
|
|
{
|
|
|
|
v->trackplayer = -1; //no trackable players found
|
|
|
|
QW_PrintfToViewer(v, "Not tracking\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v->trackplayer = t;
|
2009-07-07 23:40:06 +00:00
|
|
|
Info_ValueForKey(v->server->map.players[t].userinfo, "name", buf, sizeof(buf));
|
2007-03-03 18:46:43 +00:00
|
|
|
QW_PrintfToViewer(v, "Now tracking: %s\n", buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (v->trackplayer > -1 && v->server)
|
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
v->origin[0] = v->server->map.players[v->trackplayer].current.origin[0];
|
|
|
|
v->origin[1] = v->server->map.players[v->trackplayer].current.origin[1];
|
|
|
|
v->origin[2] = v->server->map.players[v->trackplayer].current.origin[2];
|
2006-09-19 01:48:12 +00:00
|
|
|
}
|
2007-01-09 05:24:03 +00:00
|
|
|
|
2006-09-17 01:27:32 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Sys_Printf(cluster, "Bad message type %i\n", mtype);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
void ParseQWC(cluster_t *cluster, sv_t *qtv, viewer_t *v, netmsg_t *m)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
// usercmd_t oldest, oldcmd, newcmd;
|
2005-09-06 01:09:36 +00:00
|
|
|
char buf[1024];
|
|
|
|
netmsg_t msg;
|
2007-01-06 09:46:32 +00:00
|
|
|
int i;
|
2007-09-08 20:15:59 +00:00
|
|
|
int iscont;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-09-08 20:15:59 +00:00
|
|
|
v->delta_frames[v->netchan.incoming_sequence & (ENTITY_FRAMES-1)] = -1;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
while (m->readpos < m->cursize)
|
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
i = ReadByte(m);
|
|
|
|
switch (i)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
case clc_nop:
|
|
|
|
return;
|
|
|
|
case clc_delta:
|
2007-09-08 20:15:59 +00:00
|
|
|
v->delta_frames[v->netchan.incoming_sequence & (ENTITY_FRAMES-1)] = ReadByte(m);
|
2005-09-06 01:09:36 +00:00
|
|
|
break;
|
2005-09-25 20:50:57 +00:00
|
|
|
case clc_stringcmd:
|
2005-09-06 01:09:36 +00:00
|
|
|
ReadString (m, buf, sizeof(buf));
|
2007-09-08 20:15:59 +00:00
|
|
|
|
|
|
|
iscont = v->server && v->server->controller == v;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-03-18 05:07:10 +00:00
|
|
|
if (!strncmp(buf, "cmd ", 4))
|
|
|
|
{
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
SendClientCommand(v->server, "%s", buf+4);
|
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strcmp(buf, "new"))
|
2006-02-21 19:55:12 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
if (qtv && qtv->parsingconnectiondata)
|
2006-02-21 19:55:12 +00:00
|
|
|
QW_StuffcmdToViewer(v, "cmd new\n");
|
|
|
|
else
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2018-04-06 17:39:32 +00:00
|
|
|
// QW_StuffcmdToViewer(v, "//querycmd conmenu\n");
|
2006-02-21 19:55:12 +00:00
|
|
|
SendServerData(qtv, v);
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strncmp(buf, "modellist ", 10))
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
char *cmd = buf+10;
|
|
|
|
int svcount = atoi(cmd);
|
|
|
|
int first;
|
|
|
|
|
|
|
|
while((*cmd >= '0' && *cmd <= '9') || *cmd == '-')
|
|
|
|
cmd++;
|
|
|
|
first = atoi(cmd);
|
|
|
|
|
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (svcount != v->servercount)
|
2005-09-06 01:09:36 +00:00
|
|
|
{ //looks like we changed map without them.
|
|
|
|
SendServerData(qtv, v);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (!qtv)
|
|
|
|
SendList(qtv, first, ConnectionlessModelList, svc_modellist, &msg);
|
|
|
|
else
|
2009-07-07 23:40:06 +00:00
|
|
|
SendList(qtv, first, qtv->map.modellist, svc_modellist, &msg);
|
2005-09-06 01:09:36 +00:00
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strncmp(buf, "soundlist ", 10))
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
char *cmd = buf+10;
|
|
|
|
int svcount = atoi(cmd);
|
|
|
|
int first;
|
|
|
|
|
|
|
|
while((*cmd >= '0' && *cmd <= '9') || *cmd == '-')
|
|
|
|
cmd++;
|
|
|
|
first = atoi(cmd);
|
|
|
|
|
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (svcount != v->servercount)
|
2005-09-06 01:09:36 +00:00
|
|
|
{ //looks like we changed map without them.
|
|
|
|
SendServerData(qtv, v);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (!qtv)
|
|
|
|
SendList(qtv, first, ConnectionlessSoundList, svc_soundlist, &msg);
|
|
|
|
else
|
2009-07-07 23:40:06 +00:00
|
|
|
SendList(qtv, first, qtv->map.soundlist, svc_soundlist, &msg);
|
2005-09-06 01:09:36 +00:00
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strncmp(buf, "prespawn", 8))
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
char skin[128];
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (atoi(buf + 9) != v->servercount)
|
2005-09-06 01:09:36 +00:00
|
|
|
SendServerData(qtv, v); //we're old.
|
|
|
|
else
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
int crc;
|
2005-09-06 01:09:36 +00:00
|
|
|
int r;
|
|
|
|
char *s;
|
2006-09-17 01:27:32 +00:00
|
|
|
s = buf+8;
|
|
|
|
while(*s == ' ')
|
|
|
|
s++;
|
2005-09-06 01:09:36 +00:00
|
|
|
while((*s >= '0' && *s <= '9') || *s == '-')
|
|
|
|
s++;
|
|
|
|
while(*s == ' ')
|
|
|
|
s++;
|
|
|
|
r = atoi(s);
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
if (r == 0)
|
|
|
|
{
|
|
|
|
while((*s >= '0' && *s <= '9') || *s == '-')
|
|
|
|
s++;
|
|
|
|
while(*s == ' ')
|
|
|
|
s++;
|
|
|
|
crc = atoi(s);
|
|
|
|
|
|
|
|
if (qtv && qtv->controller == v)
|
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
if (!qtv->map.bsp)
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2008-02-01 06:13:30 +00:00
|
|
|
//warning do we still actually need to do this ourselves? Or can we just forward what the user stated?
|
2009-07-07 23:40:06 +00:00
|
|
|
QW_PrintfToViewer(v, "QTV doesn't have that map (%s), sorry.\n", qtv->map.modellist[1].name);
|
2007-12-12 11:17:18 +00:00
|
|
|
qtv->errored = ERR_DROP;
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
else if (crc != BSP_Checksum(qtv->map.bsp))
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
2009-07-07 23:40:06 +00:00
|
|
|
QW_PrintfToViewer(v, "QTV's map (%s) does not match the servers\n", qtv->map.modellist[1].name);
|
2007-12-12 11:17:18 +00:00
|
|
|
qtv->errored = ERR_DROP;
|
2006-04-11 22:15:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
InitNetMsg(&msg, buf, sizeof(buf));
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
if (qtv)
|
|
|
|
{
|
|
|
|
r = Prespawn(qtv, v->netchan.message.cursize, &msg, r, v->thisplayer);
|
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
r = SendCurrentUserinfos(qtv, v->netchan.message.cursize, &msg, r, v->thisplayer);
|
|
|
|
if (r > MAX_CLIENTS)
|
|
|
|
r = -1;
|
2005-10-07 02:02:15 +00:00
|
|
|
SendBufferToViewer(v, msg.data, msg.cursize, true);
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
if (r < 0)
|
|
|
|
sprintf(skin, "%ccmd spawn\n", svc_stufftext);
|
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
sprintf(skin, "%ccmd prespawn %i %i\n", svc_stufftext, v->servercount, r);
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
SendBufferToViewer(v, skin, strlen(skin)+1, true);
|
|
|
|
}
|
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strncmp(buf, "spawn", 5))
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
char skin[64];
|
|
|
|
sprintf(skin, "%cskins\n", svc_stufftext);
|
|
|
|
SendBufferToViewer(v, skin, strlen(skin)+1, true);
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
QW_PositionAtIntermission(qtv, v);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (iscont && !strncmp(buf, "begin", 5))
|
|
|
|
{ //the client made it!
|
|
|
|
v->thinksitsconnected = true;
|
|
|
|
qtv->parsingconnectiondata = false;
|
|
|
|
SendClientCommand(v->server, "%s", buf);
|
|
|
|
}
|
|
|
|
else if (!iscont && !strncmp(buf, "begin", 5))
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
int oldmenu;
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *com;
|
2005-10-07 02:02:15 +00:00
|
|
|
if (atoi(buf+6) != v->servercount)
|
2005-09-06 01:09:36 +00:00
|
|
|
SendServerData(qtv, v); //this is unfortunate!
|
|
|
|
else
|
2006-02-21 23:25:54 +00:00
|
|
|
{
|
2005-09-06 01:09:36 +00:00
|
|
|
v->thinksitsconnected = true;
|
2009-07-07 23:40:06 +00:00
|
|
|
if (qtv && qtv->map.ispaused)
|
2006-02-21 23:25:54 +00:00
|
|
|
{
|
|
|
|
char msgb[] = {svc_setpause, 1};
|
|
|
|
SendBufferToViewer(v, msgb, sizeof(msgb), true);
|
|
|
|
}
|
2006-11-03 15:53:04 +00:00
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
oldmenu = v->menunum;
|
|
|
|
QW_SetMenu(v, MENU_NONE);
|
|
|
|
QW_SetMenu(v, oldmenu);
|
2011-07-14 09:18:04 +00:00
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
com = v->commentator;
|
|
|
|
v->commentator = NULL;
|
|
|
|
QW_SetCommentator(cluster, v, com);
|
|
|
|
|
2008-10-05 16:18:17 +00:00
|
|
|
if (v->firstconnect)
|
|
|
|
{
|
|
|
|
QW_StuffcmdToViewer(v, "f_qtv\n");
|
|
|
|
v->firstconnect = false;
|
|
|
|
}
|
2007-01-06 09:46:32 +00:00
|
|
|
|
|
|
|
if (!v->server)
|
|
|
|
QTV_Say(cluster, v->server, v, ".menu", false);
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
else if (!strncmp(buf, "download", 8))
|
|
|
|
{
|
|
|
|
netmsg_t m;
|
|
|
|
InitNetMsg(&m, buf, sizeof(buf));
|
|
|
|
WriteByte(&m, svc_download);
|
|
|
|
WriteShort(&m, -1);
|
|
|
|
WriteByte(&m, 0);
|
|
|
|
SendBufferToViewer(v, m.data, m.cursize, true);
|
|
|
|
}
|
|
|
|
else if (!strncmp(buf, "drop", 4))
|
2006-10-22 20:33:12 +00:00
|
|
|
{
|
|
|
|
if (!v->drop)
|
|
|
|
Sys_Printf(cluster, "QW viewer %s disconnects\n", v->name);
|
2005-09-06 01:09:36 +00:00
|
|
|
v->drop = true;
|
2006-10-22 20:33:12 +00:00
|
|
|
}
|
2009-07-07 23:40:06 +00:00
|
|
|
else if (!strcmp(buf, "pause"))
|
|
|
|
{
|
|
|
|
if (qtv->errored == ERR_PAUSED)
|
|
|
|
qtv->errored = ERR_NONE;
|
|
|
|
else if (qtv->sourcetype == SRC_DEMO && (1 || v->isadmin))
|
|
|
|
qtv->errored = ERR_PAUSED;
|
|
|
|
else
|
|
|
|
QW_PrintfToViewer(v, "You may not pause this stream\n");
|
|
|
|
}
|
2005-09-24 21:32:31 +00:00
|
|
|
else if (!strncmp(buf, "ison", 4))
|
|
|
|
{
|
2005-10-07 02:02:15 +00:00
|
|
|
viewer_t *other;
|
2006-02-22 02:06:24 +00:00
|
|
|
if ((other = QW_IsOn(cluster, buf+5)))
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
|
|
|
if (!other->server)
|
2006-09-19 01:48:12 +00:00
|
|
|
QW_PrintfToViewer(v, "%s is on the proxy, but not yet watching a game\n", other->name);
|
2005-10-07 02:02:15 +00:00
|
|
|
else
|
|
|
|
QW_PrintfToViewer(v, "%s is watching %s\n", buf+5, other->server->server);
|
|
|
|
}
|
2005-09-24 21:32:31 +00:00
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
QW_PrintfToViewer(v, "%s is not on the proxy, sorry\n", buf+5); //the apology is to make the alternatives distinct.
|
2005-09-24 21:32:31 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
else if (!strncmp(buf, "ptrack ", 7))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2005-09-06 01:09:36 +00:00
|
|
|
v->trackplayer = atoi(buf+7);
|
2006-11-03 15:53:04 +00:00
|
|
|
// if (v->trackplayer != MAX_CLIENTS-2)
|
|
|
|
// QW_SetCommentator(v, NULL);
|
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
else if (!strncmp(buf, "ptrack", 6))
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2005-09-24 04:48:20 +00:00
|
|
|
v->trackplayer = -1;
|
2007-01-09 05:24:03 +00:00
|
|
|
QW_SetCommentator(cluster, v, NULL); //clicking out will stop the client from tracking thier commentator
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (!iscont && !strncmp(buf, "pings", 5))
|
2005-10-07 02:02:15 +00:00
|
|
|
{
|
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
else if (!strncmp(buf, "say \"", 5))
|
2006-04-11 22:15:09 +00:00
|
|
|
QTV_Say(cluster, qtv, v, buf+5, false);
|
2006-02-21 19:55:12 +00:00
|
|
|
else if (!strncmp(buf, "say ", 4))
|
2006-04-11 22:15:09 +00:00
|
|
|
QTV_Say(cluster, qtv, v, buf+4, false);
|
|
|
|
|
|
|
|
else if (!strncmp(buf, "say_team \"", 10))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+10, true);
|
|
|
|
else if (!strncmp(buf, "say_team ", 9))
|
|
|
|
QTV_Say(cluster, qtv, v, buf+9, true);
|
2005-10-07 02:02:15 +00:00
|
|
|
|
|
|
|
else if (!strncmp(buf, "servers", 7))
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
QW_SetMenu(v, MENU_SERVERS);
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
else if (!strncmp(buf, "setinfo", 5))
|
|
|
|
{
|
|
|
|
#define TOKENIZE_PUNCTUATION ""
|
|
|
|
|
|
|
|
int i;
|
2007-07-23 10:53:59 +00:00
|
|
|
char arg[3][ARG_LEN];
|
2006-04-11 22:15:09 +00:00
|
|
|
char *command = buf;
|
|
|
|
|
2007-07-23 10:53:59 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2006-04-11 22:15:09 +00:00
|
|
|
{
|
|
|
|
command = COM_ParseToken(command, arg[i], ARG_LEN, TOKENIZE_PUNCTUATION);
|
|
|
|
}
|
|
|
|
|
|
|
|
Info_SetValueForStarKey(v->userinfo, arg[1], arg[2], sizeof(v->userinfo));
|
2006-10-22 20:33:12 +00:00
|
|
|
ParseUserInfo(cluster, v);
|
2006-10-20 14:25:20 +00:00
|
|
|
// Info_ValueForKey(v->userinfo, "name", v->name, sizeof(v->name));
|
2006-04-11 22:15:09 +00:00
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
SendClientCommand(v->server, "%s", buf);
|
|
|
|
}
|
2006-10-07 22:29:31 +00:00
|
|
|
else if (!strncmp(buf, "cmdsupported ", 13))
|
|
|
|
{
|
|
|
|
if (!strcmp(buf+13, "conmenu"))
|
|
|
|
v->conmenussupported = true;
|
|
|
|
else if (v->server && v->server->controller == v)
|
|
|
|
SendClientCommand(v->server, "%s", buf);
|
|
|
|
}
|
2005-10-07 02:02:15 +00:00
|
|
|
else if (!qtv)
|
|
|
|
{
|
|
|
|
//all the other things need an active server.
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_PrintfToViewer(v, "Choose a server first DEBUG:(%s)\n", buf);
|
2005-10-07 02:02:15 +00:00
|
|
|
}
|
2005-09-24 04:48:20 +00:00
|
|
|
else if (!strncmp(buf, "serverinfo", 5))
|
|
|
|
{
|
|
|
|
char *key, *value, *end;
|
|
|
|
int len;
|
|
|
|
netmsg_t m;
|
|
|
|
InitNetMsg(&m, buf, sizeof(buf));
|
|
|
|
WriteByte(&m, svc_print);
|
|
|
|
WriteByte(&m, 2);
|
2009-07-07 23:40:06 +00:00
|
|
|
end = qtv->map.serverinfo;
|
2005-09-24 04:48:20 +00:00
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
if (!*end)
|
|
|
|
break;
|
|
|
|
key = end;
|
|
|
|
value = strchr(key+1, '\\');
|
|
|
|
if (!value)
|
|
|
|
break;
|
|
|
|
end = strchr(value+1, '\\');
|
|
|
|
if (!end)
|
|
|
|
end = value+strlen(value);
|
|
|
|
|
|
|
|
len = value-key;
|
|
|
|
|
|
|
|
key++;
|
|
|
|
while(*key != '\\' && *key)
|
|
|
|
WriteByte(&m, *key++);
|
|
|
|
|
|
|
|
for (; len < 20; len++)
|
|
|
|
WriteByte(&m, ' ');
|
|
|
|
|
|
|
|
value++;
|
|
|
|
while(*value != '\\' && *value)
|
|
|
|
WriteByte(&m, *value++);
|
|
|
|
WriteByte(&m, '\n');
|
|
|
|
}
|
|
|
|
WriteByte(&m, 0);
|
|
|
|
|
|
|
|
// WriteString(&m, qtv->serverinfo);
|
|
|
|
SendBufferToViewer(v, m.data, m.cursize, true);
|
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
else
|
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
if (v->server && v->server->controller == v)
|
2007-09-08 20:15:59 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
SendClientCommand(v->server, "%s", buf);
|
2007-09-08 20:15:59 +00:00
|
|
|
}
|
2006-04-11 22:15:09 +00:00
|
|
|
else
|
|
|
|
Sys_Printf(cluster, "Client sent unknown string command: %s\n", buf);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-09-06 01:09:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case clc_move:
|
2006-04-11 22:15:09 +00:00
|
|
|
v->lost = ReadByte(m);
|
2005-09-06 01:09:36 +00:00
|
|
|
ReadByte(m);
|
2006-04-11 22:15:09 +00:00
|
|
|
ReadDeltaUsercmd(m, &nullcmd, &v->ucmds[0]);
|
|
|
|
ReadDeltaUsercmd(m, &v->ucmds[0], &v->ucmds[1]);
|
|
|
|
ReadDeltaUsercmd(m, &v->ucmds[1], &v->ucmds[2]);
|
2006-09-19 01:48:12 +00:00
|
|
|
|
2006-04-11 22:15:09 +00:00
|
|
|
PMove(v, &v->ucmds[2]);
|
2007-01-09 05:24:03 +00:00
|
|
|
|
|
|
|
if (v->ucmds[0].buttons & 2)
|
|
|
|
{
|
|
|
|
if (!v->server && !v->menunum)
|
2007-03-18 05:07:10 +00:00
|
|
|
QW_SetMenu(v, MENU_DEFAULT);
|
2007-01-09 05:24:03 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
break;
|
|
|
|
case clc_tmove:
|
2019-03-01 22:39:30 +00:00
|
|
|
v->origin[0] = ReadCoord(m, v->pext1);
|
|
|
|
v->origin[1] = ReadCoord(m, v->pext1);
|
|
|
|
v->origin[2] = ReadCoord(m, v->pext1);
|
2005-09-06 01:09:36 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case clc_upload:
|
2006-10-22 20:33:12 +00:00
|
|
|
Sys_Printf(cluster, "Client uploads are not supported from %s\n", v->name);
|
2005-09-06 01:09:36 +00:00
|
|
|
v->drop = true;
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
2007-01-06 09:46:32 +00:00
|
|
|
Sys_Printf(cluster, "bad clc from %s\n", v->name);
|
2005-09-06 01:09:36 +00:00
|
|
|
v->drop = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-09-24 21:32:31 +00:00
|
|
|
static const char dropcmd[] = {svc_stufftext, 'd', 'i', 's', 'c', 'o', 'n', 'n', 'e', 'c', 't', '\n', '\0'};
|
2005-10-07 02:02:15 +00:00
|
|
|
|
|
|
|
void QW_FreeViewer(cluster_t *cluster, viewer_t *viewer)
|
2005-09-24 21:32:31 +00:00
|
|
|
{
|
2007-01-06 09:46:32 +00:00
|
|
|
char buf[1024];
|
2006-11-03 15:53:04 +00:00
|
|
|
viewer_t *oview;
|
2005-09-24 21:32:31 +00:00
|
|
|
int i;
|
|
|
|
//note: unlink them yourself.
|
|
|
|
|
2007-01-06 09:46:32 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%cQTV%c%s leaves the proxy\n", 91+128, 93+128, viewer->name);
|
|
|
|
QW_StreamPrint(cluster, viewer->server, NULL, buf);
|
|
|
|
|
|
|
|
Sys_Printf(cluster, "Dropping viewer %s\n", viewer->name);
|
2005-09-24 21:32:31 +00:00
|
|
|
|
|
|
|
//spam them thrice, then forget about them
|
2005-10-07 02:02:15 +00:00
|
|
|
Netchan_Transmit(cluster, &viewer->netchan, strlen(dropcmd)+1, dropcmd);
|
|
|
|
Netchan_Transmit(cluster, &viewer->netchan, strlen(dropcmd)+1, dropcmd);
|
|
|
|
Netchan_Transmit(cluster, &viewer->netchan, strlen(dropcmd)+1, dropcmd);
|
2005-09-24 21:32:31 +00:00
|
|
|
|
|
|
|
for (i = 0; i < MAX_BACK_BUFFERS; i++)
|
|
|
|
{
|
|
|
|
if (viewer->backbuf[i].data)
|
|
|
|
free(viewer->backbuf[i].data);
|
|
|
|
}
|
|
|
|
|
2006-02-21 19:55:12 +00:00
|
|
|
if (viewer->server)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
|
|
|
if (viewer->server->controller == viewer)
|
2007-01-09 05:24:03 +00:00
|
|
|
{
|
2010-03-14 14:35:56 +00:00
|
|
|
if (viewer->server->autodisconnect == AD_WHENEMPTY)
|
2007-12-12 11:17:18 +00:00
|
|
|
viewer->server->errored = ERR_DROP;
|
2007-01-09 05:24:03 +00:00
|
|
|
else
|
|
|
|
viewer->server->controller = NULL;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2006-02-21 19:55:12 +00:00
|
|
|
viewer->server->numviewers--;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
2006-02-21 19:55:12 +00:00
|
|
|
|
2006-11-03 15:53:04 +00:00
|
|
|
for (oview = cluster->viewers; oview; oview = oview->next)
|
|
|
|
{
|
|
|
|
if (oview->commentator == viewer)
|
2007-01-06 09:46:32 +00:00
|
|
|
QW_SetCommentator(cluster, oview, NULL);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
|
|
|
|
2005-09-24 21:32:31 +00:00
|
|
|
free(viewer);
|
2005-09-25 20:50:57 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
cluster->numviewers--;
|
2005-09-24 21:32:31 +00:00
|
|
|
}
|
|
|
|
|
2007-01-09 05:24:03 +00:00
|
|
|
void SendViewerPackets(cluster_t *cluster, viewer_t *v)
|
|
|
|
{
|
2007-11-15 21:19:52 +00:00
|
|
|
char buffer[MAX_MSGLEN];
|
2007-01-09 05:24:03 +00:00
|
|
|
netmsg_t m;
|
|
|
|
int read;
|
|
|
|
sv_t *useserver;
|
|
|
|
|
|
|
|
v->drop |= v->netchan.drop;
|
|
|
|
|
|
|
|
if (v->timeout < cluster->curtime)
|
|
|
|
{
|
|
|
|
Sys_Printf(cluster, "Viewer %s timed out\n", v->name);
|
|
|
|
v->drop = true;
|
|
|
|
}
|
|
|
|
|
2007-03-03 18:46:43 +00:00
|
|
|
if (v->netchan.isnqprotocol && (v->server == NULL || v->server->parsingconnectiondata))
|
2007-01-09 05:24:03 +00:00
|
|
|
{
|
|
|
|
v->maysend = (v->nextpacket < cluster->curtime);
|
|
|
|
}
|
|
|
|
if (!Netchan_CanPacket(&v->netchan))
|
2007-07-23 10:53:59 +00:00
|
|
|
{
|
2007-01-09 05:24:03 +00:00
|
|
|
return;
|
2007-07-23 10:53:59 +00:00
|
|
|
}
|
2007-01-09 05:24:03 +00:00
|
|
|
if (v->maysend) //don't send incompleate connection data.
|
|
|
|
{
|
2007-03-03 18:46:43 +00:00
|
|
|
// printf("maysend (%i, %i)\n", cluster->curtime, v->nextpacket);
|
|
|
|
v->nextpacket = v->nextpacket + 1000/NQ_PACKETS_PER_SECOND;
|
|
|
|
if (v->nextpacket < cluster->curtime)
|
|
|
|
v->nextpacket = cluster->curtime;
|
|
|
|
if (v->nextpacket > cluster->curtime+1000/NQ_PACKETS_PER_SECOND)
|
|
|
|
v->nextpacket = cluster->curtime+1000/NQ_PACKETS_PER_SECOND;
|
2007-01-09 05:24:03 +00:00
|
|
|
|
|
|
|
useserver = v->server;
|
2007-09-08 20:15:59 +00:00
|
|
|
if (useserver && useserver->controller == v)
|
|
|
|
v->netchan.outgoing_sequence = useserver->netchan.incoming_sequence;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (useserver && useserver->parsingconnectiondata)
|
|
|
|
useserver = NULL;
|
|
|
|
}
|
2007-01-09 05:24:03 +00:00
|
|
|
|
|
|
|
v->maysend = false;
|
2007-11-15 21:19:52 +00:00
|
|
|
InitNetMsg(&m, buffer, v->netchan.maxdatagramlen);
|
2007-01-09 05:24:03 +00:00
|
|
|
m.cursize = 0;
|
|
|
|
if (v->thinksitsconnected)
|
|
|
|
{
|
|
|
|
if (v->netchan.isnqprotocol)
|
|
|
|
SendNQPlayerStates(cluster, useserver, v, &m);
|
|
|
|
else
|
|
|
|
SendPlayerStates(useserver, v, &m);
|
|
|
|
UpdateStats(useserver, v);
|
|
|
|
}
|
|
|
|
if (v->menunum)
|
|
|
|
Menu_Draw(cluster, v);
|
2007-09-08 20:15:59 +00:00
|
|
|
else if (v->server && v->server->parsingconnectiondata && v->server->controller != v)
|
2007-01-09 05:24:03 +00:00
|
|
|
{
|
|
|
|
WriteByte(&m, svc_centerprint);
|
|
|
|
WriteString(&m, v->server->status);
|
|
|
|
}
|
2007-07-23 10:53:59 +00:00
|
|
|
|
2007-09-08 20:15:59 +00:00
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
|
|
|
int saved;
|
|
|
|
saved = v->netchan.incoming_sequence;
|
|
|
|
v->netchan.incoming_sequence = v->server->netchan.incoming_sequence;
|
|
|
|
Netchan_Transmit(cluster, &v->netchan, m.cursize, m.data);
|
|
|
|
v->netchan.incoming_sequence = saved;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Netchan_Transmit(cluster, &v->netchan, m.cursize, m.data);
|
2007-01-09 05:24:03 +00:00
|
|
|
|
|
|
|
if (!v->netchan.message.cursize && v->backbuffered)
|
|
|
|
{//shift the backbuffers around
|
|
|
|
memcpy(v->netchan.message.data, v->backbuf[0].data, v->backbuf[0].cursize);
|
|
|
|
v->netchan.message.cursize = v->backbuf[0].cursize;
|
|
|
|
for (read = 0; read < v->backbuffered; read++)
|
|
|
|
{
|
|
|
|
if (read == v->backbuffered-1)
|
|
|
|
{
|
|
|
|
v->backbuf[read].cursize = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(v->backbuf[read].data, v->backbuf[read+1].data, v->backbuf[read+1].cursize);
|
|
|
|
v->backbuf[read].cursize = v->backbuf[read+1].cursize;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
v->backbuffered--;
|
|
|
|
}
|
|
|
|
}
|
2007-03-03 18:46:43 +00:00
|
|
|
// else
|
|
|
|
// printf("maynotsend (%i, %i)\n", cluster->curtime, v->nextpacket);
|
2007-01-09 05:24:03 +00:00
|
|
|
}
|
2012-04-20 14:41:40 +00:00
|
|
|
|
|
|
|
void QW_ProcessUDPPacket(cluster_t *cluster, netmsg_t *m, netadr_t from)
|
|
|
|
{
|
|
|
|
char tempbuffer[256];
|
|
|
|
int qport;
|
|
|
|
|
|
|
|
viewer_t *v;
|
|
|
|
sv_t *useserver;
|
|
|
|
|
|
|
|
if (*(int*)m->data == -1)
|
|
|
|
{ //connectionless message
|
|
|
|
ConnectionlessPacket(cluster, &from, m);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m->cursize < 10) //otherwise it's a runt or bad.
|
|
|
|
{
|
|
|
|
qport = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//read the qport
|
|
|
|
ReadLong(m);
|
|
|
|
ReadLong(m);
|
|
|
|
qport = ReadShort(m);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
|
|
|
{
|
|
|
|
if (v->netchan.isnqprotocol)
|
|
|
|
{
|
|
|
|
if (Net_CompareAddress(&v->netchan.remote_address, &from, 0, 0))
|
|
|
|
{
|
|
|
|
if (NQNetchan_Process(cluster, &v->netchan, m))
|
|
|
|
{
|
|
|
|
useserver = v->server;
|
|
|
|
if (useserver && useserver->parsingconnectiondata)
|
|
|
|
useserver = NULL;
|
|
|
|
|
|
|
|
v->timeout = cluster->curtime + 15*1000;
|
|
|
|
|
|
|
|
ParseNQC(cluster, useserver, v, m);
|
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
|
|
|
QTV_Run(v->server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (Net_CompareAddress(&v->netchan.remote_address, &from, v->netchan.qport, qport))
|
|
|
|
{
|
|
|
|
if (v->server && v->server->controller == v && v->maysend)
|
|
|
|
SendViewerPackets(cluster, v); //do this before we read the new sequences
|
|
|
|
|
|
|
|
if (Netchan_Process(&v->netchan, m))
|
|
|
|
{
|
|
|
|
useserver = v->server;
|
|
|
|
if (useserver && useserver->parsingconnectiondata && useserver->controller != v)
|
|
|
|
useserver = NULL;
|
|
|
|
|
|
|
|
v->timeout = cluster->curtime + 15*1000;
|
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
|
|
|
// v->maysend = true;
|
|
|
|
v->server->maysend = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
v->netchan.outgoing_sequence = v->netchan.incoming_sequence; //compensate for client->server packetloss.
|
|
|
|
if (!v->server)
|
|
|
|
v->maysend = true;
|
|
|
|
else if (!v->chokeme || !cluster->chokeonnotupdated)
|
|
|
|
{
|
|
|
|
v->maysend = true;
|
|
|
|
v->chokeme = cluster->chokeonnotupdated;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ParseQWC(cluster, useserver, v, m);
|
|
|
|
|
|
|
|
if (v->server && v->server->controller == v)
|
|
|
|
{
|
|
|
|
QTV_Run(v->server);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!v && cluster->allownqclients)
|
|
|
|
{
|
|
|
|
unsigned int ctrl;
|
|
|
|
//NQ connectionless packet?
|
|
|
|
m->readpos = 0;
|
|
|
|
ctrl = ReadLong(m);
|
|
|
|
ctrl = SwapLong(ctrl);
|
|
|
|
if (ctrl & NETFLAG_CTL)
|
|
|
|
{ //looks hopeful
|
|
|
|
switch(ReadByte(m))
|
|
|
|
{
|
|
|
|
case CCREQ_SERVER_INFO:
|
|
|
|
ReadString(m, tempbuffer, sizeof(tempbuffer));
|
2014-12-23 15:26:42 +00:00
|
|
|
if (!strcmp(tempbuffer, NQ_NETCHAN_GAMENAME))
|
2012-04-20 14:41:40 +00:00
|
|
|
{
|
|
|
|
m->cursize = 0;
|
|
|
|
WriteLong(m, 0);
|
|
|
|
WriteByte(m, CCREP_SERVER_INFO);
|
|
|
|
WriteString(m, "??");
|
|
|
|
WriteString(m, cluster->hostname);
|
|
|
|
WriteString(m, "Quake TV");
|
|
|
|
WriteByte(m, cluster->numviewers>255?255:cluster->numviewers);
|
|
|
|
WriteByte(m, cluster->maxviewers>255?255:cluster->maxviewers);
|
2014-12-23 15:26:42 +00:00
|
|
|
WriteByte(m, NQ_NETCHAN_VERSION);
|
2012-04-20 14:41:40 +00:00
|
|
|
*(int*)m->data = BigLong(NETFLAG_CTL | m->cursize);
|
2015-04-21 04:12:00 +00:00
|
|
|
NET_SendPacket(cluster, NET_ChooseSocket(cluster->qwdsocket, &from, from), m->cursize, m->data, from);
|
2012-04-20 14:41:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CCREQ_CONNECT:
|
|
|
|
ReadString(m, tempbuffer, sizeof(tempbuffer));
|
2014-12-23 15:26:42 +00:00
|
|
|
if (!strcmp(tempbuffer, NQ_NETCHAN_GAMENAME))
|
2012-04-20 14:41:40 +00:00
|
|
|
{
|
2014-12-23 15:26:42 +00:00
|
|
|
if (ReadByte(m) == NQ_NETCHAN_VERSION)
|
2012-04-20 14:41:40 +00:00
|
|
|
{
|
|
|
|
//proquake extensions
|
2019-02-16 19:09:07 +00:00
|
|
|
/*int mod =*/ ReadByte(m);
|
|
|
|
/*int modver =*/ ReadByte(m);
|
|
|
|
/*int flags =*/ ReadByte(m);
|
|
|
|
/*int passwd =*/ ReadLong(m);
|
2012-04-20 14:41:40 +00:00
|
|
|
|
|
|
|
//fte extension, sent so that dual-protocol servers will not create connections for dual-protocol clients
|
dpp7: Treat 'dropped' c2s packets as choked when using dpp7 protocols. This is because the protocol provides no way to disambiguate, and I don't like false reports of packetloss (only reliables loss can be detected, and that's not frequent enough to be meaningful). Pings can still be determined with dpp7, for those few packets which are acked.
package manager: reworked to enable/disable plugins when downloaded, which can also be present-but-disabled.
package manager: display a confirmation prompt before applying changes. do not allow other changes to be made while applying. prompt may be skipped with 'pkg apply' in dedicated servers.
sv: downloads are no longer forced to lower case.
sv: added sv_demoAutoCompress cvar. set to 1 to directly record to *.mvd.gz
cl: properly support directly playing .mvd.gz files
menus: reworked to separate mouse and keyboard focus. mouse focus becomes keyboard focus only on mouse clicks. tooltips follow mouse cursors.
menus: cleaned up menu heirachy a little. now simpler.
server browser: changed 'hide *' filters to 'show *' instead. I felt it was more logical.
deluxmapping: changed to disabled, load, generate, like r_loadlit is.
render targets api now supports negative formats to mean nearest filtering, where filtering is part of texture state.
drawrotpic fixed, now batches and interacts with drawpic correctly.
drawline fixed, no interacts with draw* correctly, but still does not batch.
fixed saving games.
provide proper userinfo to nq clients, where supported.
qcc: catch string table overflows safely, giving errors instead of crashes. switch to 32bit statements if some over-sized function requires it.
qtv: some bigcoords support tweaks
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5073 fc73d0e0-1445-4013-8a0c-d673dee63da5
2017-03-21 05:27:07 +00:00
|
|
|
//the nqconnect command disables this (as well as the qw hand shake) if you really want to use nq protocols with fte clients
|
2012-04-20 14:41:40 +00:00
|
|
|
ReadString(m, tempbuffer, sizeof(tempbuffer));
|
|
|
|
if (!strncmp(tempbuffer, "getchallenge", 12))
|
|
|
|
break;
|
|
|
|
|
|
|
|
//drop any old nq clients from this address
|
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
|
|
|
{
|
|
|
|
if (v->netchan.isnqprotocol)
|
|
|
|
{
|
|
|
|
if (Net_CompareAddress(&v->netchan.remote_address, &from, 0, 0))
|
|
|
|
{
|
|
|
|
Sys_Printf(cluster, "Dup connect from %s\n", v->name);
|
|
|
|
v->drop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NewNQClient(cluster, &from);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QW_TCPConnection(cluster_t *cluster, SOCKET sock, wsrbuf_t ws)
|
|
|
|
{
|
|
|
|
int alen;
|
|
|
|
tcpconnect_t *tc;
|
|
|
|
tc = malloc(sizeof(*tc));
|
|
|
|
if (!tc)
|
|
|
|
{
|
|
|
|
closesocket(sock);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
tc->sock = sock;
|
|
|
|
tc->websocket = ws;
|
|
|
|
tc->inbuffersize = 0;
|
|
|
|
tc->outbuffersize = 0;
|
|
|
|
|
|
|
|
memset(&tc->peeraddr, 0, sizeof(tc->peeraddr));
|
|
|
|
tc->peeraddr.tcpcon = tc;
|
|
|
|
|
|
|
|
alen = sizeof(tc->peeraddr.sockaddr);
|
|
|
|
getpeername(sock, (struct sockaddr*)&tc->peeraddr.sockaddr, &alen);
|
|
|
|
|
|
|
|
tc->next = cluster->tcpconnects;
|
|
|
|
cluster->tcpconnects = tc;
|
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
void QW_UpdateUDPStuff(cluster_t *cluster)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2007-11-15 21:19:52 +00:00
|
|
|
char buffer[MAX_MSGLEN]; //contains read info
|
2005-09-06 01:09:36 +00:00
|
|
|
netadr_t from;
|
2012-04-20 14:41:40 +00:00
|
|
|
int fromsize = sizeof(from.sockaddr);
|
2005-09-06 01:09:36 +00:00
|
|
|
int read;
|
|
|
|
netmsg_t m;
|
2010-03-14 14:35:56 +00:00
|
|
|
int socketno;
|
2012-04-20 14:41:40 +00:00
|
|
|
tcpconnect_t *tc, **l;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
|
|
|
viewer_t *v, *f;
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (*cluster->master && (cluster->curtime > cluster->mastersendtime || cluster->mastersendtime > cluster->curtime + 4*1000*60)) //urm... time wrapped?
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
2006-04-11 22:15:09 +00:00
|
|
|
if (NET_StringToAddr(cluster->master, &from, 27000))
|
2005-09-24 04:48:20 +00:00
|
|
|
{
|
2005-10-07 02:02:15 +00:00
|
|
|
sprintf(buffer, "a\n%i\n0\n", cluster->mastersequence++); //fill buffer with a heartbeat
|
2005-09-24 04:48:20 +00:00
|
|
|
//why is there no \xff\xff\xff\xff ?..
|
2015-04-21 04:12:00 +00:00
|
|
|
NET_SendPacket(cluster, NET_ChooseSocket(cluster->qwdsocket, &from, from), strlen(buffer), buffer, from);
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
|
|
|
else
|
2005-10-07 02:02:15 +00:00
|
|
|
Sys_Printf(cluster, "Cannot resolve master %s\n", cluster->master);
|
2005-09-24 04:48:20 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
cluster->mastersendtime = cluster->curtime + 3*1000*60; //3 minuites.
|
2005-09-24 04:48:20 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2007-11-15 21:19:52 +00:00
|
|
|
/* initialised for reading */
|
|
|
|
InitNetMsg(&m, buffer, sizeof(buffer));
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
socketno = 0;
|
2005-09-06 01:09:36 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2010-03-14 14:35:56 +00:00
|
|
|
if (cluster->qwdsocket[socketno] == INVALID_SOCKET)
|
|
|
|
{
|
|
|
|
socketno++;
|
|
|
|
if (socketno >= SOCKETGROUPS)
|
|
|
|
break;
|
2012-04-20 14:41:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
from.tcpcon = NULL;
|
|
|
|
read = recvfrom(cluster->qwdsocket[socketno], buffer, sizeof(buffer), 0, (struct sockaddr*)&from.sockaddr, (unsigned*)&fromsize);
|
|
|
|
|
|
|
|
if (read < 0) //it's bad.
|
|
|
|
{
|
|
|
|
socketno++;
|
|
|
|
if (socketno >= SOCKETGROUPS)
|
|
|
|
break;
|
|
|
|
continue;
|
2010-03-14 14:35:56 +00:00
|
|
|
}
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2005-09-24 04:48:20 +00:00
|
|
|
if (read <= 5) //otherwise it's a runt or bad.
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
m.cursize = read;
|
2012-04-20 14:41:40 +00:00
|
|
|
m.data = buffer;
|
2007-03-18 05:07:10 +00:00
|
|
|
m.readpos = 0;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
QW_ProcessUDPPacket(cluster, &m, from);
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
for (l = &cluster->tcpconnects; *l; )
|
|
|
|
{
|
|
|
|
int clen;
|
|
|
|
tc = *l;
|
|
|
|
read = sizeof(tc->inbuffer) - tc->inbuffersize;
|
|
|
|
read = NET_WebSocketRecv(tc->sock, &tc->websocket, tc->inbuffer+tc->inbuffersize, read, &clen);
|
|
|
|
if (read > 0)
|
|
|
|
tc->inbuffersize += read;
|
|
|
|
if (read == 0 || read < 0)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2019-02-16 19:09:07 +00:00
|
|
|
if (read == 0 || qerrno != NET_EWOULDBLOCK)
|
2012-04-20 14:41:40 +00:00
|
|
|
{
|
|
|
|
*l = tc->next;
|
|
|
|
closesocket(tc->sock);
|
|
|
|
free(tc);
|
|
|
|
continue;
|
|
|
|
}
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
2012-04-20 14:41:40 +00:00
|
|
|
|
|
|
|
if (clen >= 0)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
/*if it really is a webclient connection, then the stream will be packetized already
|
|
|
|
so we don't waste extra space*/
|
|
|
|
m.data = tc->inbuffer;
|
|
|
|
m.readpos = 0;
|
|
|
|
m.cursize = read;
|
2006-10-22 19:18:15 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
QW_ProcessUDPPacket(cluster, &m, tc->peeraddr);
|
2006-09-17 01:27:32 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
memmove(tc->inbuffer, tc->inbuffer+read, tc->inbuffersize - (read));
|
|
|
|
tc->inbuffersize -= read;
|
|
|
|
continue; //ask to read the next packet
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (tc->inbuffersize >= 2)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
read = (tc->inbuffer[0]<<8) | tc->inbuffer[1];
|
|
|
|
if (tc->inbuffersize >= 2+read)
|
2006-09-17 01:27:32 +00:00
|
|
|
{
|
2012-04-20 14:41:40 +00:00
|
|
|
m.data = tc->inbuffer+2;
|
|
|
|
m.readpos = 0;
|
|
|
|
m.cursize = read;
|
2005-09-06 01:09:36 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
QW_ProcessUDPPacket(cluster, &m, tc->peeraddr);
|
2006-04-11 22:15:09 +00:00
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
memmove(tc->inbuffer, tc->inbuffer+2+read, tc->inbuffersize - (2+read));
|
|
|
|
tc->inbuffersize -= 2+read;
|
2006-09-17 01:27:32 +00:00
|
|
|
}
|
2012-04-20 14:41:40 +00:00
|
|
|
else
|
2006-09-17 01:27:32 +00:00
|
|
|
break;
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-20 14:41:40 +00:00
|
|
|
l = &(*l)->next;
|
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
if (cluster->viewers && cluster->viewers->drop)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
2006-10-22 20:33:12 +00:00
|
|
|
// Sys_Printf(cluster, "Dropping viewer %s\n", v->name);
|
2005-10-07 02:02:15 +00:00
|
|
|
f = cluster->viewers;
|
|
|
|
cluster->viewers = f->next;
|
2005-09-24 21:32:31 +00:00
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
QW_FreeViewer(cluster, f);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
for (v = cluster->viewers; v; v = v->next)
|
2005-09-06 01:09:36 +00:00
|
|
|
{
|
|
|
|
if (v->next && v->next->drop)
|
|
|
|
{ //free the next/
|
2006-10-22 20:33:12 +00:00
|
|
|
// Sys_Printf(cluster, "Dropping viewer %s\n", v->name);
|
2005-09-06 01:09:36 +00:00
|
|
|
f = v->next;
|
|
|
|
v->next = f->next;
|
|
|
|
|
2005-10-07 02:02:15 +00:00
|
|
|
QW_FreeViewer(cluster, f);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
|
2007-01-09 05:24:03 +00:00
|
|
|
SendViewerPackets(cluster, v);
|
2005-09-06 01:09:36 +00:00
|
|
|
}
|
|
|
|
}
|