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
|
|
|
|
|
|
|
|
*/
|
2001-09-28 06:26:31 +00:00
|
|
|
static const char rcsid[] =
|
|
|
|
"$Id$";
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
#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"
|
2001-11-04 19:06:50 +00:00
|
|
|
#include "QF/hash.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "QF/msg.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"
|
|
|
|
#include "QF/sound.h"
|
|
|
|
#include "QF/teamplay.h"
|
|
|
|
#include "QF/va.h"
|
2002-04-19 06:26:08 +00:00
|
|
|
#include "QF/dstring.h"
|
2002-08-24 05:14:46 +00:00
|
|
|
#include "QF/gib_vars.h"
|
2002-08-27 04:47:49 +00:00
|
|
|
#include "QF/gib_thread.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
|
|
|
|
#include "bothdefs.h"
|
2002-10-02 21:56:45 +00:00
|
|
|
#include "cl_cam.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "cl_ents.h"
|
|
|
|
#include "cl_input.h"
|
|
|
|
#include "cl_main.h"
|
|
|
|
#include "cl_parse.h"
|
2001-05-11 22:47:15 +00:00
|
|
|
#include "cl_skin.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "cl_tent.h"
|
|
|
|
#include "client.h"
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "pmove.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
#include "sbar.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
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",
|
|
|
|
"svc_finale",
|
|
|
|
|
|
|
|
"svc_cdtrack",
|
|
|
|
"svc_sellscreen",
|
|
|
|
|
|
|
|
"svc_smallkick",
|
|
|
|
"svc_bigkick",
|
|
|
|
|
|
|
|
"svc_updateping",
|
|
|
|
"svc_updateentertime",
|
|
|
|
|
|
|
|
"svc_updatestatlong",
|
|
|
|
"svc_muzzleflash",
|
|
|
|
"svc_updateuserinfo",
|
|
|
|
"svc_download",
|
|
|
|
"svc_playerinfo",
|
|
|
|
"svc_nails",
|
|
|
|
"svc_choke",
|
|
|
|
"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;
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
int viewentity;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
int cl_spikeindex, cl_playerindex, cl_flagindex;
|
|
|
|
int cl_h_playerindex, cl_gib1index, cl_gib2index, cl_gib3index;
|
|
|
|
|
|
|
|
int packet_latency[NET_TIMINGS];
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2002-08-15 09:38:23 +00:00
|
|
|
extern cvar_t *cl_showscoresuid;
|
|
|
|
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
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];
|
|
|
|
if (frame->receivedtime == -1)
|
2002-07-03 05:40:33 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 9999; // dropped
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (frame->receivedtime == -2)
|
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 10000; // choked
|
|
|
|
else if (frame->invalid)
|
2002-07-03 05:40:33 +00:00
|
|
|
packet_latency[i & NET_TIMINGSMASK] = 9998; // invalid delta
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
|
|
|
packet_latency[i & NET_TIMINGSMASK] =
|
|
|
|
(frame->receivedtime - frame->senttime) * 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
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, "..")) {
|
|
|
|
Con_Printf ("Refusing to download a path with ..\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
COM_FOpenFile (filename, &f);
|
|
|
|
if (f) { // it exists, no need to download
|
|
|
|
Qclose (f);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// ZOID - can't download when recording
|
|
|
|
if (cls.demorecording) {
|
|
|
|
Con_Printf ("Unable to download %s in record mode.\n",
|
|
|
|
cls.downloadname);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
// ZOID - can't download when playback
|
|
|
|
if (cls.demoplayback)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
strcpy (cls.downloadname, filename);
|
|
|
|
Con_Printf ("Downloading %s...\n", cls.downloadname);
|
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
// download to a temp name, and only rename to the real name when done,
|
|
|
|
// so if interrupted a runt file wont be left
|
2001-02-19 21:15:25 +00:00
|
|
|
COM_StripExtension (cls.downloadname, cls.downloadtempname);
|
|
|
|
strncat (cls.downloadtempname, ".tmp",
|
|
|
|
sizeof (cls.downloadtempname) - strlen (cls.downloadtempname));
|
|
|
|
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2002-03-11 18:47:14 +00:00
|
|
|
va ("download \"%s\"", cls.downloadname));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cls.downloadnumber++;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2002-11-08 02:43:04 +00:00
|
|
|
static void
|
|
|
|
map_cfg (const char *mapname, int all)
|
2002-08-06 05:45:03 +00:00
|
|
|
{
|
|
|
|
char *name = malloc (strlen (mapname) + 4 + 1);
|
2002-11-08 02:43:04 +00:00
|
|
|
QFile *f;
|
|
|
|
|
|
|
|
COM_StripExtension (mapname, name);
|
|
|
|
strcat (name, ".cfg");
|
2002-11-08 03:27:05 +00:00
|
|
|
COM_FOpenFile (name, &f);
|
|
|
|
if (f) {
|
2002-11-08 02:43:04 +00:00
|
|
|
Qclose (f);
|
2002-11-08 16:39:28 +00:00
|
|
|
Cmd_Exec_File (cl_cbuf, name, 1);
|
2002-11-08 02:43:04 +00:00
|
|
|
} else {
|
2002-11-08 16:39:28 +00:00
|
|
|
Cmd_Exec_File (cl_cbuf, "maps_default.cfg", 1);
|
2002-11-08 02:43:04 +00:00
|
|
|
}
|
|
|
|
if (all)
|
|
|
|
Cbuf_Execute_Stack (cl_cbuf);
|
|
|
|
else
|
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
|
|
|
free (name);
|
|
|
|
}
|
2002-08-06 05:45:03 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-11-08 02:43:04 +00:00
|
|
|
CL_NewMap (const char *mapname)
|
|
|
|
{
|
2002-08-06 05:45:03 +00:00
|
|
|
R_NewMap (cl.worldmodel, cl.model_precache, MAX_MODELS);
|
|
|
|
Team_NewMap ();
|
|
|
|
Con_NewMap ();
|
|
|
|
Hunk_Check (); // make sure nothing is hurt
|
|
|
|
|
2002-11-08 02:43:04 +00:00
|
|
|
map_cfg (mapname, 1);
|
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) {
|
|
|
|
Con_Printf ("Checking models...\n");
|
2001-05-23 06:33:23 +00:00
|
|
|
CL_UpdateScreen (realtime);
|
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
|
|
|
}
|
|
|
|
|
2002-11-08 02:43:04 +00:00
|
|
|
if (cl.model_name[1])
|
|
|
|
map_cfg (cl.model_name[1], 0);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 1; i < MAX_MODELS; i++) {
|
2001-05-29 17:37:48 +00:00
|
|
|
char *info_key = 0;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cl.model_name[i][0])
|
|
|
|
break;
|
|
|
|
|
|
|
|
cl.model_precache[i] = Mod_ForName (cl.model_name[i], false);
|
|
|
|
|
|
|
|
if (!cl.model_precache[i]) {
|
2001-08-28 23:05:45 +00:00
|
|
|
Con_Printf ("\nThe required model file '%s' could not be found or "
|
|
|
|
"downloaded.\n\n", cl.model_name[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("You may need to download or purchase a %s client "
|
|
|
|
"pack in order to play on this server.\n\n",
|
|
|
|
gamedirfile);
|
|
|
|
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")
|
2002-09-13 05:32:28 +00:00
|
|
|
&& cl.model_precache[i]->type == mod_alias) {
|
2001-06-02 22:20:34 +00:00
|
|
|
info_key = pmodel_name;
|
2002-09-13 05:32:28 +00:00
|
|
|
Skin_Player_Model (cl.model_precache[i]);
|
|
|
|
}
|
2001-06-02 22:20:34 +00:00
|
|
|
if (strequal (cl.model_name[i], "progs/eyes.mdl")
|
|
|
|
&& cl.model_precache[i]->type == mod_alias)
|
|
|
|
info_key = emodel_name;
|
|
|
|
|
2001-06-02 23:29:41 +00:00
|
|
|
if (info_key && cl_model_crcs->int_val) {
|
2002-09-13 05:32:28 +00:00
|
|
|
aliashdr_t *ahdr = Cache_Get (&cl.model_precache[i]->cache);
|
2001-05-29 17:37:48 +00:00
|
|
|
Info_SetValueForKey (cls.userinfo, info_key, va ("%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);
|
|
|
|
SZ_Print (&cls.netchan.message, va ("setinfo %s %d", info_key,
|
|
|
|
ahdr->crc));
|
|
|
|
}
|
2001-08-31 12:22:45 +00:00
|
|
|
Cache_Release (&cl.model_precache[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.
|
|
|
|
if (!cl.model_precache[1]) {
|
|
|
|
Con_Printf ("\nThe server has failed to provide the map name.\n\n");
|
|
|
|
Con_Printf ("Disconnecting to prevent a crash.\n\n");
|
|
|
|
CL_Disconnect ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// all done
|
|
|
|
cl.worldmodel = cl.model_precache[1];
|
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,
|
|
|
|
va (prespawn_name, cl.servercount,
|
|
|
|
cl.worldmodel->checksum2));
|
|
|
|
}
|
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) {
|
|
|
|
Con_Printf ("Checking sounds...\n");
|
2001-05-23 06:33:23 +00:00
|
|
|
CL_UpdateScreen (realtime);
|
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];
|
|
|
|
if (!CL_CheckOrDownloadFile (va ("sound/%s", s)))
|
|
|
|
return; // started a download
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < MAX_SOUNDS; i++) {
|
|
|
|
if (!cl.sound_name[i][0])
|
|
|
|
break;
|
|
|
|
cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// done with sounds, request models now
|
|
|
|
memset (cl.model_precache, 0, sizeof (cl.model_precache));
|
|
|
|
cl_playerindex = -1;
|
|
|
|
cl_spikeindex = -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,
|
|
|
|
va (modellist_name, cl.servercount, 0));
|
|
|
|
}
|
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:
|
|
|
|
Con_DPrintf ("Unknown download type.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
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)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
byte name[1024];
|
|
|
|
int size, percent, r;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
// read the data
|
|
|
|
size = MSG_ReadShort (net_message);
|
|
|
|
percent = MSG_ReadByte (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (cls.demoplayback) {
|
|
|
|
if (size > 0)
|
|
|
|
net_message->readcount += size;
|
2002-01-23 19:01:19 +00:00
|
|
|
cls.downloadname[0] = 0;
|
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
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (size == -1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("File not found.\n");
|
|
|
|
if (cls.download) {
|
|
|
|
Con_Printf ("cls.download shouldn't have been set\n");
|
|
|
|
Qclose (cls.download);
|
|
|
|
cls.download = NULL;
|
|
|
|
}
|
2002-01-23 19:01:19 +00:00
|
|
|
cls.downloadname[0] = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (size == -2) {
|
2002-07-03 05:40:33 +00:00
|
|
|
const char *newname = MSG_ReadString (net_message);
|
2001-11-07 08:24:56 +00:00
|
|
|
|
|
|
|
if (strncmp (newname, cls.downloadname, strlen (cls.downloadname))
|
|
|
|
|| strstr (newname + strlen (cls.downloadname), "/")) {
|
|
|
|
Con_Printf
|
|
|
|
("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);
|
|
|
|
unlink (cls.downloadname);
|
|
|
|
}
|
2001-11-07 08:24:56 +00:00
|
|
|
strncpy (cls.downloadname, newname, sizeof (cls.downloadname));
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("downloading to %s\n", cls.downloadname);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// open the file if not opened yet
|
|
|
|
if (!cls.download) {
|
|
|
|
if (strncmp (cls.downloadtempname, "skins/", 6))
|
|
|
|
snprintf (name, sizeof (name), "%s/%s", com_gamedir,
|
|
|
|
cls.downloadtempname);
|
|
|
|
else
|
|
|
|
snprintf (name, sizeof (name), "%s/%s/%s", fs_userpath->string,
|
|
|
|
fs_skinbase->string, cls.downloadtempname);
|
|
|
|
|
|
|
|
COM_CreatePath (name);
|
|
|
|
|
|
|
|
cls.download = Qopen (name, "wb");
|
|
|
|
if (!cls.download) {
|
2002-01-23 19:01:19 +00:00
|
|
|
cls.downloadname[0] = 0;
|
2001-11-07 08:24:56 +00:00
|
|
|
net_message->readcount += size;
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Failed to open %s\n", cls.downloadtempname);
|
|
|
|
CL_RequestNextDownload ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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)
|
2001-05-19 23:31:20 +00:00
|
|
|
VID_SetCaption (va ("Downloading %s %d%%", cls.downloadname,
|
2001-11-07 08:24:56 +00:00
|
|
|
percent));
|
|
|
|
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 {
|
2002-07-03 05:40:33 +00:00
|
|
|
char oldn[MAX_OSPATH];
|
|
|
|
char newn[MAX_OSPATH];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Qclose (cls.download);
|
|
|
|
VID_SetCaption (va ("Connecting to %s", cls.servername));
|
|
|
|
|
|
|
|
// rename the temp file to it's final name
|
|
|
|
if (strcmp (cls.downloadtempname, cls.downloadname)) {
|
|
|
|
if (strncmp (cls.downloadtempname, "skins/", 6)) {
|
|
|
|
snprintf (oldn, sizeof (oldn), "%s/%s", com_gamedir,
|
|
|
|
cls.downloadtempname);
|
|
|
|
snprintf (newn, sizeof (newn), "%s/%s", com_gamedir,
|
|
|
|
cls.downloadname);
|
|
|
|
} else {
|
|
|
|
snprintf (oldn, sizeof (oldn), "%s/%s/%s", fs_userpath->string,
|
|
|
|
fs_skinbase->string, cls.downloadtempname);
|
|
|
|
snprintf (newn, sizeof (newn), "%s/%s/%s", fs_userpath->string,
|
|
|
|
fs_skinbase->string, cls.downloadname);
|
|
|
|
}
|
|
|
|
r = Qrename (oldn, newn);
|
|
|
|
if (r)
|
|
|
|
Con_Printf ("failed to rename, %s.\n", strerror (errno));
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.download = NULL;
|
2002-01-17 02:37:52 +00:00
|
|
|
cls.downloadname[0] = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.downloadpercent = 0;
|
|
|
|
|
|
|
|
// get another file if needed
|
|
|
|
CL_RequestNextDownload ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
Con_DPrintf ("UPLOAD: %6d: %d written\n", upload_pos - r, r);
|
|
|
|
|
|
|
|
if (upload_pos != upload_size)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Con_Printf ("Upload completed\n");
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
Con_DPrintf ("Upload starting of %d...\n", size);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
memset (cl_baselines, 0, sizeof (cl_baselines));
|
|
|
|
for (i = 0; i < MAX_EDICTS; i++) {
|
|
|
|
cl_baselines[i].colormod = 255;
|
|
|
|
cl_baselines[i].alpha = 255;
|
|
|
|
cl_baselines[i].scale = 16;
|
|
|
|
cl_baselines[i].glow_size = 0;
|
|
|
|
cl_baselines[i].glow_color = 254;
|
|
|
|
}
|
|
|
|
}
|
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)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char fn[MAX_OSPATH];
|
2001-11-07 08:24:56 +00:00
|
|
|
const char *str;
|
2002-07-03 05:40:33 +00:00
|
|
|
int protover;
|
|
|
|
qboolean cflag = false;
|
2001-05-19 23:31:20 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
Con_DPrintf ("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
|
|
|
|
&& !(cls.demoplayback && (protover <= 26 && protover >= 28)))
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (!strequal (gamedirfile, str)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
// save current config
|
|
|
|
Host_WriteConfiguration ();
|
|
|
|
cflag = true;
|
|
|
|
Draw_ClearCache ();
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
COM_Gamedir (str);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
// ZOID--run the autoexec.cfg in the gamedir if it exists
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cflag) {
|
2001-10-03 21:25:43 +00:00
|
|
|
int cmd_warncmd_val = cmd_warncmd->int_val;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, "cmd_warncmd 0\n");
|
|
|
|
Cbuf_AddText (cl_cbuf, "exec config.cfg\n");
|
|
|
|
Cbuf_AddText (cl_cbuf, "exec frontend.cfg\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl_autoexec->int_val) {
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, "exec autoexec.cfg\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-10-03 21:25:43 +00:00
|
|
|
snprintf (fn, sizeof (fn), "cmd_warncmd %d\n", cmd_warncmd_val);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, fn);
|
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
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// FIXME: evil hack so NQ and QW can share sound code
|
2001-03-27 22:30:25 +00:00
|
|
|
cl.viewentity = cl.playernum + 1;
|
2001-10-28 04:23:37 +00:00
|
|
|
viewentity = cl.playernum + 1;
|
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);
|
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);
|
|
|
|
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
|
2001-08-28 23:05:45 +00:00
|
|
|
Con_Printf ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36"
|
|
|
|
"\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
|
2001-11-07 08:24:56 +00:00
|
|
|
Con_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,
|
|
|
|
va (soundlist_name, cl.servercount, 0));
|
|
|
|
}
|
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;
|
2002-07-03 05:40:33 +00:00
|
|
|
int numsounds, n;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// precache sounds
|
2001-11-07 08:24:56 +00:00
|
|
|
// memset (cl.sound_precache, 0, sizeof(cl.sound_precache));
|
|
|
|
|
|
|
|
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;
|
|
|
|
numsounds++;
|
2001-11-07 08:24:56 +00:00
|
|
|
if (numsounds == MAX_SOUNDS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("Server sent too many sound_precache");
|
2001-02-19 21:15:25 +00:00
|
|
|
strcpy (cl.sound_name[numsounds], str);
|
|
|
|
}
|
|
|
|
|
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,
|
2001-11-07 08:24:56 +00:00
|
|
|
va (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)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
int nummodels, 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
|
2001-11-07 08:24:56 +00:00
|
|
|
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;
|
|
|
|
nummodels++;
|
2001-11-07 08:24:56 +00:00
|
|
|
if (nummodels == MAX_MODELS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("Server sent too many model_precache");
|
2001-11-07 08:24:56 +00:00
|
|
|
strcpy (cl.model_name[nummodels], str);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (!strcmp (cl.model_name[nummodels], "progs/spike.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_spikeindex = nummodels;
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/player.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_playerindex = nummodels;
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/flag.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_flagindex = nummodels;
|
2002-08-27 04:47:49 +00:00
|
|
|
// for deadbodyfilter & gib filter
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/h_player.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_h_playerindex = nummodels;
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/gib1.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_gib1index = nummodels;
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/gib2.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_gib2index = nummodels;
|
2001-11-07 08:24:56 +00:00
|
|
|
else if (!strcmp (cl.model_name[nummodels], "progs/gib3.mdl"))
|
2001-02-19 21:15:25 +00:00
|
|
|
cl_gib3index = nummodels;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
va (modellist_name, cl.servercount, n));
|
|
|
|
}
|
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-12-03 05:36:39 +00:00
|
|
|
CL_ParseBaseline (entity_state_t *es)
|
2001-11-05 20:13:27 +00:00
|
|
|
{
|
2001-11-07 08:24:56 +00:00
|
|
|
es->modelindex = MSG_ReadByte (net_message);
|
|
|
|
es->frame = MSG_ReadByte (net_message);
|
|
|
|
es->colormap = MSG_ReadByte (net_message);
|
|
|
|
es->skinnum = MSG_ReadByte (net_message);
|
2001-12-12 21:56:09 +00:00
|
|
|
|
|
|
|
MSG_ReadCoordAngleV (net_message, es->origin, es->angles);
|
|
|
|
|
|
|
|
// LordHavoc: set up baseline to for new effects (alpha, colormod, etc)
|
2002-06-07 11:25:47 +00:00
|
|
|
es->colormod = 255;
|
2001-02-19 21:15:25 +00:00
|
|
|
es->alpha = 255;
|
|
|
|
es->scale = 16;
|
2001-03-27 03:57:17 +00:00
|
|
|
es->glow_size = 0;
|
2002-06-07 11:25:47 +00:00
|
|
|
es->glow_color = 254;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_ParseStatic
|
|
|
|
|
|
|
|
Static entities are non-interactive world objects
|
|
|
|
like torches
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseStatic (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
entity_t *ent;
|
|
|
|
entity_state_t es;
|
2001-10-25 23:26:33 +00:00
|
|
|
|
2001-12-03 05:36:39 +00:00
|
|
|
CL_ParseBaseline (&es);
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (cl.num_statics >= MAX_STATIC_ENTITIES)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("Too many static entities");
|
2001-02-19 21:15:25 +00:00
|
|
|
ent = &cl_static_entities[cl.num_statics++];
|
2001-12-03 05:36:39 +00:00
|
|
|
CL_Init_Entity (ent);
|
|
|
|
|
|
|
|
// copy it to the current state
|
|
|
|
ent->model = cl.model_precache[es.modelindex];
|
|
|
|
ent->frame = es.frame;
|
|
|
|
ent->skinnum = es.skinnum;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-03 05:36:39 +00:00
|
|
|
VectorCopy (es.origin, ent->origin);
|
|
|
|
VectorCopy (es.angles, ent->angles);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
R_AddEfrags (ent);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseStaticSound (void)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
int sound_num, vol, atten;
|
|
|
|
vec3_t org;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_ReadCoordV (net_message, org);
|
2001-11-07 08:24:56 +00:00
|
|
|
sound_num = MSG_ReadByte (net_message);
|
|
|
|
vol = MSG_ReadByte (net_message);
|
|
|
|
atten = MSG_ReadByte (net_message);
|
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;
|
|
|
|
int channel, ent, sound_num, volume;
|
|
|
|
vec3_t pos;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
channel = MSG_ReadShort (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
if (channel & SND_VOLUME)
|
|
|
|
volume = MSG_ReadByte (net_message);
|
|
|
|
else
|
|
|
|
volume = DEFAULT_SOUND_PACKET_VOLUME;
|
|
|
|
|
|
|
|
if (channel & SND_ATTENUATION)
|
|
|
|
attenuation = MSG_ReadByte (net_message) / 64.0;
|
|
|
|
else
|
|
|
|
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
|
|
|
|
|
|
|
|
sound_num = MSG_ReadByte (net_message);
|
|
|
|
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_ReadCoordV (net_message, pos);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
ent = (channel >> 3) & 1023;
|
|
|
|
channel &= 7;
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
Server information pertaining to this client only, sent every frame
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
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)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
char skin[512];
|
2001-11-04 19:06:50 +00:00
|
|
|
const char *s;
|
|
|
|
|
|
|
|
s = Info_ValueForKey (player->userinfo, "skin");
|
2002-07-02 21:37:22 +00:00
|
|
|
COM_StripExtension (s, skin); // FIXME: buffer overflow
|
2001-11-04 19:06:50 +00:00
|
|
|
if (!strequal (s, skin))
|
|
|
|
Info_SetValueForKey (player->userinfo, "skin", skin, 1);
|
2001-12-03 05:36:39 +00:00
|
|
|
strncpy (player->name, Info_ValueForKey (player->userinfo, "name"),
|
|
|
|
sizeof (player->name) - 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
player->_topcolor = player->_bottomcolor = -1;
|
|
|
|
player->topcolor = atoi (Info_ValueForKey (player->userinfo, "topcolor"));
|
|
|
|
player->bottomcolor =
|
|
|
|
atoi (Info_ValueForKey (player->userinfo, "bottomcolor"));
|
2001-11-04 19:06:50 +00:00
|
|
|
|
|
|
|
while (!(player->team = Hash_Find (player->userinfo->tab, "team")))
|
|
|
|
Info_SetValueForKey (player->userinfo, "team", "", 1);
|
|
|
|
while (!(player->skinname = Hash_Find (player->userinfo->tab, "skin")))
|
|
|
|
Info_SetValueForKey (player->userinfo, "skin", "", 1);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Info_ValueForKey (player->userinfo, "*spectator")[0])
|
|
|
|
player->spectator = true;
|
|
|
|
else
|
|
|
|
player->spectator = false;
|
|
|
|
|
|
|
|
if (cls.state == ca_active)
|
|
|
|
Skin_Find (player);
|
|
|
|
|
|
|
|
Sbar_Changed ();
|
|
|
|
}
|
|
|
|
|
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];
|
2001-11-04 07:50:39 +00:00
|
|
|
if (player->userinfo)
|
|
|
|
Info_Destroy (player->userinfo);
|
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;
|
|
|
|
player->userinfo = Info_ParseString (info, MAX_INFO_STRING);
|
|
|
|
CL_ProcessUserInfo (slot, player);
|
|
|
|
} else {
|
|
|
|
// the server dropped the client
|
|
|
|
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-12-03 05:36:39 +00:00
|
|
|
Con_DPrintf ("SETINFO %s: %s=%s\n", player->name, key, value);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
if (!player->userinfo)
|
|
|
|
player->userinfo = Info_ParseString ("", MAX_INFO_STRING);
|
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);
|
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
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
Con_DPrintf ("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")) {
|
|
|
|
cl.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")) {
|
2002-09-17 05:11:28 +00:00
|
|
|
Cvar_Set (no_pogo_stick, value);
|
|
|
|
cl.no_pogo_stick = no_pogo_stick->int_val;
|
2001-11-11 07:02:38 +00:00
|
|
|
} else if (strequal (key, "teamplay")) {
|
|
|
|
cl.teamplay = atoi (value);
|
2002-08-15 09:38:23 +00:00
|
|
|
Sbar_DMO_Init_f (cl_showscoresuid); // HUD setup, cl.teamplay changed
|
2001-11-07 08:24:56 +00:00
|
|
|
} else if (strequal (key, "watervis")) {
|
|
|
|
cl.watervis = atoi (value);
|
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
|
|
|
Sbar_Changed ();
|
|
|
|
|
|
|
|
switch (stat) {
|
2002-08-24 05:14:46 +00:00
|
|
|
case STAT_ITEMS:
|
2001-02-19 21:15:25 +00:00
|
|
|
Sbar_Changed ();
|
|
|
|
break;
|
|
|
|
case STAT_HEALTH:
|
2003-01-03 04:30:38 +00:00
|
|
|
if (cl_player_health_e->func)
|
|
|
|
GIB_Event_Callback (cl_player_health_e, 1, va("%i", value));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (value <= 0)
|
|
|
|
Team_Dead ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cl.stats[stat] = value;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_MuzzleFlash (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
dlight_t *dl;
|
2002-07-03 05:40:33 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
player_state_t *pl;
|
2002-07-03 05:40:33 +00:00
|
|
|
vec3_t fv, rv, uv;
|
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;
|
|
|
|
|
|
|
|
pl = &cl.frames[parsecountmod].playerstate[i - 1];
|
|
|
|
|
2002-06-05 22:07:38 +00:00
|
|
|
dl = R_AllocDlight (i);
|
|
|
|
if (!dl)
|
|
|
|
return;
|
|
|
|
|
2001-08-06 00:27:41 +00:00
|
|
|
if (i - 1 == cl.playernum)
|
|
|
|
AngleVectors (cl.viewangles, fv, rv, uv);
|
|
|
|
else
|
|
|
|
AngleVectors (pl->viewangles, fv, rv, uv);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-07 05:21:53 +00:00
|
|
|
VectorMA (pl->origin, 18, fv, dl->origin);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->radius = 200 + (rand () & 31);
|
|
|
|
dl->die = cl.time + 0.1;
|
2002-06-07 05:21:53 +00:00
|
|
|
dl->minlight = 32;
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->color[0] = 0.2;
|
|
|
|
dl->color[1] = 0.1;
|
|
|
|
dl->color[2] = 0.05;
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
#define SHOWNET(x) if (cl_shownet->int_val == 2) Con_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)
|
|
|
|
{
|
2001-11-07 08:24:56 +00:00
|
|
|
const char *s;
|
2002-04-19 06:26:08 +00:00
|
|
|
static dstring_t *stuffbuf;
|
2002-10-06 04:30:50 +00:00
|
|
|
int cmd = 0, i, j;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
received_framecount = host_framecount;
|
|
|
|
cl.last_servermessage = realtime;
|
|
|
|
CL_ClearProjectiles ();
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// if recording demos, copy the message out
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl_shownet->int_val == 1)
|
2001-02-23 23:16:13 +00:00
|
|
|
Con_Printf ("%i ", net_message->message->cursize);
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (cl_shownet->int_val == 2)
|
|
|
|
Con_Printf ("------------------\n");
|
|
|
|
|
|
|
|
CL_ParseClientdata ();
|
|
|
|
|
2001-05-19 23:31:20 +00:00
|
|
|
// parse the message
|
2001-02-19 21:15:25 +00:00
|
|
|
while (1) {
|
2001-02-23 23:16:13 +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
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
cmd = MSG_ReadByte (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cmd == -1) {
|
2001-11-07 08:24:56 +00:00
|
|
|
net_message->readcount++; // so the EOM showner has the right
|
|
|
|
// value
|
|
|
|
SHOWNET ("END OF MESSAGE");
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
SHOWNET (svc_strings[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
|
|
|
|
Host_EndGame ("Server disconnected");
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_print: {
|
2002-07-03 05:40:33 +00:00
|
|
|
char p[2048];
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
s = MSG_ReadString (net_message);
|
|
|
|
if (i == PRINT_CHAT) {
|
|
|
|
// TODO: cl_nofake 2 -- accept fake messages from teammates
|
|
|
|
|
|
|
|
if (cl_nofake->int_val) {
|
2002-07-03 05:40:33 +00:00
|
|
|
char *c;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
strncpy (p, s, sizeof (p));
|
|
|
|
p[sizeof (p) - 1] = 0;
|
|
|
|
for (c = p; *c; c++) {
|
|
|
|
if (*c == '\r')
|
|
|
|
*c = '#';
|
|
|
|
}
|
|
|
|
s = p;
|
|
|
|
}
|
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)
|
|
|
|
GIB_Event_Callback (cl_chat_e, 1, s);
|
2001-11-07 08:24:56 +00:00
|
|
|
Team_ParseChat(s);
|
|
|
|
}
|
|
|
|
Con_Printf ("%s", s);
|
2002-01-16 21:53:42 +00:00
|
|
|
Con_SetOrMask (0);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case svc_centerprint:
|
|
|
|
SCR_CenterPrint (MSG_ReadString (net_message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_stufftext:
|
|
|
|
s = MSG_ReadString (net_message);
|
2002-04-19 17:58:52 +00:00
|
|
|
if (s[strlen (s) - 1] == '\n') {
|
|
|
|
if (stuffbuf && stuffbuf->str[0]) {
|
|
|
|
Con_DPrintf ("stufftext: %s%s\n", stuffbuf->str, s);
|
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 {
|
|
|
|
Con_DPrintf ("stufftext: %s\n", s);
|
|
|
|
}
|
2002-12-01 07:22:42 +00:00
|
|
|
Cbuf_AddText (cl_stbuf, s);
|
2002-04-19 17:58:52 +00:00
|
|
|
} else {
|
|
|
|
Con_DPrintf ("partial stufftext: %s\n", s);
|
|
|
|
if (!stuffbuf)
|
|
|
|
stuffbuf = dstring_newstr();
|
|
|
|
dstring_appendstr (stuffbuf, s);
|
2002-04-19 06:26:08 +00:00
|
|
|
}
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_damage:
|
|
|
|
V_ParseDamage ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_serverdata:
|
2002-07-31 05:19:03 +00:00
|
|
|
// make sure any stuffed commands are done
|
2002-12-01 07:22:42 +00:00
|
|
|
Cbuf_Execute_Stack (cl_stbuf);
|
2001-11-07 08:24:56 +00:00
|
|
|
CL_ParseServerData ();
|
|
|
|
vid.recalc_refdef = true; // leave full screen intermission
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_setangle:
|
2002-10-02 21:56:45 +00:00
|
|
|
if (!cls.demoplayback2) {
|
|
|
|
MSG_ReadAngleV (net_message, cl.viewangles);
|
|
|
|
} else {
|
|
|
|
j = MSG_ReadByte(net_message);
|
|
|
|
//fixangle |= 1 << j;
|
|
|
|
if (j != Cam_TrackNum()) {
|
|
|
|
MSG_ReadAngle (net_message);
|
|
|
|
MSG_ReadAngle (net_message);
|
|
|
|
MSG_ReadAngle (net_message);
|
|
|
|
} else {
|
|
|
|
MSG_ReadAngleV (net_message, cl.viewangles);
|
|
|
|
}
|
|
|
|
}
|
2002-07-03 05:40:33 +00:00
|
|
|
// FIXME cl.viewangles[PITCH] = cl.viewangles[ROLL] = 0;
|
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");
|
2001-11-07 08:24:56 +00:00
|
|
|
strcpy (r_lightstyle[i].map, MSG_ReadString (net_message));
|
|
|
|
r_lightstyle[i].length = strlen (r_lightstyle[i].map);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_sound:
|
|
|
|
CL_ParseStartSoundPacket ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_stopsound:
|
|
|
|
i = MSG_ReadShort (net_message);
|
|
|
|
S_StopSound (i >> 3, i & 7);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updatefrags:
|
|
|
|
Sbar_Changed ();
|
|
|
|
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");
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.players[i].frags = MSG_ReadShort (net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updateping:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updateping > "
|
|
|
|
"MAX_SCOREBOARD");
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.players[i].ping = MSG_ReadShort (net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updatepl:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updatepl > "
|
|
|
|
"MAX_SCOREBOARD");
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.players[i].pl = MSG_ReadByte (net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updateentertime:
|
|
|
|
// time is sent over as seconds ago
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
if (i >= MAX_CLIENTS)
|
2001-11-12 20:46:11 +00:00
|
|
|
Host_Error ("CL_ParseServerMessage: svc_updateentertime "
|
|
|
|
"> MAX_SCOREBOARD");
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.players[i].entertime = realtime - MSG_ReadFloat
|
|
|
|
(net_message);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_spawnbaseline:
|
|
|
|
i = MSG_ReadShort (net_message);
|
2001-12-03 05:36:39 +00:00
|
|
|
CL_ParseBaseline (&cl_baselines[i]);
|
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_spawnstatic:
|
|
|
|
CL_ParseStatic ();
|
|
|
|
break;
|
2002-07-03 05:40:33 +00:00
|
|
|
|
|
|
|
case svc_spawnstaticsound:
|
|
|
|
CL_ParseStaticSound ();
|
|
|
|
break;
|
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_temp_entity:
|
|
|
|
CL_ParseTEnt ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_killedmonster:
|
|
|
|
cl.stats[STAT_MONSTERS]++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_foundsecret:
|
|
|
|
cl.stats[STAT_SECRETS]++;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updatestat:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
j = MSG_ReadByte (net_message);
|
|
|
|
CL_SetStat (i, j);
|
|
|
|
break;
|
2002-07-03 05:40:33 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_updatestatlong:
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
j = MSG_ReadLong (net_message);
|
|
|
|
CL_SetStat (i, j);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_cdtrack:
|
|
|
|
cl.cdtrack = MSG_ReadByte (net_message);
|
|
|
|
CDAudio_Play ((byte) cl.cdtrack, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_intermission:
|
|
|
|
Con_DPrintf ("svc_intermission\n");
|
2002-03-14 15:43:08 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.intermission = 1;
|
|
|
|
cl.completed_time = realtime;
|
|
|
|
vid.recalc_refdef = true; // go to full screen
|
|
|
|
Con_DPrintf ("intermission simorg: ");
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_ReadCoordV (net_message, cl.simorg);
|
|
|
|
for (i = 0; i < 3; i++)
|
2001-11-07 08:24:56 +00:00
|
|
|
Con_DPrintf ("%f ", cl.simorg[i]);
|
|
|
|
Con_DPrintf ("\nintermission simangles: ");
|
2001-12-12 21:56:09 +00:00
|
|
|
MSG_ReadAngleV (net_message, cl.simangles);
|
|
|
|
for (i = 0; i < 3; i++)
|
2001-11-07 08:24:56 +00:00
|
|
|
Con_DPrintf ("%f ", cl.simangles[i]);
|
|
|
|
Con_DPrintf ("\n");
|
|
|
|
VectorCopy (vec3_origin, cl.simvel);
|
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)
|
|
|
|
Sbar_LogFrags();
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_finale:
|
2002-03-14 15:43:08 +00:00
|
|
|
Con_Printf("svc_finale\n");
|
2001-11-07 08:24:56 +00:00
|
|
|
cl.intermission = 2;
|
|
|
|
cl.completed_time = realtime;
|
2002-07-03 05:40:33 +00:00
|
|
|
vid.recalc_refdef = true; // go to full screen
|
2001-11-07 08:24:56 +00:00
|
|
|
SCR_CenterPrint (MSG_ReadString (net_message));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_sellscreen:
|
|
|
|
Cmd_ExecuteString ("help", src_command);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_smallkick:
|
|
|
|
cl.punchangle = -2;
|
|
|
|
break;
|
2002-07-03 05:40:33 +00:00
|
|
|
|
2001-11-07 08:24:56 +00:00
|
|
|
case svc_bigkick:
|
|
|
|
cl.punchangle = -4;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_muzzleflash:
|
|
|
|
CL_MuzzleFlash ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_updateuserinfo:
|
|
|
|
CL_UpdateUserinfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_setinfo:
|
|
|
|
CL_SetInfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_serverinfo:
|
|
|
|
CL_ServerInfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_download:
|
|
|
|
CL_ParseDownload ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_playerinfo:
|
|
|
|
CL_ParsePlayerinfo ();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nails:
|
2002-10-02 21:56:45 +00:00
|
|
|
CL_ParseProjectiles (false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nails2: // FIXME from qwex
|
|
|
|
CL_ParseProjectiles (true);
|
2001-11-07 08:24:56 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
case svc_setpause:
|
|
|
|
cl.paused = MSG_ReadByte (net_message);
|
|
|
|
if (cl.paused)
|
|
|
|
CDAudio_Pause ();
|
|
|
|
else
|
|
|
|
CDAudio_Resume ();
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CL_SetSolidEntities ();
|
|
|
|
}
|