2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_parse.c
|
|
|
|
|
|
|
|
parse a message received from the server
|
|
|
|
|
|
|
|
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 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:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2001-05-19 23:31:20 +00:00
|
|
|
# include <string.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
2001-05-19 23:31:20 +00:00
|
|
|
# include <strings.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_ERRNO_H
|
2001-05-19 23:31:20 +00:00
|
|
|
# include <errno.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-05-19 23:31:20 +00:00
|
|
|
# include <unistd.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2002-11-05 19:12:51 +00:00
|
|
|
#include "QF/draw.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/dstring.h"
|
|
|
|
#include "QF/gib.h"
|
2003-08-12 23:22:30 +00:00
|
|
|
#include "QF/idparse.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/msg.h"
|
2011-08-28 12:11:08 +00:00
|
|
|
#include "QF/progs.h"
|
2021-03-21 07:13:03 +00:00
|
|
|
#include "QF/plist.h"
|
2002-08-27 07:16:28 +00:00
|
|
|
#include "QF/quakeio.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/screen.h"
|
2012-01-23 07:16:30 +00:00
|
|
|
#include "QF/skin.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/sound.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/teamplay.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "QF/scene/scene.h"
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "sbar.h"
|
|
|
|
|
2021-03-11 06:23:35 +00:00
|
|
|
#include "client/effects.h"
|
2022-03-29 04:46:11 +00:00
|
|
|
#include "client/particles.h"
|
2022-11-02 06:08:09 +00:00
|
|
|
#include "client/screen.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "client/temp_entities.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
#include "client/view.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/bothdefs.h"
|
2005-05-02 04:09:15 +00:00
|
|
|
#include "qw/pmove.h"
|
2004-02-21 02:31:22 +00:00
|
|
|
#include "qw/protocol.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "qw/include/cl_cam.h"
|
|
|
|
#include "qw/include/cl_chat.h"
|
|
|
|
#include "qw/include/cl_ents.h"
|
|
|
|
#include "qw/include/cl_http.h"
|
|
|
|
#include "qw/include/cl_input.h"
|
|
|
|
#include "qw/include/cl_main.h"
|
|
|
|
#include "qw/include/cl_parse.h"
|
|
|
|
#include "qw/include/cl_skin.h"
|
|
|
|
#include "qw/include/client.h"
|
|
|
|
#include "qw/include/host.h"
|
|
|
|
#include "qw/include/map_cfg.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
const char *svc_strings[] = {
|
2001-11-07 08:24:56 +00:00
|
|
|
"svc_bad",
|
|
|
|
"svc_nop",
|
|
|
|
"svc_disconnect",
|
|
|
|
"svc_updatestat",
|
|
|
|
"svc_version", // [long] server version
|
|
|
|
"svc_setview", // [short] entity number
|
|
|
|
"svc_sound", // <see code>
|
|
|
|
"svc_time", // [float] server time
|
|
|
|
"svc_print", // [string] null terminated string
|
|
|
|
"svc_stufftext", // [string] stuffed into client's console
|
|
|
|
// buffer the string should be \n terminated
|
|
|
|
"svc_setangle", // [vec3] set view angle to this absolute value
|
|
|
|
|
|
|
|
"svc_serverdata", // [long] version ...
|
|
|
|
"svc_lightstyle", // [byte] [string]
|
|
|
|
"svc_updatename", // [byte] [string]
|
|
|
|
"svc_updatefrags", // [byte] [short]
|
|
|
|
"svc_clientdata", // <shortbits + data>
|
|
|
|
"svc_stopsound", // <see code>
|
|
|
|
"svc_updatecolors", // [byte] [byte]
|
|
|
|
"svc_particle", // [vec3] <variable>
|
|
|
|
"svc_damage", // [byte] impact [byte] blood [vec3] from
|
|
|
|
|
|
|
|
"svc_spawnstatic",
|
|
|
|
"OBSOLETE svc_spawnbinary",
|
|
|
|
"svc_spawnbaseline",
|
|
|
|
|
|
|
|
"svc_temp_entity", // <variable>
|
|
|
|
"svc_setpause",
|
|
|
|
"svc_signonnum",
|
|
|
|
"svc_centerprint",
|
|
|
|
"svc_killedmonster",
|
|
|
|
"svc_foundsecret",
|
|
|
|
"svc_spawnstaticsound",
|
|
|
|
"svc_intermission",
|
2011-08-27 01:25:41 +00:00
|
|
|
"svc_finale", // [string] text
|
|
|
|
"svc_cdtrack", // [byte] track
|
2001-11-07 08:24:56 +00:00
|
|
|
"svc_sellscreen",
|
|
|
|
"svc_smallkick",
|
|
|
|
"svc_bigkick",
|
|
|
|
"svc_updateping",
|
|
|
|
"svc_updateentertime",
|
|
|
|
"svc_updatestatlong",
|
|
|
|
"svc_muzzleflash",
|
|
|
|
"svc_updateuserinfo",
|
|
|
|
"svc_download",
|
|
|
|
"svc_playerinfo",
|
|
|
|
"svc_nails",
|
2012-05-26 01:39:42 +00:00
|
|
|
"svc_chokecount",
|
2001-11-07 08:24:56 +00:00
|
|
|
"svc_modellist",
|
|
|
|
"svc_soundlist",
|
|
|
|
"svc_packetentities",
|
|
|
|
"svc_deltapacketentities",
|
|
|
|
"svc_maxspeed",
|
|
|
|
"svc_entgravity",
|
|
|
|
"svc_setinfo",
|
|
|
|
"svc_serverinfo",
|
|
|
|
"svc_updatepl",
|
2002-10-02 21:56:45 +00:00
|
|
|
"svc_nails2", // FIXME from qwex
|
2001-11-07 08:24:56 +00:00
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL",
|
|
|
|
"NEW PROTOCOL"
|
|
|
|
};
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
int oldparsecountmod;
|
|
|
|
int parsecountmod;
|
|
|
|
double parsecounttime;
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
int cl_playerindex, cl_flagindex;
|
2001-02-19 21:15:25 +00:00
|
|
|
int cl_h_playerindex, cl_gib1index, cl_gib2index, cl_gib3index;
|
|
|
|
|
|
|
|
int packet_latency[NET_TIMINGS];
|
|
|
|
|
|
|
|
int
|
|
|
|
CL_CalcNet (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
int lost, a, i;
|
|
|
|
frame_t *frame;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
for (i = cls.netchan.outgoing_sequence - UPDATE_BACKUP + 1;
|
|
|
|
i <= cls.netchan.outgoing_sequence; i++) {
|
|
|
|
frame = &cl.frames[i & UPDATE_MASK];
|
2021-07-11 02:02:37 +00:00
|
|
|
if (frame->receivedtime == -1) {
|
2002-07-03 05:40:33 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 9999; // dropped
|
2021-07-11 02:02:37 +00:00
|
|
|
} else if (frame->receivedtime == -2) {
|
2001-02-19 21:15:25 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 10000; // choked
|
2021-07-11 02:02:37 +00:00
|
|
|
} else if (frame->invalid) {
|
2002-07-03 05:40:33 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 9998; // invalid delta
|
2021-07-11 02:02:37 +00:00
|
|
|
} else {
|
|
|
|
double d = frame->receivedtime - frame->senttime;
|
|
|
|
d = log (d * 1000 + 1) / log (1000);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
d *= d * cl_netgraph_height;
|
2021-07-11 02:02:37 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = d;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lost = 0;
|
|
|
|
for (a = 0; a < NET_TIMINGS; a++) {
|
|
|
|
i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK;
|
|
|
|
if (packet_latency[i] == 9999)
|
|
|
|
lost++;
|
|
|
|
}
|
|
|
|
return lost * 100 / NET_TIMINGS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_CheckOrDownloadFile
|
|
|
|
|
|
|
|
Returns true if the file exists, otherwise it attempts
|
|
|
|
to start a download from the server.
|
|
|
|
*/
|
|
|
|
qboolean
|
2001-07-15 07:04:17 +00:00
|
|
|
CL_CheckOrDownloadFile (const char *filename)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-08-27 07:16:28 +00:00
|
|
|
QFile *f;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (strstr (filename, "..")) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Refusing to download a path with ..\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-01-08 01:02:35 +00:00
|
|
|
/*
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!snd_initialized && strnequal ("sound/", filename, 6)) {
|
2002-09-12 22:09:55 +00:00
|
|
|
// don't bother downloading sounds if we can't play them
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-01-08 01:02:35 +00:00
|
|
|
*/
|
2014-01-23 02:57:57 +00:00
|
|
|
f = QFS_FOpenFile (filename);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (f) { // it exists, no need to download
|
|
|
|
Qclose (f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// ZOID - can't download when recording
|
|
|
|
if (cls.demorecording) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Unable to download %s in record mode.\n",
|
2007-03-20 14:16:43 +00:00
|
|
|
cls.downloadname->str);
|
2001-02-19 21:15:25 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// ZOID - can't download when playback
|
|
|
|
if (cls.demoplayback)
|
|
|
|
return true;
|
|
|
|
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_copystr (cls.downloadname, filename);
|
2007-03-24 13:57:07 +00:00
|
|
|
dstring_copystr (cls.downloadtempname, filename);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Downloading %s...\n", cls.downloadname->str);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// download to a temp name, and rename to the real name only when done,
|
2002-07-03 05:40:33 +00:00
|
|
|
// so if interrupted a runt file wont be left
|
2007-03-20 14:16:43 +00:00
|
|
|
QFS_StripExtension (cls.downloadname->str, cls.downloadtempname->str);
|
|
|
|
dstring_appendstr (cls.downloadtempname, ".tmp");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, "download \"%s\"", cls.downloadname->str));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cls.downloadnumber++;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-11-08 02:43:04 +00:00
|
|
|
CL_NewMap (const char *mapname)
|
|
|
|
{
|
2022-03-04 16:48:10 +00:00
|
|
|
const char *skyname = 0;
|
|
|
|
// R_LoadSkys does the right thing with null pointers.
|
|
|
|
if (cl.serverinfo) {
|
|
|
|
skyname = Info_ValueForKey (cl.serverinfo, "sky");
|
2011-08-28 12:11:08 +00:00
|
|
|
}
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_World_NewMap (mapname, skyname);
|
2022-05-05 05:41:46 +00:00
|
|
|
cl.chasestate.worldmodel = cl_world.scene->worldmodel;
|
|
|
|
|
|
|
|
Team_NewMap ();
|
|
|
|
Con_NewMap ();
|
|
|
|
Sbar_CenterPrint (0);
|
|
|
|
|
|
|
|
Hunk_Check (0); // make sure nothing is hurt
|
2002-08-06 05:45:03 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
Model_NextDownload (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char *s;
|
|
|
|
int i;
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.downloadnumber == 0) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Checking models...\n");
|
2022-11-02 06:08:09 +00:00
|
|
|
cl.viewstate.time = realtime;
|
|
|
|
CL_UpdateScreen (&cl.viewstate);
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.downloadnumber = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.downloadtype = dl_model;
|
|
|
|
for (; cl.model_name[cls.downloadnumber][0]; cls.downloadnumber++) {
|
|
|
|
s = cl.model_name[cls.downloadnumber];
|
|
|
|
if (s[0] == '*')
|
2002-07-03 05:40:33 +00:00
|
|
|
continue; // inline brush model
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!CL_CheckOrDownloadFile (s))
|
2002-07-03 05:40:33 +00:00
|
|
|
return; // started a download
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2022-07-26 12:14:28 +00:00
|
|
|
CL_MapCfg (cl.model_name[1]);
|
2002-11-08 02:43:04 +00:00
|
|
|
|
2012-01-09 07:22:39 +00:00
|
|
|
for (i = 1; i < cl.nummodels; i++) {
|
2021-03-29 08:24:30 +00:00
|
|
|
const char *info_key = 0;
|
2001-05-29 17:37:48 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cl.model_name[i][0])
|
|
|
|
break;
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
DARRAY_APPEND (&cl_world.models,
|
|
|
|
Mod_ForName (cl.model_name[i], false));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
if (!cl_world.models.a[i]) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("\nThe required model file '%s' could not be found or "
|
2001-08-28 23:05:45 +00:00
|
|
|
"downloaded.\n\n", cl.model_name[i]);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("You may need to download or purchase a %s client "
|
2001-02-19 21:15:25 +00:00
|
|
|
"pack in order to play on this server.\n\n",
|
2003-02-14 22:36:10 +00:00
|
|
|
qfs_gamedir->gamedir);
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Disconnect ();
|
|
|
|
return;
|
|
|
|
}
|
2001-05-29 17:37:48 +00:00
|
|
|
|
2001-06-02 22:20:34 +00:00
|
|
|
if (strequal (cl.model_name[i], "progs/player.mdl")
|
2022-03-04 16:48:10 +00:00
|
|
|
&& cl_world.models.a[i]->type == mod_alias) {
|
2001-06-02 22:20:34 +00:00
|
|
|
info_key = pmodel_name;
|
2022-03-04 16:48:10 +00:00
|
|
|
//XXX mod_funcs->Skin_Player_Model (cl_world.models.a[i]);
|
2002-09-13 05:32:28 +00:00
|
|
|
}
|
2001-06-02 22:20:34 +00:00
|
|
|
if (strequal (cl.model_name[i], "progs/eyes.mdl")
|
2022-03-04 16:48:10 +00:00
|
|
|
&& cl_world.models.a[i]->type == mod_alias)
|
2001-06-02 22:20:34 +00:00
|
|
|
info_key = emodel_name;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (info_key && cl_model_crcs) {
|
2022-03-04 16:48:10 +00:00
|
|
|
aliashdr_t *ahdr = cl_world.models.a[i]->aliashdr;
|
2012-01-23 07:47:43 +00:00
|
|
|
if (!ahdr)
|
2022-03-04 16:48:10 +00:00
|
|
|
ahdr = Cache_Get (&cl_world.models.a[i]->cache);
|
2021-01-31 07:01:20 +00:00
|
|
|
Info_SetValueForKey (cls.userinfo, info_key, va (0, "%d",
|
|
|
|
ahdr->crc),
|
2001-11-04 07:50:39 +00:00
|
|
|
0);
|
2002-10-05 04:52:09 +00:00
|
|
|
if (!cls.demoplayback) {
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
2021-01-31 07:01:20 +00:00
|
|
|
SZ_Print (&cls.netchan.message, va (0, "setinfo %s %d",
|
|
|
|
info_key, ahdr->crc));
|
2002-10-05 04:52:09 +00:00
|
|
|
}
|
2022-03-04 16:48:10 +00:00
|
|
|
if (!cl_world.models.a[i]->aliashdr)
|
|
|
|
Cache_Release (&cl_world.models.a[i]->cache);
|
2001-05-29 17:37:48 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Something went wrong (probably in the server, probably a TF server)
|
|
|
|
// We need to disconnect gracefully.
|
2022-03-04 16:48:10 +00:00
|
|
|
if (!cl_world.models.a[1]) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("\nThe server has failed to provide the map name.\n\n");
|
|
|
|
Sys_Printf ("Disconnecting to prevent a crash.\n\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Disconnect ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// all done
|
2002-08-06 05:45:03 +00:00
|
|
|
CL_NewMap (cl.model_name[1]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// done with modellist, request first of static signon messages
|
2002-10-05 04:52:09 +00:00
|
|
|
if (!cls.demoplayback) {
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, prespawn_name, cl.servercount,
|
2022-05-05 05:41:46 +00:00
|
|
|
cl_world.scene->worldmodel->brush.checksum2));
|
2002-10-05 04:52:09 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
Sound_NextDownload (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char *s;
|
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cls.downloadnumber == 0) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Checking sounds...\n");
|
2022-11-02 06:08:09 +00:00
|
|
|
cl.viewstate.time = realtime;
|
|
|
|
CL_UpdateScreen (&cl.viewstate);
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.downloadnumber = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.downloadtype = dl_sound;
|
|
|
|
for (; cl.sound_name[cls.downloadnumber][0];
|
|
|
|
cls.downloadnumber++) {
|
|
|
|
s = cl.sound_name[cls.downloadnumber];
|
2021-01-31 07:01:20 +00:00
|
|
|
if (!CL_CheckOrDownloadFile (va (0, "sound/%s", s)))
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // started a download
|
|
|
|
}
|
|
|
|
|
2012-01-09 07:22:39 +00:00
|
|
|
for (i = 1; i < cl.numsounds; i++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cl.sound_name[i][0])
|
|
|
|
break;
|
|
|
|
cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// done with sounds, request models now
|
2022-03-04 16:48:10 +00:00
|
|
|
cl_world.models.size = 0;
|
|
|
|
DARRAY_APPEND (&cl_world.models, 0);// ind 0 is null model
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_playerindex = -1;
|
|
|
|
cl_flagindex = -1;
|
|
|
|
cl_h_playerindex = -1;
|
|
|
|
cl_gib1index = cl_gib2index = cl_gib3index = -1;
|
2002-10-05 04:52:09 +00:00
|
|
|
if (!cls.demoplayback) {
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, modellist_name, cl.servercount, 0));
|
2002-10-05 04:52:09 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_RequestNextDownload (void)
|
|
|
|
{
|
|
|
|
switch (cls.downloadtype) {
|
|
|
|
case dl_single:
|
|
|
|
break;
|
|
|
|
case dl_skin:
|
|
|
|
Skin_NextDownload ();
|
|
|
|
break;
|
|
|
|
case dl_model:
|
|
|
|
Model_NextDownload ();
|
|
|
|
break;
|
|
|
|
case dl_sound:
|
|
|
|
Sound_NextDownload ();
|
|
|
|
break;
|
|
|
|
case dl_none:
|
|
|
|
default:
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Unknown download type.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:16:43 +00:00
|
|
|
void
|
|
|
|
CL_FinishDownload (void)
|
|
|
|
{
|
|
|
|
Qclose (cls.download);
|
2021-01-31 07:01:20 +00:00
|
|
|
VID_SetCaption (va (0, "Connecting to %s", cls.servername->str));
|
2007-03-20 14:16:43 +00:00
|
|
|
|
|
|
|
// rename the temp file to it's final name
|
|
|
|
if (strcmp (cls.downloadtempname->str, cls.downloadname->str)) {
|
|
|
|
dstring_t *oldn = dstring_new ();
|
|
|
|
dstring_t *newn = dstring_new ();
|
|
|
|
|
|
|
|
if (strncmp (cls.downloadtempname->str, "skins/", 6)) {
|
|
|
|
dsprintf (oldn, "%s/%s", qfs_gamedir->dir.def,
|
|
|
|
cls.downloadtempname->str);
|
|
|
|
dsprintf (newn, "%s/%s", qfs_gamedir->dir.def,
|
|
|
|
cls.downloadname->str);
|
|
|
|
} else {
|
|
|
|
dsprintf (oldn, "%s/%s", qfs_gamedir->dir.skins,
|
|
|
|
cls.downloadtempname->str + 6);
|
|
|
|
dsprintf (newn, "%s/%s", qfs_gamedir->dir.skins,
|
|
|
|
cls.downloadname->str + 6);
|
|
|
|
}
|
|
|
|
if (QFS_Rename (oldn->str, newn->str))
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("failed to rename %s to %s, %s.\n", oldn->str,
|
2007-03-24 13:57:07 +00:00
|
|
|
newn->str, strerror (errno));
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_delete (oldn);
|
|
|
|
dstring_delete (newn);
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.download = NULL;
|
|
|
|
dstring_clearstr (cls.downloadname);
|
2007-03-24 13:57:07 +00:00
|
|
|
dstring_clearstr (cls.downloadtempname);
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_clearstr (cls.downloadurl);
|
|
|
|
cls.downloadpercent = 0;
|
|
|
|
|
|
|
|
// get another file if needed
|
|
|
|
CL_RequestNextDownload ();
|
|
|
|
}
|
|
|
|
|
2007-03-24 14:20:20 +00:00
|
|
|
void
|
|
|
|
CL_FailDownload (void)
|
|
|
|
{
|
|
|
|
if (cls.download) {
|
|
|
|
Qclose (cls.download);
|
|
|
|
cls.download = NULL;
|
|
|
|
}
|
|
|
|
dstring_clearstr (cls.downloadname);
|
|
|
|
dstring_clearstr (cls.downloadtempname);
|
|
|
|
dstring_clearstr (cls.downloadurl);
|
|
|
|
CL_RequestNextDownload ();
|
|
|
|
}
|
|
|
|
|
2007-03-24 13:57:07 +00:00
|
|
|
static int
|
|
|
|
CL_OpenDownload (void)
|
|
|
|
{
|
|
|
|
dstring_t *name = dstring_newstr ();
|
|
|
|
const char *fname, *path;
|
|
|
|
|
|
|
|
if (strncmp (cls.downloadtempname->str, "skins/", 6) == 0) {
|
|
|
|
path = qfs_gamedir->dir.skins;
|
|
|
|
fname = cls.downloadtempname->str + 6;
|
|
|
|
} else if (strncmp (cls.downloadtempname->str, "progs/", 6) == 0) {
|
2010-08-24 13:42:00 +00:00
|
|
|
path = qfs_gamedir->dir.models;
|
2007-03-24 13:57:07 +00:00
|
|
|
fname = cls.downloadtempname->str + 6;
|
|
|
|
} else if (strncmp (cls.downloadtempname->str, "sound/", 6) == 0) {
|
|
|
|
path = qfs_gamedir->dir.sound;
|
|
|
|
fname = cls.downloadtempname->str + 6;
|
|
|
|
} else if (strncmp (cls.downloadtempname->str, "maps/", 5) == 0) {
|
|
|
|
path = qfs_gamedir->dir.maps;
|
|
|
|
fname = cls.downloadtempname->str + 5;
|
|
|
|
} else {
|
|
|
|
path = qfs_gamedir->dir.def;
|
|
|
|
fname = cls.downloadtempname->str;
|
|
|
|
}
|
|
|
|
dsprintf (name, "%s/%s", path, fname);
|
|
|
|
|
|
|
|
cls.download = QFS_WOpen (name->str, 0);
|
|
|
|
if (!cls.download) {
|
|
|
|
dstring_clearstr (cls.downloadname);
|
|
|
|
dstring_clearstr (cls.downloadurl);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Failed to open %s\n", name->str);
|
2007-03-24 13:57:07 +00:00
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
dstring_delete (name);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
CL_ParseDownload
|
|
|
|
|
|
|
|
A download message has been received from the server
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseDownload (void)
|
|
|
|
{
|
2007-03-20 14:16:43 +00:00
|
|
|
int size, percent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
// read the data
|
2011-12-10 12:37:32 +00:00
|
|
|
size = (short) MSG_ReadShort (net_message);
|
2001-11-07 08:24:56 +00:00
|
|
|
percent = MSG_ReadByte (net_message);
|
2007-03-24 14:20:20 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (cls.demoplayback) {
|
|
|
|
if (size > 0)
|
|
|
|
net_message->readcount += size;
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_clearstr (cls.downloadname);
|
2007-03-24 14:20:20 +00:00
|
|
|
dstring_clearstr (cls.downloadtempname);
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_clearstr (cls.downloadurl);
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // not in demo playback
|
2001-11-07 08:24:56 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2007-03-20 14:41:54 +00:00
|
|
|
if (size == DL_NOFILE) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("File not found.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.download) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("cls.download shouldn't have been set\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
Qclose (cls.download);
|
|
|
|
cls.download = NULL;
|
|
|
|
}
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_clearstr (cls.downloadname);
|
2007-03-24 14:20:20 +00:00
|
|
|
dstring_clearstr (cls.downloadtempname);
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_clearstr (cls.downloadurl);
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-20 14:41:54 +00:00
|
|
|
if (size == DL_RENAME) {
|
2007-03-20 14:16:43 +00:00
|
|
|
const char *newname = MSG_ReadString (net_message);
|
2001-11-07 08:24:56 +00:00
|
|
|
|
2007-03-20 14:16:43 +00:00
|
|
|
if (strncmp (newname, cls.downloadname->str,
|
|
|
|
strlen (cls.downloadname->str))
|
|
|
|
|| strstr (newname + strlen (cls.downloadname->str), "/")) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf
|
2001-11-07 08:24:56 +00:00
|
|
|
("WARNING: server tried to give a strange new name: %s\n",
|
|
|
|
newname);
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cls.download) {
|
|
|
|
Qclose (cls.download);
|
2007-03-20 14:16:43 +00:00
|
|
|
unlink (cls.downloadname->str);
|
|
|
|
}
|
|
|
|
dstring_copystr (cls.downloadname, newname);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("downloading to %s\n", cls.downloadname->str);
|
2007-03-20 14:16:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-03-20 14:41:54 +00:00
|
|
|
if (size == DL_HTTP) {
|
2007-03-20 14:16:43 +00:00
|
|
|
#ifdef HAVE_LIBCURL
|
|
|
|
const char *url = MSG_ReadString (net_message);
|
|
|
|
const char *newname = MSG_ReadString (net_message);
|
|
|
|
|
2007-03-21 11:35:45 +00:00
|
|
|
if (*newname) {
|
2007-03-20 14:16:43 +00:00
|
|
|
if (strncmp (newname, cls.downloadname->str,
|
|
|
|
strlen (cls.downloadname->str))
|
|
|
|
|| strstr (newname + strlen (cls.downloadname->str), "/")) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf
|
2007-03-20 14:16:43 +00:00
|
|
|
("WARNING: server tried to give a strange new name: %s\n",
|
|
|
|
newname);
|
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (cls.download) {
|
|
|
|
Qclose (cls.download);
|
|
|
|
unlink (cls.downloadname->str);
|
|
|
|
}
|
|
|
|
dstring_copystr (cls.downloadname, newname);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2007-03-20 14:16:43 +00:00
|
|
|
dstring_copystr (cls.downloadurl, url);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("downloading %s to %s\n", cls.downloadurl->str,
|
2007-03-20 14:16:43 +00:00
|
|
|
cls.downloadname->str);
|
|
|
|
CL_HTTP_StartDownload ();
|
|
|
|
#else
|
|
|
|
MSG_ReadString (net_message);
|
|
|
|
MSG_ReadString (net_message);
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("server sent http redirect but we don't know how to handle"
|
2007-03-20 14:16:43 +00:00
|
|
|
"it :(\n");
|
|
|
|
#endif
|
2007-03-24 13:57:07 +00:00
|
|
|
CL_OpenDownload ();
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// open the file if not opened yet
|
|
|
|
if (!cls.download) {
|
2007-03-24 13:57:07 +00:00
|
|
|
if (!CL_OpenDownload ()) {
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
2007-03-24 13:57:07 +00:00
|
|
|
net_message->readcount += size;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
Qwrite (cls.download, net_message->message->data + net_message->readcount,
|
|
|
|
size);
|
|
|
|
net_message->readcount += size;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (percent != 100) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// request next block
|
2001-11-07 08:24:56 +00:00
|
|
|
if (percent != cls.downloadpercent)
|
2021-01-31 07:01:20 +00:00
|
|
|
VID_SetCaption (va (0, "Downloading %s %d%%",
|
|
|
|
cls.downloadname->str, percent));
|
2001-11-07 08:24:56 +00:00
|
|
|
cls.downloadpercent = percent;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
SZ_Print (&cls.netchan.message, "nextdl");
|
|
|
|
} else {
|
2007-03-20 14:16:43 +00:00
|
|
|
CL_FinishDownload ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static byte *upload_data;
|
2002-07-03 05:40:33 +00:00
|
|
|
static int upload_pos, upload_size;
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_NextUpload (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
byte buffer[1024];
|
|
|
|
int percent, size, r;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (!upload_data)
|
|
|
|
return;
|
|
|
|
|
|
|
|
r = upload_size - upload_pos;
|
|
|
|
if (r > 768)
|
|
|
|
r = 768;
|
|
|
|
memcpy (buffer, upload_data + upload_pos, r);
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_upload);
|
|
|
|
MSG_WriteShort (&cls.netchan.message, r);
|
|
|
|
|
|
|
|
upload_pos += r;
|
|
|
|
size = upload_size;
|
|
|
|
if (!size)
|
|
|
|
size = 1;
|
|
|
|
percent = upload_pos * 100 / size;
|
|
|
|
MSG_WriteByte (&cls.netchan.message, percent);
|
|
|
|
SZ_Write (&cls.netchan.message, buffer, r);
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "UPLOAD: %6d: %d written\n", upload_pos - r, r);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (upload_pos != upload_size)
|
|
|
|
return;
|
|
|
|
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Upload completed\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
free (upload_data);
|
|
|
|
upload_data = 0;
|
|
|
|
upload_pos = upload_size = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_StartUpload (byte * data, int size)
|
|
|
|
{
|
|
|
|
if (cls.state < ca_onserver)
|
2002-07-03 05:40:33 +00:00
|
|
|
return; // must be connected
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// override
|
|
|
|
if (upload_data)
|
|
|
|
free (upload_data);
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Upload starting of %d...\n", size);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
upload_data = malloc (size);
|
|
|
|
memcpy (upload_data, data, size);
|
|
|
|
upload_size = size;
|
|
|
|
upload_pos = 0;
|
|
|
|
|
|
|
|
CL_NextUpload ();
|
|
|
|
}
|
|
|
|
|
|
|
|
qboolean
|
|
|
|
CL_IsUploading (void)
|
|
|
|
{
|
|
|
|
if (upload_data)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_StopUpload (void)
|
|
|
|
{
|
|
|
|
if (upload_data)
|
|
|
|
free (upload_data);
|
|
|
|
upload_data = NULL;
|
|
|
|
}
|
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
// SERVER CONNECTING MESSAGES =================================================
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2002-11-05 19:12:51 +00:00
|
|
|
// LordHavoc: BIG BUG-FIX! Clear baselines each time it connects...
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-11-05 19:12:51 +00:00
|
|
|
CL_ClearBaselines (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2012-07-01 02:36:47 +00:00
|
|
|
i = qw_entstates.num_entities;
|
|
|
|
memset (qw_entstates.baseline, 0, i * sizeof (entity_state_t));
|
2002-11-05 19:12:51 +00:00
|
|
|
for (i = 0; i < MAX_EDICTS; i++) {
|
2012-07-01 02:36:47 +00:00
|
|
|
qw_entstates.baseline[i].colormod = 255;
|
|
|
|
qw_entstates.baseline[i].alpha = 255;
|
|
|
|
qw_entstates.baseline[i].scale = 16;
|
|
|
|
qw_entstates.baseline[i].glow_size = 0;
|
|
|
|
qw_entstates.baseline[i].glow_color = 254;
|
2002-11-05 19:12:51 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseServerData (void)
|
|
|
|
{
|
2001-11-07 08:24:56 +00:00
|
|
|
const char *str;
|
2002-07-03 05:40:33 +00:00
|
|
|
int protover;
|
2011-06-19 01:48:02 +00:00
|
|
|
//FIXME qboolean cflag = false;
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Serverdata packet received.\n");
|
2001-11-05 20:13:27 +00:00
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// wipe the client_state_t struct
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ClearState ();
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// parse protocol version number
|
|
|
|
// allow 2.2 and 2.29 demos to play
|
2001-11-07 08:24:56 +00:00
|
|
|
protover = MSG_ReadLong (net_message);
|
2002-07-03 05:40:33 +00:00
|
|
|
if (protover != PROTOCOL_VERSION
|
2011-03-17 10:58:56 +00:00
|
|
|
&& !(cls.demoplayback && (protover <= 26 || protover >= 28)))
|
2002-07-03 05:40:33 +00:00
|
|
|
Host_Error ("Server returned version %i, not %i\nYou probably "
|
|
|
|
"need to upgrade.\nCheck http://www.quakeworld.net/",
|
|
|
|
protover, PROTOCOL_VERSION);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.servercount = MSG_ReadLong (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// game directory
|
2001-11-07 08:24:56 +00:00
|
|
|
str = MSG_ReadString (net_message);
|
|
|
|
|
2003-02-14 22:36:10 +00:00
|
|
|
if (!strequal (qfs_gamedir->gamedir, str)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// save current config
|
|
|
|
Host_WriteConfiguration ();
|
2011-06-19 01:48:02 +00:00
|
|
|
//FIXME cflag = true;
|
2007-03-24 10:38:16 +00:00
|
|
|
QFS_Gamedir (str);
|
2003-03-11 05:58:06 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-10-02 21:56:45 +00:00
|
|
|
if (cls.demoplayback2) {
|
|
|
|
realtime = cls.basetime = MSG_ReadFloat (net_message);
|
|
|
|
cl.playernum = 31;
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.spectator = true;
|
2002-10-02 21:56:45 +00:00
|
|
|
} else {
|
|
|
|
// parse player slot, high bit means spectator
|
|
|
|
cl.playernum = MSG_ReadByte (net_message);
|
|
|
|
if (cl.playernum & 128) {
|
|
|
|
cl.spectator = true;
|
|
|
|
cl.playernum &= ~128;
|
|
|
|
}
|
2001-10-25 23:26:33 +00:00
|
|
|
}
|
2001-03-27 22:30:25 +00:00
|
|
|
|
|
|
|
cl.viewentity = cl.playernum + 1;
|
2022-02-25 06:48:57 +00:00
|
|
|
cl.viewstate.bob_enabled = !cl.spectator;
|
2022-11-12 19:04:27 +00:00
|
|
|
Sbar_SetPlayerNum (cl.playernum, cl.spectator);
|
2001-03-27 22:30:25 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// get the full level name
|
2001-11-07 08:24:56 +00:00
|
|
|
str = MSG_ReadString (net_message);
|
|
|
|
strncpy (cl.levelname, str, sizeof (cl.levelname) - 1);
|
2022-11-09 03:50:05 +00:00
|
|
|
Sbar_SetLevelName (cl.levelname, cls.servername->str);
|
2022-11-12 19:04:27 +00:00
|
|
|
Sbar_SetGameType (1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// get the movevars
|
2001-11-07 08:24:56 +00:00
|
|
|
movevars.gravity = MSG_ReadFloat (net_message);
|
2022-03-29 04:46:11 +00:00
|
|
|
CL_ParticlesGravity (movevars.gravity);// Gravity for renderer effects
|
2001-11-07 08:24:56 +00:00
|
|
|
movevars.stopspeed = MSG_ReadFloat (net_message);
|
|
|
|
movevars.maxspeed = MSG_ReadFloat (net_message);
|
|
|
|
movevars.spectatormaxspeed = MSG_ReadFloat (net_message);
|
|
|
|
movevars.accelerate = MSG_ReadFloat (net_message);
|
|
|
|
movevars.airaccelerate = MSG_ReadFloat (net_message);
|
|
|
|
movevars.wateraccelerate = MSG_ReadFloat (net_message);
|
|
|
|
movevars.friction = MSG_ReadFloat (net_message);
|
|
|
|
movevars.waterfriction = MSG_ReadFloat (net_message);
|
|
|
|
movevars.entgravity = MSG_ReadFloat (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-17 16:18:34 +00:00
|
|
|
// separate the printfs so the server message can have a color
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
2001-08-28 23:05:45 +00:00
|
|
|
"\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("%c%s\n", 2, str);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// ask for the sound list next
|
|
|
|
memset (cl.sound_name, 0, sizeof (cl.sound_name));
|
2002-10-05 04:52:09 +00:00
|
|
|
if (!cls.demoplayback) {
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, soundlist_name, cl.servercount, 0));
|
2002-10-05 04:52:09 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// now waiting for downloads, etc
|
2001-08-19 03:51:52 +00:00
|
|
|
CL_SetState (ca_onserver);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
CL_ClearBaselines ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseSoundlist (void)
|
|
|
|
{
|
2001-10-18 04:44:58 +00:00
|
|
|
const char *str;
|
2012-01-09 07:22:39 +00:00
|
|
|
int n;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// precache sounds
|
2003-03-21 21:25:44 +00:00
|
|
|
// memset (cl.sound_precache, 0, sizeof (cl.sound_precache));
|
2001-11-07 08:24:56 +00:00
|
|
|
|
2012-01-09 07:22:39 +00:00
|
|
|
cl.numsounds = MSG_ReadByte (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
for (;;) {
|
|
|
|
str = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!str[0])
|
|
|
|
break;
|
2012-01-09 07:22:39 +00:00
|
|
|
cl.numsounds++;
|
|
|
|
if (cl.numsounds >= MAX_SOUNDS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("Server sent too many sound_precache");
|
2012-01-09 07:22:39 +00:00
|
|
|
strcpy (cl.sound_name[cl.numsounds], str);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2012-06-26 02:06:59 +00:00
|
|
|
cl.numsounds++;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
n = MSG_ReadByte (net_message);
|
|
|
|
|
2002-10-05 04:52:09 +00:00
|
|
|
if (n && !cls.demoplayback) {
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, soundlist_name, cl.servercount, n));
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.downloadnumber = 0;
|
|
|
|
cls.downloadtype = dl_sound;
|
|
|
|
Sound_NextDownload ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseModellist (void)
|
|
|
|
{
|
2012-01-09 07:22:39 +00:00
|
|
|
int n;
|
2001-10-18 04:44:58 +00:00
|
|
|
const char *str;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// precache models and note certain default indexes
|
2012-01-09 07:22:39 +00:00
|
|
|
cl.nummodels = MSG_ReadByte (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
for (;;) {
|
|
|
|
str = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!str[0])
|
|
|
|
break;
|
2012-01-09 07:22:39 +00:00
|
|
|
cl.nummodels++;
|
|
|
|
if (cl.nummodels >= MAX_MODELS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("Server sent too many model_precache");
|
2012-01-09 07:22:39 +00:00
|
|
|
strcpy (cl.model_name[cl.nummodels], str);
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
if (!strcmp (cl.model_name[cl.nummodels], "progs/player.mdl"))
|
2012-01-09 07:22:39 +00:00
|
|
|
cl_playerindex = cl.nummodels;
|
|
|
|
else if (!strcmp (cl.model_name[cl.nummodels], "progs/flag.mdl"))
|
|
|
|
cl_flagindex = cl.nummodels;
|
2002-08-27 04:47:49 +00:00
|
|
|
// for deadbodyfilter & gib filter
|
2012-01-09 07:22:39 +00:00
|
|
|
else if (!strcmp (cl.model_name[cl.nummodels], "progs/h_player.mdl"))
|
|
|
|
cl_h_playerindex = cl.nummodels;
|
|
|
|
else if (!strcmp (cl.model_name[cl.nummodels], "progs/gib1.mdl"))
|
|
|
|
cl_gib1index = cl.nummodels;
|
|
|
|
else if (!strcmp (cl.model_name[cl.nummodels], "progs/gib2.mdl"))
|
|
|
|
cl_gib2index = cl.nummodels;
|
|
|
|
else if (!strcmp (cl.model_name[cl.nummodels], "progs/gib3.mdl"))
|
|
|
|
cl_gib3index = cl.nummodels;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2012-01-12 02:28:25 +00:00
|
|
|
cl.nummodels++;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
n = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (n) {
|
2002-10-07 03:58:08 +00:00
|
|
|
if (!cls.demoplayback) {
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, modellist_name, cl.servercount, n));
|
2002-10-07 03:58:08 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.downloadnumber = 0;
|
|
|
|
cls.downloadtype = dl_model;
|
|
|
|
Model_NextDownload ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseStaticSound (void)
|
|
|
|
{
|
2022-06-03 07:54:57 +00:00
|
|
|
int sound_num;
|
|
|
|
float vol, atten;
|
2022-03-30 14:38:01 +00:00
|
|
|
vec4f_t org = { 0, 0, 0, 1 };
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-03-30 14:38:01 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&org);//FIXME
|
2001-11-07 08:24:56 +00:00
|
|
|
sound_num = MSG_ReadByte (net_message);
|
2022-06-03 07:54:57 +00:00
|
|
|
vol = MSG_ReadByte (net_message) / 255.0;
|
|
|
|
atten = MSG_ReadByte (net_message) / 64.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
S_StaticSound (cl.sound_precache[sound_num], org, vol, atten);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
// ACTION MESSAGES ============================================================
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_ParseStartSoundPacket (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
float attenuation;
|
2012-06-26 01:51:11 +00:00
|
|
|
int bits, channel, ent, sound_num, volume;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-26 01:51:11 +00:00
|
|
|
bits = MSG_ReadShort (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-26 01:51:11 +00:00
|
|
|
if (bits & SND_VOLUME)
|
2001-11-07 08:24:56 +00:00
|
|
|
volume = MSG_ReadByte (net_message);
|
|
|
|
else
|
|
|
|
volume = DEFAULT_SOUND_PACKET_VOLUME;
|
|
|
|
|
2012-06-26 01:51:11 +00:00
|
|
|
if (bits & SND_ATTENUATION)
|
2001-11-07 08:24:56 +00:00
|
|
|
attenuation = MSG_ReadByte (net_message) / 64.0;
|
|
|
|
else
|
|
|
|
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
|
|
|
|
|
|
|
|
sound_num = MSG_ReadByte (net_message);
|
|
|
|
|
2022-03-30 14:38:01 +00:00
|
|
|
vec4f_t pos = { 0, 0, 0, 1 };
|
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&pos);//FIXME
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-26 01:51:11 +00:00
|
|
|
ent = (bits >> 3) & 1023;
|
|
|
|
channel = bits & 7;
|
2001-11-07 08:24:56 +00:00
|
|
|
|
|
|
|
if (ent > MAX_EDICTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseStartSoundPacket: ent = %i", ent);
|
2001-11-07 08:24:56 +00:00
|
|
|
|
|
|
|
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos,
|
|
|
|
volume / 255.0, attenuation);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_ParseClientdata
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
Server information pertaining to only this client, sent every frame
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_ParseClientdata (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
float latency;
|
|
|
|
frame_t *frame;
|
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// calculate simulated time of message
|
2001-02-19 21:15:25 +00:00
|
|
|
oldparsecountmod = parsecountmod;
|
|
|
|
|
|
|
|
i = cls.netchan.incoming_acknowledged;
|
2002-10-02 21:56:45 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.parsecount = i;
|
|
|
|
i &= UPDATE_MASK;
|
|
|
|
parsecountmod = i;
|
|
|
|
frame = &cl.frames[i];
|
2002-10-02 21:56:45 +00:00
|
|
|
if (cls.demoplayback2)
|
2004-02-09 04:16:59 +00:00
|
|
|
frame->senttime = realtime - host_frametime; //realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
parsecounttime = cl.frames[i].senttime;
|
|
|
|
|
|
|
|
frame->receivedtime = realtime;
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// calculate latency
|
2001-02-19 21:15:25 +00:00
|
|
|
latency = frame->receivedtime - frame->senttime;
|
|
|
|
|
2002-07-02 21:37:22 +00:00
|
|
|
if (!(latency < 0 || latency > 1.0)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// drift the average latency towards the observed latency
|
|
|
|
if (latency < cls.latency)
|
|
|
|
cls.latency = latency;
|
|
|
|
else
|
2001-05-19 23:31:20 +00:00
|
|
|
cls.latency += 0.001; // drift up, so correction is needed
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ProcessUserInfo (int slot, player_info_t *player)
|
|
|
|
{
|
2004-04-04 02:34:05 +00:00
|
|
|
char skin[MAX_SKIN_LENGTH] = { 0 };
|
2001-11-04 19:06:50 +00:00
|
|
|
const char *s;
|
|
|
|
|
|
|
|
s = Info_ValueForKey (player->userinfo, "skin");
|
2004-04-04 02:34:05 +00:00
|
|
|
|
|
|
|
if (strlen(s) < sizeof skin) {
|
|
|
|
QFS_StripExtension (s, skin);
|
|
|
|
if (!strequal (s, skin))
|
|
|
|
Info_SetValueForKey (player->userinfo, "skin", skin, 1);
|
|
|
|
} else {
|
2001-11-04 19:06:50 +00:00
|
|
|
Info_SetValueForKey (player->userinfo, "skin", skin, 1);
|
2004-04-04 02:34:05 +00:00
|
|
|
}
|
|
|
|
|
2012-05-21 14:04:47 +00:00
|
|
|
while (!(player->name = Info_Key (player->userinfo, "name"))) {
|
|
|
|
if (player->userid)
|
|
|
|
Info_SetValueForKey (player->userinfo, "name",
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, "user-%i [exploit]",
|
|
|
|
player->userid), 1);
|
2012-05-21 14:04:47 +00:00
|
|
|
else
|
|
|
|
Info_SetValueForKey (player->userinfo, "name", "", 1);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
player->topcolor = atoi (Info_ValueForKey (player->userinfo, "topcolor"));
|
|
|
|
player->bottomcolor =
|
|
|
|
atoi (Info_ValueForKey (player->userinfo, "bottomcolor"));
|
2001-11-04 19:06:50 +00:00
|
|
|
|
2012-05-21 13:50:59 +00:00
|
|
|
while (!(player->team = Info_Key (player->userinfo, "team")))
|
2001-11-04 19:06:50 +00:00
|
|
|
Info_SetValueForKey (player->userinfo, "team", "", 1);
|
2012-05-21 13:50:59 +00:00
|
|
|
while (!(player->skinname = Info_Key (player->userinfo, "skin")))
|
2001-11-04 19:06:50 +00:00
|
|
|
Info_SetValueForKey (player->userinfo, "skin", "", 1);
|
2012-06-29 08:59:30 +00:00
|
|
|
while (!(player->chat = Info_Key (player->userinfo, "chat")))
|
|
|
|
Info_SetValueForKey (player->userinfo, "chat", "0", 1);
|
2001-11-04 19:06:50 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Info_ValueForKey (player->userinfo, "*spectator")[0])
|
|
|
|
player->spectator = true;
|
|
|
|
else
|
|
|
|
player->spectator = false;
|
|
|
|
|
2012-02-14 12:25:19 +00:00
|
|
|
mod_funcs->Skin_SetTranslation (slot + 1, player->topcolor,
|
|
|
|
player->bottomcolor);
|
|
|
|
player->skin = mod_funcs->Skin_SetSkin (player->skin, slot + 1,
|
|
|
|
player->skinname->value);
|
|
|
|
player->skin = mod_funcs->Skin_SetColormap (player->skin, slot + 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-11-09 10:41:59 +00:00
|
|
|
Sbar_UpdateInfo (slot);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_UpdateUserinfo (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
int slot, uid;
|
|
|
|
const char *info;
|
|
|
|
player_info_t *player;
|
2001-10-18 07:01:40 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
slot = MSG_ReadByte (net_message);
|
|
|
|
if (slot >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error
|
2001-11-07 08:24:56 +00:00
|
|
|
("CL_ParseServerMessage: svc_updateuserinfo > MAX_SCOREBOARD");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
player = &cl.players[slot];
|
2002-02-13 17:52:53 +00:00
|
|
|
uid = MSG_ReadLong (net_message);
|
|
|
|
info = MSG_ReadString (net_message);
|
|
|
|
if (*info) {
|
|
|
|
// a totally empty userinfo string should not be possible
|
|
|
|
player->userid = uid;
|
2003-07-18 06:27:26 +00:00
|
|
|
if (player->userinfo)
|
|
|
|
Info_Destroy (player->userinfo);
|
2003-02-19 17:39:21 +00:00
|
|
|
player->userinfo = Info_ParseString (info, MAX_INFO_STRING, 0);
|
2002-02-13 17:52:53 +00:00
|
|
|
CL_ProcessUserInfo (slot, player);
|
2003-07-18 06:27:26 +00:00
|
|
|
CL_Chat_Check_Name (Info_ValueForKey (player->userinfo, "name"), slot);
|
2002-02-13 17:52:53 +00:00
|
|
|
} else {
|
|
|
|
// the server dropped the client
|
2003-07-18 06:27:26 +00:00
|
|
|
CL_Chat_User_Disconnected (player->userid);
|
|
|
|
if (player->userinfo)
|
|
|
|
Info_Destroy (player->userinfo);
|
2002-02-13 17:52:53 +00:00
|
|
|
memset (player, 0, sizeof (*player));
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_SetInfo (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char key[MAX_MSGLEN], value[MAX_MSGLEN];
|
|
|
|
int flags, slot;
|
|
|
|
player_info_t *player;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
slot = MSG_ReadByte (net_message);
|
|
|
|
if (slot >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: svc_setinfo > MAX_SCOREBOARD");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
player = &cl.players[slot];
|
|
|
|
|
|
|
|
strncpy (key, MSG_ReadString (net_message), sizeof (key) - 1);
|
|
|
|
key[sizeof (key) - 1] = 0;
|
|
|
|
strncpy (value, MSG_ReadString (net_message), sizeof (value) - 1);
|
|
|
|
key[sizeof (value) - 1] = 0;
|
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
if (!player->userinfo)
|
2003-02-19 17:39:21 +00:00
|
|
|
player->userinfo = Info_ParseString ("", MAX_INFO_STRING, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
flags = !strequal (key, "name");
|
|
|
|
flags |= strequal (key, "team") << 1;
|
|
|
|
Info_SetValueForKey (player->userinfo, key, value, flags);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_ProcessUserInfo (slot, player);
|
2012-05-21 14:04:47 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "SETINFO %s: %s=%s\n", player->name->value, key,
|
2012-05-21 14:04:47 +00:00
|
|
|
value);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_ServerInfo (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char key[MAX_MSGLEN], value[MAX_MSGLEN];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
strncpy (key, MSG_ReadString (net_message), sizeof (key) - 1);
|
|
|
|
key[sizeof (key) - 1] = 0;
|
|
|
|
strncpy (value, MSG_ReadString (net_message), sizeof (value) - 1);
|
|
|
|
key[sizeof (value) - 1] = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "SERVERINFO: %s=%s\n", key, value);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
Info_SetValueForKey (cl.serverinfo, key, value, 0);
|
|
|
|
if (strequal (key, "chase")) {
|
2022-02-25 06:48:57 +00:00
|
|
|
cl.viewstate.chase = atoi (value);
|
2001-11-11 07:02:38 +00:00
|
|
|
} else if (strequal (key, "cshifts")) {
|
|
|
|
cl.sv_cshifts = atoi (value);
|
|
|
|
} else if (strequal (key, "no_pogo_stick")) {
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Set ("no_pogo_stick", value);
|
|
|
|
cl.no_pogo_stick = no_pogo_stick;
|
2001-11-11 07:02:38 +00:00
|
|
|
} else if (strequal (key, "teamplay")) {
|
|
|
|
cl.teamplay = atoi (value);
|
2022-11-09 03:50:05 +00:00
|
|
|
Sbar_SetTeamplay (cl.teamplay);
|
2001-11-07 08:24:56 +00:00
|
|
|
} else if (strequal (key, "watervis")) {
|
2022-11-02 06:08:09 +00:00
|
|
|
cl.viewstate.watervis = atoi (value);
|
2004-07-11 01:41:01 +00:00
|
|
|
} else if (strequal (key, "fpd")) {
|
|
|
|
cl.fpd = atoi (value);
|
|
|
|
} else if (strequal (key, "fbskins")) {
|
|
|
|
cl.fbskins = atoi (value);
|
2003-07-27 23:20:11 +00:00
|
|
|
// } else if (strequal (key, "*z_ext") {
|
|
|
|
// cl.z_ext = atoi (value);
|
|
|
|
// } else if (strequal (key, "pm_bunnyspeedcap") {
|
|
|
|
// cl.bunnyspeedcap = atof (value);
|
|
|
|
// } else if (strequal (key, "pm_slidefix") {
|
|
|
|
// movevars.slidefix = atoi (value);
|
|
|
|
// } else if (strequal (key, "pm_ktjump") {
|
|
|
|
// movevars.ktjump = atof (value);
|
|
|
|
// FIXME: need to set to 0.5 otherwise, outside of else structure
|
2001-10-01 01:51:36 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_SetStat (int stat, int value)
|
|
|
|
{
|
|
|
|
if (stat < 0 || stat >= MAX_CL_STATS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_SetStat: %i is invalid", stat);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-10-02 21:56:45 +00:00
|
|
|
if (cls.demoplayback2) {
|
|
|
|
cl.players[cls.lastto].stats[stat] = value;
|
|
|
|
if (Cam_TrackNum () != cls.lastto)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
switch (stat) {
|
2002-08-24 05:14:46 +00:00
|
|
|
case STAT_ITEMS:
|
2022-02-25 06:48:57 +00:00
|
|
|
#define IT_POWER (IT_QUAD | IT_SUIT | IT_INVULNERABILITY | IT_INVISIBILITY)
|
|
|
|
cl.viewstate.powerup_index = (cl.stats[STAT_ITEMS]&IT_POWER) >> 19;
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
case STAT_HEALTH:
|
2003-01-03 04:30:38 +00:00
|
|
|
if (cl_player_health_e->func)
|
2021-01-31 07:01:20 +00:00
|
|
|
GIB_Event_Callback (cl_player_health_e, 1,
|
|
|
|
va (0, "%i", value));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (value <= 0)
|
|
|
|
Team_Dead ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cl.stats[stat] = value;
|
2022-03-04 16:48:10 +00:00
|
|
|
cl.viewstate.weapon_model = cl_world.models.a[cl.stats[STAT_WEAPON]];
|
2022-11-02 00:52:35 +00:00
|
|
|
if (cl.stdver) {
|
|
|
|
cl.viewstate.height = cl.stats[STAT_VIEWHEIGHT];
|
|
|
|
} else {
|
|
|
|
cl.viewstate.height = DEFAULT_VIEWHEIGHT; // view height
|
|
|
|
}
|
2022-11-09 10:41:59 +00:00
|
|
|
Sbar_UpdateStats (stat);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2021-03-11 06:23:35 +00:00
|
|
|
CL_ParseMuzzleFlash (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-11 06:23:35 +00:00
|
|
|
//FIXME this should just enable the effect on the relevant entity and
|
|
|
|
//then automatic entity updates take care of the rest
|
2002-07-03 05:40:33 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
player_state_t *pl;
|
2021-03-11 06:23:35 +00:00
|
|
|
vec3_t f, r, u;
|
|
|
|
vec4f_t position = { 0, 0, 0, 1}, fv = {};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
i = MSG_ReadShort (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if ((unsigned int) (i - 1) >= MAX_CLIENTS)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2005-04-27 09:54:37 +00:00
|
|
|
pl = &cl.frames[parsecountmod].playerstate[i - 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-06 00:27:41 +00:00
|
|
|
if (i - 1 == cl.playernum)
|
2022-03-01 02:43:23 +00:00
|
|
|
AngleVectors (cl.viewstate.player_angles, f, r, u);
|
2001-08-06 00:27:41 +00:00
|
|
|
else
|
2021-03-11 06:23:35 +00:00
|
|
|
AngleVectors (pl->viewangles, f, r, u);
|
|
|
|
|
|
|
|
VectorCopy (f, fv);
|
|
|
|
VectorCopy (pl->pls.es.origin, position);
|
|
|
|
CL_MuzzleFlash (position, fv, 0, i, cl.time);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
#define SHOWNET(x) \
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cl_shownet == 2) \
|
2011-08-28 12:05:35 +00:00
|
|
|
Sys_Printf ("%3i:%s\n", net_message->readcount - 1, x);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
int received_framecount;
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_ParseServerMessage (void)
|
|
|
|
{
|
2012-05-26 01:39:42 +00:00
|
|
|
int cmd = 0, i, j;
|
2022-11-09 10:41:59 +00:00
|
|
|
int update_pings = 0;
|
2011-08-27 01:25:41 +00:00
|
|
|
const char *str;
|
2002-04-19 06:26:08 +00:00
|
|
|
static dstring_t *stuffbuf;
|
2021-03-10 09:00:16 +00:00
|
|
|
TEntContext_t tentCtx = {
|
2022-03-04 16:48:10 +00:00
|
|
|
cl.viewstate.player_origin, cl.viewentity
|
2021-03-10 09:00:16 +00:00
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
received_framecount = host_framecount;
|
2022-11-02 06:08:09 +00:00
|
|
|
cl.viewstate.last_servermessage = realtime;
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ClearProjectiles ();
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// if recording demos, copy the message out
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cl_shownet == 1)
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("%i ", net_message->message->cursize);
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
else if (cl_shownet == 2)
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("------------------ %d\n",
|
2005-04-27 09:54:37 +00:00
|
|
|
cls.netchan.incoming_acknowledged);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
CL_ParseClientdata ();
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// parse the message
|
2001-02-19 21:15:25 +00:00
|
|
|
while (1) {
|
2011-08-28 12:05:35 +00:00
|
|
|
if (net_message->badread)
|
2002-10-06 04:30:50 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: Bad server message: %s\n",
|
|
|
|
svc_strings[cmd]);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
cmd = MSG_ReadByte (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cmd == -1) {
|
2004-03-05 23:42:15 +00:00
|
|
|
net_message->readcount++; // so the EOM SHOWNET has the right
|
2001-11-07 08:24:56 +00:00
|
|
|
// value
|
|
|
|
SHOWNET ("END OF MESSAGE");
|
2011-08-28 12:05:35 +00:00
|
|
|
break; // end of message
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2021-01-31 07:01:20 +00:00
|
|
|
SHOWNET (va (0, "%s(%d)", svc_strings[cmd], cmd));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// other commands
|
|
|
|
switch (cmd) {
|
|
|
|
default:
|
2002-10-02 21:56:45 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: Illegible server "
|
|
|
|
"message: %d\n", cmd);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nop:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_disconnect:
|
|
|
|
if (cls.state == ca_connected)
|
|
|
|
Host_EndGame ("Server disconnected\n"
|
|
|
|
"Server version may not be compatible");
|
|
|
|
else
|
2012-05-26 02:13:57 +00:00
|
|
|
Host_EndGame ("Server disconnected\n");
|
2001-11-07 08:24:56 +00:00
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
case svc_updatestat:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
j = MSG_ReadByte (net_message);
|
|
|
|
CL_SetStat (i, j);
|
|
|
|
break;
|
|
|
|
|
|
|
|
// svc_version
|
|
|
|
// svc_setview
|
|
|
|
|
|
|
|
case svc_sound:
|
|
|
|
CL_ParseStartSoundPacket ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
// svc_time
|
|
|
|
|
2011-08-28 12:05:35 +00:00
|
|
|
case svc_print:
|
|
|
|
{
|
2011-06-19 11:02:00 +00:00
|
|
|
dstring_t *p = 0;
|
2002-07-03 05:40:33 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
i = MSG_ReadByte (net_message);
|
2011-08-27 01:25:41 +00:00
|
|
|
str = MSG_ReadString (net_message);
|
2001-11-07 08:24:56 +00:00
|
|
|
if (i == PRINT_CHAT) {
|
2011-08-27 01:25:41 +00:00
|
|
|
if (!CL_Chat_Allow_Message (str))
|
2003-07-18 06:27:26 +00:00
|
|
|
break;
|
2001-11-07 08:24:56 +00:00
|
|
|
// TODO: cl_nofake 2 -- accept fake messages from teammates
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (cl_nofake) {
|
2002-07-03 05:40:33 +00:00
|
|
|
char *c;
|
|
|
|
|
2011-08-27 01:25:41 +00:00
|
|
|
p = dstring_strdup (str);
|
2011-06-19 11:02:00 +00:00
|
|
|
for (c = p->str; *c; c++) {
|
2001-11-07 08:24:56 +00:00
|
|
|
if (*c == '\r')
|
|
|
|
*c = '#';
|
|
|
|
}
|
2011-08-27 01:25:41 +00:00
|
|
|
str = p->str;
|
2001-11-07 08:24:56 +00:00
|
|
|
}
|
2002-01-16 21:53:42 +00:00
|
|
|
Con_SetOrMask (128);
|
2001-11-07 08:24:56 +00:00
|
|
|
S_LocalSound ("misc/talk.wav");
|
2003-01-03 04:30:38 +00:00
|
|
|
if (cl_chat_e->func)
|
2011-08-27 01:25:41 +00:00
|
|
|
GIB_Event_Callback (cl_chat_e, 1, str);
|
|
|
|
Team_ParseChat (str);
|
2001-11-07 08:24:56 +00:00
|
|
|
}
|
2011-08-27 01:25:41 +00:00
|
|
|
Sys_Printf ("%s", str);
|
2011-06-19 11:02:00 +00:00
|
|
|
if (p)
|
|
|
|
dstring_delete (p);
|
2002-01-16 21:53:42 +00:00
|
|
|
Con_SetOrMask (0);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case svc_stufftext:
|
2011-08-27 01:25:41 +00:00
|
|
|
str = MSG_ReadString (net_message);
|
|
|
|
if (str[strlen (str) - 1] == '\n') {
|
2002-04-19 17:58:52 +00:00
|
|
|
if (stuffbuf && stuffbuf->str[0]) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "stufftext: %s%s\n",
|
2011-08-27 01:25:41 +00:00
|
|
|
stuffbuf->str, str);
|
2002-12-01 07:22:42 +00:00
|
|
|
Cbuf_AddText (cl_stbuf, stuffbuf->str);
|
2002-04-19 17:58:52 +00:00
|
|
|
dstring_clearstr (stuffbuf);
|
|
|
|
} else {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "stufftext: %s\n", str);
|
2002-04-19 17:58:52 +00:00
|
|
|
}
|
2011-08-27 01:25:41 +00:00
|
|
|
Cbuf_AddText (cl_stbuf, str);
|
2002-04-19 17:58:52 +00:00
|
|
|
} else {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "partial stufftext: %s\n", str);
|
2002-04-19 17:58:52 +00:00
|
|
|
if (!stuffbuf)
|
2003-03-21 21:25:44 +00:00
|
|
|
stuffbuf = dstring_newstr ();
|
2011-08-27 01:25:41 +00:00
|
|
|
dstring_appendstr (stuffbuf, str);
|
2002-04-19 06:26:08 +00:00
|
|
|
}
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_setangle:
|
2011-08-28 12:05:35 +00:00
|
|
|
{
|
2022-03-01 02:43:23 +00:00
|
|
|
vec_t *dest = cl.viewstate.player_angles;
|
2011-08-28 12:05:35 +00:00
|
|
|
vec3_t dummy;
|
|
|
|
|
|
|
|
if (cls.demoplayback2) {
|
2003-03-03 19:20:44 +00:00
|
|
|
j = MSG_ReadByte (net_message);
|
|
|
|
// fixangle |= 1 << j;
|
2011-08-28 12:05:35 +00:00
|
|
|
if (j != Cam_TrackNum ())
|
|
|
|
dest = dummy;
|
2002-10-02 21:56:45 +00:00
|
|
|
}
|
2011-08-28 12:05:35 +00:00
|
|
|
MSG_ReadAngleV (net_message, dest);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case svc_serverdata:
|
|
|
|
// make sure any stuffed commands are done
|
2012-05-26 02:31:23 +00:00
|
|
|
if (stuffbuf && stuffbuf->str[0]) {
|
|
|
|
Cbuf_AddText (cl_stbuf, stuffbuf->str);
|
|
|
|
dstring_clearstr (stuffbuf);
|
|
|
|
}
|
2011-08-28 12:05:35 +00:00
|
|
|
Cbuf_Execute_Stack (cl_stbuf);
|
|
|
|
CL_ParseServerData ();
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_lightstyle:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_LIGHTSTYLES)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("svc_lightstyle > MAX_LIGHTSTYLES");
|
2012-02-14 10:47:02 +00:00
|
|
|
strcpy (cl.lightstyle[i].map, MSG_ReadString (net_message));
|
|
|
|
cl.lightstyle[i].length = strlen (cl.lightstyle[i].map);
|
2012-05-26 02:06:21 +00:00
|
|
|
if (cl.lightstyle[i].length) {
|
|
|
|
int total = 0;
|
|
|
|
|
|
|
|
cl.lightstyle[i].peak = 'a';
|
|
|
|
for (j = 0; j < cl.lightstyle[i].length; j++) {
|
|
|
|
total += cl.lightstyle[i].map[j] - 'a';
|
|
|
|
cl.lightstyle[i].peak = max (cl.lightstyle[i].peak,
|
|
|
|
cl.lightstyle[i].map[j]);
|
|
|
|
}
|
|
|
|
total /= cl.lightstyle[i].length;
|
|
|
|
cl.lightstyle[i].average = total + 'a';
|
|
|
|
} else {
|
|
|
|
cl.lightstyle[i].average = 'm';
|
|
|
|
cl.lightstyle[i].peak = 'm';
|
|
|
|
}
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_updatename
|
2001-11-07 08:24:56 +00:00
|
|
|
|
|
|
|
case svc_updatefrags:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updatefrags > "
|
|
|
|
"MAX_SCOREBOARD");
|
2011-08-28 09:29:46 +00:00
|
|
|
cl.players[i].frags = (short) MSG_ReadShort (net_message);
|
2022-11-09 10:41:59 +00:00
|
|
|
Sbar_UpdateFrags (i);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_clientdata
|
|
|
|
|
|
|
|
case svc_stopsound:
|
|
|
|
i = MSG_ReadShort (net_message);
|
|
|
|
S_StopSound (i >> 3, i & 7);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_updatecolors
|
|
|
|
// svc_particle
|
|
|
|
|
|
|
|
case svc_damage:
|
2022-02-28 03:12:51 +00:00
|
|
|
V_ParseDamage (net_message, &cl.viewstate);
|
2022-02-25 06:48:57 +00:00
|
|
|
// put sbar face into pain frame
|
2022-11-09 03:50:05 +00:00
|
|
|
Sbar_Damage (cl.time);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
case svc_spawnstatic:
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_ParseStatic (net_message, 1);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_spawnbinary
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_spawnbaseline:
|
|
|
|
i = MSG_ReadShort (net_message);
|
2022-03-04 16:48:10 +00:00
|
|
|
CL_ParseBaseline (net_message, &qw_entstates.baseline[i], 1);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
2012-05-26 01:39:42 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_temp_entity:
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_ParseTEnt_qw (net_message, cl.time, &tentCtx);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2011-08-28 12:05:35 +00:00
|
|
|
case svc_setpause:
|
2012-02-14 10:47:02 +00:00
|
|
|
r_data->paused = cl.paused = MSG_ReadByte (net_message);
|
2011-08-28 12:05:35 +00:00
|
|
|
if (cl.paused)
|
|
|
|
CDAudio_Pause ();
|
|
|
|
else
|
|
|
|
CDAudio_Resume ();
|
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_signonnum
|
|
|
|
|
|
|
|
case svc_centerprint:
|
|
|
|
str = MSG_ReadString (net_message);
|
|
|
|
Sbar_CenterPrint (str);
|
|
|
|
break;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_killedmonster:
|
|
|
|
cl.stats[STAT_MONSTERS]++;
|
2022-11-09 16:35:33 +00:00
|
|
|
Sbar_UpdateStats (STAT_MONSTERS);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_foundsecret:
|
|
|
|
cl.stats[STAT_SECRETS]++;
|
2022-11-09 16:35:33 +00:00
|
|
|
Sbar_UpdateStats (STAT_SECRETS);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
case svc_spawnstaticsound:
|
|
|
|
CL_ParseStaticSound ();
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_intermission:
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "svc_intermission\n");
|
2002-03-14 15:43:08 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.intermission = 1;
|
2022-03-18 15:56:30 +00:00
|
|
|
SCR_SetFullscreen (1);
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.completed_time = realtime;
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "intermission simorg: ");
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&cl.viewstate.player_origin);//FIXME
|
2022-03-01 02:43:23 +00:00
|
|
|
cl.viewstate.player_origin[3] = 1;
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, VEC4F_FMT,
|
2022-03-01 02:43:23 +00:00
|
|
|
VEC4_EXP (cl.viewstate.player_origin));
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "\nintermission simangles: ");
|
2022-03-01 02:43:23 +00:00
|
|
|
MSG_ReadAngleV (net_message, cl.viewstate.player_angles);
|
|
|
|
cl.viewstate.player_angles[ROLL] = 0; // FIXME @@@
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "%f %f %f",
|
2022-03-01 02:43:23 +00:00
|
|
|
VectorExpand (cl.viewstate.player_angles));
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "\n");
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.velocity = (vec4f_t) { };
|
2002-03-14 15:43:08 +00:00
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
// automatic fraglogging (by elmex)
|
|
|
|
// XXX: Should this _really_ called here?
|
2002-07-02 21:37:22 +00:00
|
|
|
if (!cls.demoplayback)
|
2022-11-09 03:50:05 +00:00
|
|
|
Sbar_LogFrags (cl.time);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_finale:
|
|
|
|
cl.intermission = 2;
|
2022-03-18 15:56:30 +00:00
|
|
|
SCR_SetFullscreen (1);
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.completed_time = realtime;
|
2011-08-27 01:25:41 +00:00
|
|
|
str = MSG_ReadString (net_message);
|
|
|
|
Sbar_CenterPrint (str);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
case svc_cdtrack:
|
|
|
|
cl.cdtrack = MSG_ReadByte (net_message);
|
|
|
|
CDAudio_Play ((byte) cl.cdtrack, true);
|
|
|
|
break;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_sellscreen:
|
|
|
|
Cmd_ExecuteString ("help", src_command);
|
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
// svc_cutscene (same value as svc_smallkick)
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_smallkick:
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.punchangle = (vec4f_t) {
|
|
|
|
// -2 degrees pitch
|
|
|
|
0, -0.0174524064, 0, 0.999847695
|
|
|
|
};
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
2002-07-03 05:40:33 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_bigkick:
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.punchangle = (vec4f_t) {
|
|
|
|
// -4 degrees pitch
|
|
|
|
0, -0.0348994967, 0, 0.999390827
|
|
|
|
};
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
2012-05-26 01:39:42 +00:00
|
|
|
case svc_updateping:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updateping > "
|
|
|
|
"MAX_SCOREBOARD");
|
|
|
|
cl.players[i].ping = MSG_ReadShort (net_message);
|
2022-11-09 10:41:59 +00:00
|
|
|
update_pings = 1;
|
2012-05-26 01:39:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updateentertime:
|
|
|
|
// time is sent over as seconds ago
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updateentertime "
|
|
|
|
"> MAX_SCOREBOARD");
|
|
|
|
cl.players[i].entertime = realtime - MSG_ReadFloat
|
|
|
|
(net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updatestatlong:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
j = MSG_ReadLong (net_message);
|
|
|
|
CL_SetStat (i, j);
|
|
|
|
break;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_muzzleflash:
|
2021-03-11 06:23:35 +00:00
|
|
|
CL_ParseMuzzleFlash ();
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updateuserinfo:
|
|
|
|
CL_UpdateUserinfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_download:
|
|
|
|
CL_ParseDownload ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_playerinfo:
|
|
|
|
CL_ParsePlayerinfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nails:
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_ParseProjectiles (net_message, false, &tentCtx);
|
2002-10-02 21:56:45 +00:00
|
|
|
break;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_chokecount: // some preceding packets were choked
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
for (j = 0; j < i; j++)
|
2002-07-03 05:40:33 +00:00
|
|
|
cl.frames[(cls.netchan.incoming_acknowledged - 1 - j) &
|
|
|
|
UPDATE_MASK].receivedtime = -2;
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_modellist:
|
|
|
|
CL_ParseModellist ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_soundlist:
|
|
|
|
CL_ParseSoundlist ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_packetentities:
|
|
|
|
CL_ParsePacketEntities (false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_deltapacketentities:
|
|
|
|
CL_ParsePacketEntities (true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_maxspeed:
|
|
|
|
movevars.maxspeed = MSG_ReadFloat (net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_entgravity:
|
|
|
|
movevars.entgravity = MSG_ReadFloat (net_message);
|
|
|
|
break;
|
2012-05-26 01:39:42 +00:00
|
|
|
|
|
|
|
case svc_setinfo:
|
|
|
|
CL_SetInfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_serverinfo:
|
|
|
|
CL_ServerInfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updatepl:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updatepl > "
|
|
|
|
"MAX_SCOREBOARD");
|
|
|
|
cl.players[i].pl = MSG_ReadByte (net_message);
|
2022-11-09 10:41:59 +00:00
|
|
|
update_pings = 1;
|
2012-05-26 01:39:42 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nails2: // FIXME from qwex
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_ParseProjectiles (net_message, true, &tentCtx);
|
2012-05-26 01:39:42 +00:00
|
|
|
break;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-09 10:41:59 +00:00
|
|
|
if (update_pings) {
|
|
|
|
Sbar_UpdatePings ();
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
CL_SetSolidEntities ();
|
|
|
|
}
|