2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_main.c
|
|
|
|
|
|
|
|
Client main loop
|
|
|
|
|
|
|
|
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 __sun
|
|
|
|
/* Sun's model_t in sys/model.h conflicts w/ Quake's model_t */
|
|
|
|
# define model_t sunmodel_t
|
|
|
|
#endif
|
2001-08-28 23:05:45 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2001-09-07 04:41:13 +00:00
|
|
|
#include <sys/types.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
2002-02-22 05:48:59 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_WINSOCK_H
|
|
|
|
# include <winsock.h>
|
|
|
|
#endif
|
2001-07-05 20:18:23 +00:00
|
|
|
#ifdef HAVE_RPC_TYPES_H
|
|
|
|
# include <rpc/types.h>
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <errno.h>
|
2001-02-19 21:15:25 +00:00
|
|
|
#include <setjmp.h>
|
|
|
|
|
|
|
|
#ifdef __sun
|
2001-08-28 23:05:45 +00:00
|
|
|
# undef model_t // allow qf to use it's model_t
|
2001-02-19 21:15:25 +00:00
|
|
|
#endif
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2002-07-31 22:03:53 +00:00
|
|
|
#include "QF/idparse.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
2002-01-20 04:10:36 +00:00
|
|
|
#include "QF/csqc.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-09 22:40:51 +00:00
|
|
|
#include "QF/draw.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/input.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/keys.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/msg.h"
|
2001-04-25 00:20:23 +00:00
|
|
|
#include "QF/plugin.h"
|
2002-01-18 19:19:33 +00:00
|
|
|
#include "QF/progs.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/qargs.h"
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "QF/qendian.h"
|
2001-04-15 08:04:15 +00:00
|
|
|
#include "QF/screen.h"
|
2001-04-10 21:45:42 +00:00
|
|
|
#include "QF/sound.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-09 18:04:45 +00:00
|
|
|
#include "QF/teamplay.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/va.h"
|
2001-05-30 04:34:06 +00:00
|
|
|
#include "QF/vfs.h"
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "QF/vid.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "bothdefs.h"
|
|
|
|
#include "buildnum.h"
|
|
|
|
#include "cl_cam.h"
|
|
|
|
#include "cl_demo.h"
|
|
|
|
#include "cl_ents.h"
|
|
|
|
#include "cl_input.h"
|
|
|
|
#include "cl_main.h"
|
|
|
|
#include "cl_parse.h"
|
|
|
|
#include "cl_pred.h"
|
2001-05-11 22:47:15 +00:00
|
|
|
#include "cl_skin.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "cl_slist.h"
|
|
|
|
#include "cl_tent.h"
|
|
|
|
#include "client.h"
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "compat.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "game.h"
|
|
|
|
#include "host.h"
|
|
|
|
#include "net.h"
|
|
|
|
#include "pmove.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
#include "r_cvar.h"
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "r_dynamic.h"
|
2001-05-09 18:28:08 +00:00
|
|
|
#include "sbar.h"
|
|
|
|
#include "view.h"
|
|
|
|
|
2002-01-16 21:53:42 +00:00
|
|
|
CLIENT_PLUGIN_PROTOS
|
|
|
|
static plugin_list_t client_plugin_list[] = {
|
|
|
|
CLIENT_PLUGIN_LIST
|
|
|
|
};
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void CL_RemoveQFInfoKeys ();
|
|
|
|
|
|
|
|
// we need to declare some mouse variables here, because the menu system
|
|
|
|
// references them even when on a unix system.
|
|
|
|
|
|
|
|
qboolean noclip_anglehack; // remnant from old quake
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
cbuf_t *cl_cbuf;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *fs_globalcfg;
|
|
|
|
cvar_t *fs_usercfg;
|
2001-11-14 20:18:37 +00:00
|
|
|
|
|
|
|
cvar_t *cl_mem_size;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *rcon_password;
|
|
|
|
|
|
|
|
cvar_t *rcon_address;
|
|
|
|
|
|
|
|
cvar_t *cl_writecfg;
|
|
|
|
cvar_t *cl_allow_cmd_pkt;
|
2001-12-05 21:56:52 +00:00
|
|
|
cvar_t *cl_paranoid;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-21 05:35:35 +00:00
|
|
|
cvar_t *cl_timeframes;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *cl_timeout;
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
cvar_t *cl_shownet;
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *cl_autoexec;
|
2001-09-06 23:58:28 +00:00
|
|
|
cvar_t *cl_quakerc;
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *cl_sbar;
|
|
|
|
cvar_t *cl_sbar_separator;
|
|
|
|
cvar_t *cl_hudswap;
|
|
|
|
cvar_t *cl_maxfps;
|
2002-02-22 05:48:59 +00:00
|
|
|
cvar_t *cl_usleep;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cvar_t *cl_cshift_bonus;
|
|
|
|
cvar_t *cl_cshift_contents;
|
|
|
|
cvar_t *cl_cshift_damage;
|
|
|
|
cvar_t *cl_cshift_powerup;
|
|
|
|
|
2001-06-02 23:29:41 +00:00
|
|
|
cvar_t *cl_model_crcs;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *lookspring;
|
|
|
|
|
|
|
|
cvar_t *m_pitch;
|
|
|
|
cvar_t *m_yaw;
|
|
|
|
cvar_t *m_forward;
|
|
|
|
cvar_t *m_side;
|
|
|
|
|
|
|
|
cvar_t *cl_predict_players;
|
|
|
|
cvar_t *cl_solid_players;
|
|
|
|
|
|
|
|
cvar_t *localid;
|
|
|
|
|
2002-03-14 18:48:04 +00:00
|
|
|
cvar_t *cl_port;
|
|
|
|
cvar_t *cl_autorecord;
|
2001-05-30 18:50:17 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
static qboolean allowremotecmd = true;
|
|
|
|
|
2001-05-19 20:57:29 +00:00
|
|
|
/* info mirrors */
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *password;
|
|
|
|
cvar_t *spectator;
|
2001-05-13 04:01:06 +00:00
|
|
|
cvar_t *cl_name;
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *team;
|
|
|
|
cvar_t *rate;
|
|
|
|
cvar_t *noaim;
|
|
|
|
cvar_t *msg;
|
|
|
|
|
2002-02-22 05:48:59 +00:00
|
|
|
static int cl_usleep_cache;
|
This took half the hair on my head. Just kidding:
cl_max_particles now lives in *part.c - in GL it dynamically changes the
amount of particles on the fly! Needless to say this is fun, and this is
proboably the third cvar that uses the callbacks function at all - which
IMHO is really a cool trick Taniwha.
However I'm losing my SANITY in r_part.c - if someone could take a look,
I'd be greatly appreciative. It should be obvious to any developer that
I'm having a few problems. :P Basically the dynamic code is completely
and totally disabled, and I hacked in code which *works* but shouldn't
EVER EVER EVER be left there after we fix this as it is downright EVIL
the way I implimented it. SW client does work, and does still work with
+set cl_max_particles - however the hacks I made to get it to do that...
*shakes head* Tread softly in there, it's a mess.
Other notes of interest:
I changed show_time so it archives its setting. Got annoyed with it. If
someone finds this change to be bad, change it back. :)
glspeed.cfg got updated with a setting of 60 for cl_max_particles. 60
works nicely, and doesn't use too much speed on my aging hardware, so
I'm sure newer systems will just plain FLY with this on.
I also changed the cl_maxfps setting as 72 is great if you aren't using
a modem !.! due to the way cl_maxfps works, the higher it goes, the more
data is sent to you by the server. This causes a heck of a lot of lost
packets if you don't have the bandwidth OR if your card can't keep up
with the framerate. Either of which is bad. I set it to 30, the default
of the cvar is 0/32 so go figure out what works best for you I say.
Let me know if this blows up in your face and ESPECIALLY let me know if
you can fix the r_part.c problems!
Misty-chan
2001-04-03 02:56:39 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
client_static_t cls;
|
|
|
|
client_state_t cl;
|
|
|
|
|
|
|
|
entity_state_t cl_baselines[MAX_EDICTS];
|
|
|
|
efrag_t cl_efrags[MAX_EFRAGS];
|
|
|
|
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|
|
|
|
|
|
|
double connect_time = -1; // for connection retransmits
|
|
|
|
|
|
|
|
quakeparms_t host_parms;
|
|
|
|
qboolean host_initialized; // true if into command execution
|
|
|
|
qboolean nomaster;
|
2001-12-09 14:05:30 +00:00
|
|
|
qboolean hudswap;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
double host_frametime;
|
|
|
|
double realtime; // without any filtering or bounding
|
|
|
|
double oldrealtime; // last frame run
|
|
|
|
int host_framecount;
|
|
|
|
|
|
|
|
int host_hunklevel;
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
byte *vid_basepal;
|
|
|
|
byte *vid_colormap;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 06:57:38 +00:00
|
|
|
cvar_t *host_speeds;
|
|
|
|
cvar_t *show_fps;
|
2001-08-11 04:14:58 +00:00
|
|
|
cvar_t *show_ping;
|
|
|
|
cvar_t *show_pl;
|
2001-02-19 21:15:25 +00:00
|
|
|
cvar_t *show_time;
|
|
|
|
|
|
|
|
int fps_count;
|
|
|
|
|
|
|
|
jmp_buf host_abort;
|
|
|
|
|
|
|
|
void Master_Connect_f (void);
|
|
|
|
|
|
|
|
char *server_version = NULL; // version of server we connected to
|
|
|
|
|
2001-06-02 22:20:34 +00:00
|
|
|
char emodel_name[] = "emodel";
|
|
|
|
char pmodel_name[] = "pmodel";
|
2001-02-19 21:15:25 +00:00
|
|
|
char prespawn_name[] = "prespawn %i 0 %i";
|
|
|
|
char modellist_name[] = "modellist %i %i";
|
|
|
|
char soundlist_name[] = "soundlist %i %i";
|
|
|
|
|
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
void CL_RSShot_f (void);
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
void
|
|
|
|
CL_Sbar_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
vid.recalc_refdef = true;
|
|
|
|
r_lineadj = var->int_val ? sb_lines : 0;
|
|
|
|
}
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_Quit_f (void)
|
|
|
|
{
|
2002-01-20 00:04:50 +00:00
|
|
|
if (!con_module)
|
|
|
|
Con_Printf ("I hope you wanted to quit\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Disconnect ();
|
|
|
|
Sys_Quit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Version_f (void)
|
|
|
|
{
|
|
|
|
Con_Printf ("%s Version %s\n", PROGRAM, VERSION);
|
|
|
|
Con_Printf ("Binary: " __TIME__ " " __DATE__ "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_SendConnectPacket
|
|
|
|
|
|
|
|
called by CL_Connect_f and CL_CheckResend
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_SendConnectPacket (void)
|
|
|
|
{
|
|
|
|
char data[2048];
|
|
|
|
double t1, t2;
|
|
|
|
|
|
|
|
// JACK: Fixed bug where DNS lookups would cause two connects real fast
|
|
|
|
// Now, adds lookup time to the connect time.
|
|
|
|
// Should I add it to realtime instead?!?!
|
|
|
|
|
|
|
|
if (cls.state != ca_disconnected)
|
|
|
|
return;
|
|
|
|
|
|
|
|
t1 = Sys_DoubleTime ();
|
|
|
|
|
2001-12-05 21:56:52 +00:00
|
|
|
if (!NET_StringToAdr (cls.servername, &cls.server_addr)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Bad server address\n");
|
|
|
|
connect_time = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-05 21:56:52 +00:00
|
|
|
if (cls.server_addr.port == 0)
|
|
|
|
cls.server_addr.port = BigShort (27500);
|
2001-02-19 21:15:25 +00:00
|
|
|
t2 = Sys_DoubleTime ();
|
|
|
|
|
|
|
|
connect_time = realtime + t2 - t1; // for retransmit requests
|
|
|
|
|
2001-10-27 08:28:15 +00:00
|
|
|
cls.qport = qport->int_val;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
snprintf (data, sizeof (data), "%c%c%c%cconnect %i %i %i \"%s\"\n",
|
|
|
|
255, 255, 255, 255, PROTOCOL_VERSION, cls.qport, cls.challenge,
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_MakeString (cls.userinfo, 0));
|
2001-12-05 21:56:52 +00:00
|
|
|
NET_SendPacket (strlen (data), data, cls.server_addr);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_CheckForResend
|
|
|
|
|
|
|
|
Resend a connect message if the last one has timed out
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_CheckForResend (void)
|
|
|
|
{
|
|
|
|
char data[2048];
|
|
|
|
double t1, t2;
|
|
|
|
|
|
|
|
if (connect_time == -1)
|
|
|
|
return;
|
|
|
|
if (cls.state != ca_disconnected)
|
|
|
|
return;
|
|
|
|
if (connect_time && realtime - connect_time < 5.0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
t1 = Sys_DoubleTime ();
|
2001-12-05 21:56:52 +00:00
|
|
|
if (!NET_StringToAdr (cls.servername, &cls.server_addr)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Bad server address\n");
|
|
|
|
connect_time = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-12-05 21:56:52 +00:00
|
|
|
if (cls.server_addr.port == 0)
|
|
|
|
cls.server_addr.port = BigShort (27500);
|
2001-02-19 21:15:25 +00:00
|
|
|
t2 = Sys_DoubleTime ();
|
|
|
|
|
|
|
|
connect_time = realtime + t2 - t1; // for retransmit requests
|
|
|
|
|
|
|
|
VID_SetCaption (va ("Connecting to %s", cls.servername));
|
|
|
|
Con_Printf ("Connecting to %s...\n", cls.servername);
|
|
|
|
snprintf (data, sizeof (data), "%c%c%c%cgetchallenge\n", 255, 255, 255,
|
|
|
|
255);
|
2001-12-05 21:56:52 +00:00
|
|
|
NET_SendPacket (strlen (data), data, cls.server_addr);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_BeginServerConnect (void)
|
|
|
|
{
|
|
|
|
connect_time = 0;
|
|
|
|
CL_CheckForResend ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Connect_f (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *server;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Con_Printf ("usage: connect <server>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
server = Cmd_Argv (1);
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
|
|
|
|
strncpy (cls.servername, server, sizeof (cls.servername) - 1);
|
|
|
|
CL_BeginServerConnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_Rcon_f
|
|
|
|
|
|
|
|
Send the rest of the command line over as
|
|
|
|
an unconnected command.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Rcon_f (void)
|
|
|
|
{
|
|
|
|
char message[1024];
|
|
|
|
netadr_t to;
|
|
|
|
|
2001-09-22 02:24:46 +00:00
|
|
|
snprintf (message, sizeof (message), "\377\377\377\377rcon %s %s",
|
|
|
|
rcon_password->string, Cmd_Args (1));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cls.state >= ca_connected)
|
|
|
|
to = cls.netchan.remote_address;
|
|
|
|
else {
|
2001-09-26 20:57:40 +00:00
|
|
|
if (!rcon_address->string[0]) {
|
2002-07-03 05:40:33 +00:00
|
|
|
Con_Printf ("You must either be connected, "
|
|
|
|
"or set the 'rcon_address' cvar "
|
2001-02-19 21:15:25 +00:00
|
|
|
"to issue rcon commands\n");
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
NET_StringToAdr (rcon_address->string, &to);
|
2001-09-26 21:06:51 +00:00
|
|
|
if (to.port == 0)
|
|
|
|
to.port = BigShort (27500);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NET_SendPacket (strlen (message) + 1, message, to);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ClearState (void)
|
|
|
|
{
|
|
|
|
S_StopAllSounds (true);
|
|
|
|
|
2002-06-14 07:55:19 +00:00
|
|
|
// wipe the entire cl structure
|
|
|
|
Info_Destroy (cl.serverinfo);
|
|
|
|
memset (&cl, 0, sizeof (cl));
|
|
|
|
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING);
|
|
|
|
|
|
|
|
CL_Init_Entity (&cl.viewent);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_DPrintf ("Clearing memory\n");
|
|
|
|
D_FlushCaches ();
|
|
|
|
Mod_ClearAll ();
|
|
|
|
if (host_hunklevel) // FIXME: check this...
|
|
|
|
Hunk_FreeToLowMark (host_hunklevel);
|
|
|
|
|
|
|
|
CL_ClearEnts ();
|
|
|
|
CL_ClearTEnts ();
|
|
|
|
|
2001-05-20 01:58:59 +00:00
|
|
|
R_ClearEfrags ();
|
2001-05-20 05:42:52 +00:00
|
|
|
R_ClearDlights ();
|
2002-01-12 05:32:21 +00:00
|
|
|
R_ClearParticles ();
|
2001-05-20 01:58:59 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Clear (&cls.netchan.message);
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
// clear other arrays
|
2001-02-19 21:15:25 +00:00
|
|
|
memset (cl_efrags, 0, sizeof (cl_efrags));
|
2001-05-21 03:08:07 +00:00
|
|
|
memset (r_lightstyle, 0, sizeof (r_lightstyle));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-04-20 13:33:56 +00:00
|
|
|
/*
|
|
|
|
CL_StopCshifts
|
|
|
|
|
|
|
|
Cleans the Cshifts, so your screen doesn't stay red after a timedemo :)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_StopCshifts (void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-08-28 23:05:45 +00:00
|
|
|
|
2001-04-20 13:33:56 +00:00
|
|
|
for (i = 0; i < NUM_CSHIFTS; i++)
|
|
|
|
cl.cshifts[i].percent = 0;
|
|
|
|
for (i = 0; i < MAX_CL_STATS; i++)
|
|
|
|
cl.stats[i] = 0;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
CL_Disconnect
|
|
|
|
|
|
|
|
Sends a disconnect message to the server
|
|
|
|
This is also called on Host_Error, so it shouldn't cause any errors
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Disconnect (void)
|
|
|
|
{
|
|
|
|
byte final[10];
|
2002-05-11 00:36:12 +00:00
|
|
|
int i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
connect_time = -1;
|
|
|
|
|
|
|
|
VID_SetCaption ("Disconnected");
|
|
|
|
|
2001-05-13 23:15:34 +00:00
|
|
|
// stop sounds (especially looping!)
|
2001-02-19 21:15:25 +00:00
|
|
|
S_StopAllSounds (true);
|
|
|
|
|
2001-05-13 23:15:34 +00:00
|
|
|
// Clean the Cshifts
|
2001-04-20 13:33:56 +00:00
|
|
|
CL_StopCshifts ();
|
|
|
|
|
2001-05-13 23:15:34 +00:00
|
|
|
// if running a local server, shut it down
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.demoplayback)
|
|
|
|
CL_StopPlayback ();
|
|
|
|
else if (cls.state != ca_disconnected) {
|
|
|
|
if (cls.demorecording)
|
|
|
|
CL_Stop_f ();
|
|
|
|
|
|
|
|
final[0] = clc_stringcmd;
|
|
|
|
strcpy (final + 1, "drop");
|
|
|
|
Netchan_Transmit (&cls.netchan, 6, final);
|
|
|
|
Netchan_Transmit (&cls.netchan, 6, final);
|
|
|
|
Netchan_Transmit (&cls.netchan, 6, final);
|
|
|
|
|
2001-08-19 03:51:52 +00:00
|
|
|
CL_SetState (ca_disconnected);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cls.demoplayback = cls.demorecording = cls.timedemo = false;
|
|
|
|
|
|
|
|
CL_RemoveQFInfoKeys ();
|
|
|
|
}
|
|
|
|
Cam_Reset ();
|
|
|
|
|
|
|
|
if (cls.download) {
|
|
|
|
Qclose (cls.download);
|
|
|
|
cls.download = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
CL_StopUpload ();
|
|
|
|
|
2001-11-05 07:23:51 +00:00
|
|
|
Team_ResetTimers ();
|
|
|
|
|
2002-05-11 00:36:12 +00:00
|
|
|
// remove player info strings
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++)
|
|
|
|
if (cl.players[i].userinfo) {
|
|
|
|
Info_Destroy (cl.players[i].userinfo);
|
|
|
|
cl.players[i].userinfo = 0;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Disconnect_f (void)
|
|
|
|
{
|
|
|
|
CL_Disconnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_User_f
|
|
|
|
|
|
|
|
user <name or userid>
|
|
|
|
|
|
|
|
Dump userdata / masterdata for a user
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_User_f (void)
|
|
|
|
{
|
2001-08-28 23:05:45 +00:00
|
|
|
int uid, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Con_Printf ("Usage: user <username / userid>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uid = atoi (Cmd_Argv (1));
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
2001-12-03 05:36:39 +00:00
|
|
|
if (!cl.players[i].name[0])
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
if (cl.players[i].userid == uid
|
2001-12-03 05:36:39 +00:00
|
|
|
|| !strcmp (cl.players[i].name, Cmd_Argv (1))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Info_Print (cl.players[i].userinfo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Con_Printf ("User not in server.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_Users_f
|
|
|
|
|
|
|
|
Dump userids for all current players
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Users_f (void)
|
|
|
|
{
|
2001-08-28 23:05:45 +00:00
|
|
|
int c, i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
c = 0;
|
|
|
|
Con_Printf ("userid frags name\n");
|
|
|
|
Con_Printf ("------ ----- ----\n");
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
2001-12-03 05:36:39 +00:00
|
|
|
if (cl.players[i].name[0]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("%6i %4i %s\n", cl.players[i].userid,
|
2001-12-03 05:36:39 +00:00
|
|
|
cl.players[i].frags, cl.players[i].name);
|
2001-02-19 21:15:25 +00:00
|
|
|
c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("%i total users\n", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_FullServerinfo_f
|
|
|
|
|
|
|
|
Sent by server when serverinfo changes
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_FullServerinfo_f (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *p;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Con_Printf ("usage: fullserverinfo <complete info string>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_DPrintf ("Cmd_Argv(1): '%s'\n", Cmd_Argv (1));
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_Destroy (cl.serverinfo);
|
|
|
|
cl.serverinfo = Info_ParseString (Cmd_Argv (1), MAX_SERVERINFO_STRING);
|
|
|
|
Con_DPrintf ("cl.serverinfo: '%s'\n", Info_MakeString (cl.serverinfo, 0));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "*qf_version")) && *p) {
|
|
|
|
if (server_version == NULL)
|
2001-09-11 03:50:24 +00:00
|
|
|
Con_Printf ("QuakeForge v%s Server\n", p);
|
2001-02-19 21:15:25 +00:00
|
|
|
server_version = strdup (p);
|
|
|
|
} else if ((p = Info_ValueForKey (cl.serverinfo, "*version")) && *p) {
|
|
|
|
if (server_version == NULL)
|
2001-09-11 03:50:24 +00:00
|
|
|
Con_Printf ("QaukeWorld v%s Server\n", p);
|
2001-02-19 21:15:25 +00:00
|
|
|
server_version = strdup (p);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "*qsg_version")) && *p) {
|
2001-09-11 03:50:24 +00:00
|
|
|
if ((cl.stdver = atof (p)))
|
|
|
|
Con_Printf ("Server supports QSG v%s protocol\n", p);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2001-09-11 03:50:24 +00:00
|
|
|
Con_Printf ("Invalid QSG Protocol number: %s", p);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-11 07:02:38 +00:00
|
|
|
|
|
|
|
cl.chase = cl.sv_cshifts = cl.no_pogo_stick = cl.teamplay = 0;
|
2001-10-01 01:51:36 +00:00
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "chase")) && *p) {
|
2001-11-11 07:02:38 +00:00
|
|
|
cl.chase = atoi (p);
|
|
|
|
}
|
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "cshifts")) && *p) {
|
|
|
|
cl.sv_cshifts = atoi (p);
|
2001-10-01 01:51:36 +00:00
|
|
|
}
|
2001-11-04 19:06:50 +00:00
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "no_pogo_stick")) && *p) {
|
2001-11-11 07:02:38 +00:00
|
|
|
cl.no_pogo_stick = atoi (p);
|
2001-11-04 19:06:50 +00:00
|
|
|
}
|
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "teamplay")) && *p) {
|
2001-11-11 07:02:38 +00:00
|
|
|
cl.teamplay = atoi (p);
|
2001-11-04 19:06:50 +00:00
|
|
|
}
|
2001-10-01 01:51:36 +00:00
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "watervis")) && *p) {
|
2001-11-11 07:02:38 +00:00
|
|
|
cl.watervis = atoi (p);
|
2001-10-01 01:51:36 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
if ((p = Info_ValueForKey (cl.serverinfo, "skybox")) && *p) {
|
2002-07-03 05:40:33 +00:00
|
|
|
// FIXME: Didn't actually do anything anyway
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-04-23 07:47:24 +00:00
|
|
|
void
|
|
|
|
CL_Getserverinfo_f (void)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Cmd_Error ("getserverinfo: invalid number of arguments.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Cmd_Return (Info_ValueForKey (cl.serverinfo, Cmd_Argv(1)));
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_AddQFInfoKeys (void)
|
|
|
|
{
|
|
|
|
char cap[100] = ""; // max of 98 or so flags
|
|
|
|
|
2001-12-19 00:40:34 +00:00
|
|
|
// set the capabilities info. single char flags (possibly with modifiers)
|
2001-02-19 21:15:25 +00:00
|
|
|
// defined capabilities (* = not implemented):
|
|
|
|
// z client can accept gzipped files.
|
|
|
|
// h * http transfers
|
|
|
|
// f * ftp transfers
|
|
|
|
// a * audio channel (voice chat)
|
|
|
|
// i * irc
|
|
|
|
// p pogo stick control
|
|
|
|
// t team messages
|
|
|
|
strncpy (cap, "pt", sizeof (cap));
|
|
|
|
#ifdef HAVE_ZLIB
|
|
|
|
strncat (cap, "z", sizeof (cap) - strlen (cap) - 1);
|
|
|
|
#endif
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForStarKey (cls.userinfo, "*cap", cap, 0);
|
|
|
|
Info_SetValueForStarKey (cls.userinfo, "*qf_version", VERSION, 0);
|
|
|
|
Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QW_QSG_VERSION, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_RemoveQFInfoKeys (void)
|
|
|
|
{
|
|
|
|
Info_RemoveKey (cls.userinfo, "*cap");
|
|
|
|
Info_RemoveKey (cls.userinfo, "*qf_version");
|
|
|
|
Info_RemoveKey (cls.userinfo, "*qsg_version");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_FullInfo_f
|
|
|
|
|
|
|
|
Allow clients to change userinfo
|
|
|
|
Casey was here :)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_FullInfo_f (void)
|
|
|
|
{
|
2001-08-28 23:05:45 +00:00
|
|
|
char key[512], value[512];
|
2001-02-19 21:15:25 +00:00
|
|
|
char *o;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *s;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Con_Printf ("fullinfo <complete info string>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = Cmd_Argv (1);
|
|
|
|
if (*s == '\\')
|
|
|
|
s++;
|
|
|
|
while (*s) {
|
|
|
|
o = key;
|
|
|
|
while (*s && *s != '\\')
|
|
|
|
*o++ = *s++;
|
|
|
|
*o = 0;
|
|
|
|
|
|
|
|
if (!*s) {
|
|
|
|
Con_Printf ("MISSING VALUE\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
o = value;
|
|
|
|
s++;
|
|
|
|
while (*s && *s != '\\')
|
|
|
|
*o++ = *s++;
|
|
|
|
*o = 0;
|
|
|
|
|
|
|
|
if (*s)
|
|
|
|
s++;
|
|
|
|
|
2001-06-02 22:20:34 +00:00
|
|
|
if (strcaseequal (key, pmodel_name) || strcaseequal (key, emodel_name))
|
|
|
|
continue;
|
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForKey (cls.userinfo, key, value,
|
2002-07-03 05:40:33 +00:00
|
|
|
(!strequal (key, "name")) |
|
|
|
|
(strequal (key, "team") << 1));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_SetInfo_f
|
|
|
|
|
|
|
|
Allow clients to change userinfo
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_SetInfo_f (void)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc () == 1) {
|
|
|
|
Info_Print (cls.userinfo);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Cmd_Argc () != 3) {
|
|
|
|
Con_Printf ("usage: setinfo [ <key> <value> ]\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-06-02 22:20:34 +00:00
|
|
|
if (strcaseequal (Cmd_Argv (1), pmodel_name)
|
|
|
|
|| strcaseequal (Cmd_Argv (1), emodel_name))
|
|
|
|
return;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Info_SetValueForKey (cls.userinfo, Cmd_Argv (1), Cmd_Argv (2),
|
2002-07-03 05:40:33 +00:00
|
|
|
(!strequal (Cmd_Argv (1), "name")) |
|
|
|
|
(strequal (Cmd_Argv (2), "team") << 1));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.state >= ca_connected)
|
2002-07-31 05:19:03 +00:00
|
|
|
CL_Cmd_ForwardToServer ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-06-05 00:13:46 +00:00
|
|
|
void
|
|
|
|
CL_GetInfo_f (void)
|
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Cmd_Error ("getinfo: invalid number of arguments\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
str = Info_ValueForKey(cls.userinfo, Cmd_Argv(1));
|
|
|
|
if (str)
|
|
|
|
Cmd_Return (str);
|
|
|
|
else
|
|
|
|
Cmd_Return ("");
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
CL_Packet_f
|
|
|
|
|
|
|
|
packet <destination> <contents>
|
|
|
|
Contents allows \n escape character
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Packet_f (void)
|
|
|
|
{
|
|
|
|
char send[2048];
|
2001-07-15 07:04:17 +00:00
|
|
|
char *out;
|
2001-08-28 23:05:45 +00:00
|
|
|
const char *in;
|
|
|
|
int i, l;
|
2001-02-19 21:15:25 +00:00
|
|
|
netadr_t adr;
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 3) {
|
|
|
|
Con_Printf ("packet <destination> <contents>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!NET_StringToAdr (Cmd_Argv (1), &adr)) {
|
|
|
|
Con_Printf ("Bad address\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
in = Cmd_Argv (2);
|
|
|
|
out = send + 4;
|
|
|
|
send[0] = send[1] = send[2] = send[3] = 0xff;
|
|
|
|
|
|
|
|
l = strlen (in);
|
|
|
|
for (i = 0; i < l; i++) {
|
|
|
|
if (in[i] == '\\' && in[i + 1] == 'n') {
|
|
|
|
*out++ = '\n';
|
|
|
|
i++;
|
|
|
|
} else
|
|
|
|
*out++ = in[i];
|
|
|
|
}
|
|
|
|
*out = 0;
|
|
|
|
|
|
|
|
NET_SendPacket (out - send, send, adr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_NextDemo
|
|
|
|
|
|
|
|
Called to play the next demo in the demo loop
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_NextDemo (void)
|
|
|
|
{
|
|
|
|
char str[1024];
|
|
|
|
|
|
|
|
if (cls.demonum == -1)
|
|
|
|
return; // don't play demos
|
|
|
|
|
|
|
|
if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS) {
|
|
|
|
cls.demonum = 0;
|
|
|
|
if (!cls.demos[cls.demonum][0]) {
|
|
|
|
cls.demonum = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_InsertText (cl_cbuf, str);
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.demonum++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_Changing_f
|
|
|
|
|
|
|
|
Just sent as a hint to the client that they should
|
|
|
|
drop to full console
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Changing_f (void)
|
|
|
|
{
|
|
|
|
if (cls.download) // don't change when downloading
|
|
|
|
return;
|
|
|
|
|
|
|
|
S_StopAllSounds (true);
|
|
|
|
cl.intermission = 0;
|
2001-08-19 03:51:52 +00:00
|
|
|
CL_SetState (ca_connected); // not active anymore, but not
|
2001-02-19 21:15:25 +00:00
|
|
|
// disconnected
|
|
|
|
Con_Printf ("\nChanging map...\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_Reconnect_f
|
|
|
|
|
|
|
|
The server is changing levels
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_Reconnect_f (void)
|
|
|
|
{
|
|
|
|
if (cls.download) // don't change when downloading
|
|
|
|
return;
|
|
|
|
|
|
|
|
S_StopAllSounds (true);
|
|
|
|
|
|
|
|
if (cls.state == ca_connected) {
|
|
|
|
Con_Printf ("reconnecting...\n");
|
|
|
|
VID_SetCaption ("Reconnecting");
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&cls.netchan.message, "new");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*cls.servername) {
|
|
|
|
Con_Printf ("No server to reconnect to...\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
CL_BeginServerConnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_ConnectionlessPacket
|
|
|
|
|
|
|
|
Responses to broadcasts, etc
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_ConnectionlessPacket (void)
|
|
|
|
{
|
2001-10-18 06:23:26 +00:00
|
|
|
const char *s;
|
2001-04-03 05:48:24 +00:00
|
|
|
int c, clcp_temp;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
MSG_BeginReading (net_message);
|
|
|
|
MSG_ReadLong (net_message); // skip the -1
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-23 23:16:13 +00:00
|
|
|
c = MSG_ReadByte (net_message);
|
2001-04-03 05:48:24 +00:00
|
|
|
clcp_temp = 0;
|
2001-12-05 21:56:52 +00:00
|
|
|
if (!cls.demoplayback
|
|
|
|
&& (cl_paranoid->int_val
|
|
|
|
|| !NET_CompareAdr (net_from, cls.server_addr)))
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("%s: ", NET_AdrToString (net_from));
|
|
|
|
if (c == S2C_CONNECTION) {
|
|
|
|
Con_Printf ("connection\n");
|
|
|
|
if (cls.state >= ca_connected) {
|
|
|
|
if (!cls.demoplayback)
|
|
|
|
Con_Printf ("Dup connect received. Ignored.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Netchan_Setup (&cls.netchan, net_from, cls.qport);
|
2002-07-02 19:13:53 +00:00
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&cls.netchan.message, "new");
|
2001-08-19 03:51:52 +00:00
|
|
|
CL_SetState (ca_connected);
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Connected.\n");
|
|
|
|
allowremotecmd = false; // localid required now for remote
|
|
|
|
// cmds
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// remote command from gui front end
|
|
|
|
if (c == A2C_CLIENT_COMMAND) {
|
|
|
|
char cmdtext[2048];
|
2001-10-18 06:23:26 +00:00
|
|
|
int len;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Con_Printf ("client command\n");
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
if (!cl_allow_cmd_pkt->int_val ||
|
|
|
|
((*(unsigned int *) net_from.ip !=
|
2002-07-03 05:40:33 +00:00
|
|
|
*(unsigned int *) net_local_adr.ip &&
|
|
|
|
*(unsigned int *) net_from.ip != htonl (INADDR_LOOPBACK)))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("Command packet from remote host. Ignored.\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
strncpy (cmdtext, s, sizeof (cmdtext) - 1);
|
|
|
|
cmdtext[sizeof (cmdtext) - 1] = 0;
|
|
|
|
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-08-02 03:22:32 +00:00
|
|
|
while (*s && isspace ((byte) *s))
|
2001-02-19 21:15:25 +00:00
|
|
|
s++;
|
2001-10-18 06:23:26 +00:00
|
|
|
len = strlen (s);
|
|
|
|
while (len && isspace ((byte) s[len - 1]))
|
|
|
|
len--;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-07-03 05:40:33 +00:00
|
|
|
if (!allowremotecmd && (!*localid->string ||
|
|
|
|
strlen (localid->string) > len ||
|
|
|
|
strncmp (localid->string, s, len))) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!*localid->string) {
|
|
|
|
Con_Printf ("===========================\n");
|
|
|
|
Con_Printf ("Command packet received from local host, but no "
|
2001-08-28 23:05:45 +00:00
|
|
|
"localid has been set. You may need to upgrade "
|
|
|
|
"your server browser.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("===========================\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Con_Printf ("===========================\n");
|
|
|
|
Con_Printf
|
|
|
|
("Invalid localid on command packet received from local host. "
|
|
|
|
"\n|%s| != |%s|\n"
|
|
|
|
"You may need to reload your server browser and %s.\n", s,
|
|
|
|
localid->string, PROGRAM);
|
|
|
|
Con_Printf ("===========================\n");
|
|
|
|
Cvar_Set (localid, "");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("%s\n", cmdtext);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, cmdtext);
|
2001-02-19 21:15:25 +00:00
|
|
|
allowremotecmd = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// print command from somewhere
|
|
|
|
if (c == A2C_PRINT) {
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-06-09 09:12:24 +00:00
|
|
|
if (SL_CheckStatus(NET_AdrToString (net_from), s))
|
|
|
|
{
|
|
|
|
Con_Printf("status response\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-07-11 19:17:58 +00:00
|
|
|
Con_Printf ("%s", s);
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// ping from somewhere
|
|
|
|
if (c == A2A_PING) {
|
|
|
|
char data[6];
|
|
|
|
|
|
|
|
Con_Printf ("ping\n");
|
|
|
|
|
|
|
|
data[0] = 0xff;
|
|
|
|
data[1] = 0xff;
|
|
|
|
data[2] = 0xff;
|
|
|
|
data[3] = 0xff;
|
|
|
|
data[4] = A2A_ACK;
|
|
|
|
data[5] = 0;
|
|
|
|
|
|
|
|
NET_SendPacket (6, &data, net_from);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (c == S2C_CHALLENGE) {
|
2001-12-05 21:56:52 +00:00
|
|
|
Con_Printf ("challenge");
|
2002-07-03 18:29:36 +00:00
|
|
|
if (cls.state >= ca_connected) {
|
|
|
|
if (!cls.demoplayback)
|
|
|
|
Con_Printf ("\nDup challenge received. Ignored.\n");
|
|
|
|
return;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.challenge = atoi (s);
|
2001-12-05 21:56:52 +00:00
|
|
|
if (strstr (s, "QF")) {
|
|
|
|
Con_Printf (": QuakeForge server detected\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_AddQFInfoKeys ();
|
2001-12-05 21:56:52 +00:00
|
|
|
} else {
|
|
|
|
Con_Printf ("\n");
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_SendConnectPacket ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-03 05:48:24 +00:00
|
|
|
if (c == M2C_MASTER_REPLY)
|
|
|
|
{
|
|
|
|
Con_Printf("Master Server Reply\n");
|
|
|
|
clcp_temp = MSG_ReadByte (net_message);
|
2001-10-18 06:23:26 +00:00
|
|
|
s = MSG_ReadString (net_message);
|
2001-04-03 05:48:24 +00:00
|
|
|
MSL_ParseServerList(s);
|
|
|
|
return;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
if (c == svc_disconnect) {
|
|
|
|
if (cls.demoplayback)
|
|
|
|
Host_EndGame ("End of demo");
|
|
|
|
else
|
|
|
|
Con_Printf ("svc_disconnect\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf ("unknown: %c\n", c);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ReadPackets (void)
|
|
|
|
{
|
|
|
|
while (CL_GetMessage ()) {
|
|
|
|
|
2002-03-15 07:35:22 +00:00
|
|
|
if (net_message->message->cursize == -1)
|
|
|
|
continue;
|
|
|
|
|
2001-05-31 15:38:08 +00:00
|
|
|
if (cls.demoplayback && net_packetlog->int_val)
|
2001-08-28 23:05:45 +00:00
|
|
|
Log_Incoming_Packet(net_message->message->data,
|
|
|
|
net_message->message->cursize);
|
2001-05-14 03:08:24 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// remote command packet
|
2001-02-23 23:16:13 +00:00
|
|
|
if (*(int *) net_message->message->data == -1) {
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ConnectionlessPacket ();
|
|
|
|
continue;
|
|
|
|
}
|
2001-02-23 23:16:13 +00:00
|
|
|
if (*(char *) net_message->message->data == A2A_ACK)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-06-09 09:12:24 +00:00
|
|
|
SL_CheckPing (NET_AdrToString (net_from));
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-02-23 23:16:13 +00:00
|
|
|
if (net_message->message->cursize < 8) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("%s: Runt packet\n", NET_AdrToString (net_from));
|
|
|
|
continue;
|
|
|
|
}
|
2001-05-14 03:08:24 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// packet from server
|
|
|
|
if (!cls.demoplayback &&
|
|
|
|
!NET_CompareAdr (net_from, cls.netchan.remote_address)) {
|
|
|
|
Con_DPrintf ("%s:sequenced packet without connection\n",
|
|
|
|
NET_AdrToString (net_from));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!Netchan_Process (&cls.netchan))
|
2002-07-03 05:40:33 +00:00
|
|
|
continue; // wasn't accepted for some reason
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseServerMessage ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// check timeout
|
|
|
|
if (cls.state >= ca_connected
|
|
|
|
&& realtime - cls.netchan.last_received > cl_timeout->value) {
|
|
|
|
Con_Printf ("\nServer connection timed out.\n");
|
|
|
|
CL_Disconnect ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Download_f (void)
|
|
|
|
{
|
|
|
|
if (cls.state == ca_disconnected) {
|
|
|
|
Con_Printf ("Must be connected.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 2) {
|
|
|
|
Con_Printf ("Usage: download <datafile>\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
snprintf (cls.downloadname, sizeof (cls.downloadname), "%s/%s",
|
|
|
|
com_gamedir, Cmd_Argv (1));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
COM_CreatePath (cls.downloadname);
|
|
|
|
|
|
|
|
strncpy (cls.downloadtempname, cls.downloadname,
|
|
|
|
sizeof (cls.downloadtempname));
|
|
|
|
cls.download = Qopen (cls.downloadname, "wb");
|
|
|
|
if (cls.download) {
|
|
|
|
cls.downloadtype = dl_single;
|
|
|
|
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
|
|
|
SZ_Print (&cls.netchan.message, va ("download %s\n", Cmd_Argv (1)));
|
|
|
|
} else {
|
|
|
|
Con_Printf ("error downloading %s: %s\n", Cmd_Argv (1),
|
2002-07-03 05:40:33 +00:00
|
|
|
strerror (errno));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-09 14:05:30 +00:00
|
|
|
void
|
|
|
|
cl_hudswap_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
if (cl_hudswap)
|
|
|
|
hudswap = cl_hudswap->int_val;
|
|
|
|
else
|
|
|
|
hudswap = 0;
|
|
|
|
}
|
|
|
|
|
2001-07-06 17:42:04 +00:00
|
|
|
void
|
|
|
|
Force_CenterView_f (void)
|
|
|
|
{
|
|
|
|
cl.viewangles[PITCH] = 0;
|
|
|
|
}
|
|
|
|
|
2001-08-19 03:51:52 +00:00
|
|
|
void
|
|
|
|
CL_SetState (cactive_t state)
|
|
|
|
{
|
2002-07-22 21:25:51 +00:00
|
|
|
cactive_t old_state = cls.state;
|
2001-08-19 03:51:52 +00:00
|
|
|
cls.state = state;
|
2002-07-22 21:25:51 +00:00
|
|
|
if (old_state != state) {
|
|
|
|
if (old_state == ca_active) {
|
|
|
|
// leaving active state
|
2002-07-22 21:47:01 +00:00
|
|
|
IN_ClearStates ();
|
2002-07-22 21:25:51 +00:00
|
|
|
r_active = false;
|
|
|
|
game_target = IMT_CONSOLE;
|
|
|
|
key_dest = key_console;
|
|
|
|
if (con_module)
|
|
|
|
con_module->data->console->force_commandline = 1;
|
2002-07-26 20:50:53 +00:00
|
|
|
// Auto demo recorder stops here
|
|
|
|
if(cl_autorecord->int_val && cls.demorecording)
|
|
|
|
CL_Stop_f ();
|
2002-07-22 21:25:51 +00:00
|
|
|
} else if (state == ca_active) {
|
|
|
|
// entering active state
|
2002-07-26 20:50:53 +00:00
|
|
|
VID_SetCaption (cls.servername);
|
2002-07-22 21:47:01 +00:00
|
|
|
IN_ClearStates ();
|
2002-07-22 21:25:51 +00:00
|
|
|
r_active = true;
|
|
|
|
game_target = IMT_0;
|
|
|
|
key_dest = key_game;
|
|
|
|
|
2002-07-26 20:50:53 +00:00
|
|
|
if (con_module)
|
|
|
|
con_module->data->console->force_commandline = 0;
|
|
|
|
|
|
|
|
// Auto demo recorder starts here
|
|
|
|
if(cl_autorecord->int_val && !cls.demoplayback
|
|
|
|
&& !cls.demorecording)
|
|
|
|
CL_Record (0);
|
2002-07-22 21:25:51 +00:00
|
|
|
}
|
2001-08-19 03:51:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_Init (void)
|
|
|
|
{
|
|
|
|
char st[80];
|
|
|
|
|
2001-08-19 03:51:52 +00:00
|
|
|
CL_SetState (ca_disconnected);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForKey (cls.userinfo, "name", "unnamed", 0);
|
|
|
|
Info_SetValueForKey (cls.userinfo, "topcolor", "0", 0);
|
|
|
|
Info_SetValueForKey (cls.userinfo, "bottomcolor", "0", 0);
|
|
|
|
Info_SetValueForKey (cls.userinfo, "rate", "2500", 0);
|
|
|
|
Info_SetValueForKey (cls.userinfo, "msg", "1", 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
snprintf (st, sizeof (st), "%s", QW_VERSION);
|
2001-11-04 07:50:39 +00:00
|
|
|
Info_SetValueForStarKey (cls.userinfo, "*ver", st, 0);
|
2001-05-19 00:05:35 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Input_Init ();
|
|
|
|
CL_Ents_Init ();
|
|
|
|
CL_TEnts_Init ();
|
|
|
|
Pmove_Init ();
|
|
|
|
|
2001-06-17 08:14:22 +00:00
|
|
|
SL_Init ();
|
2001-08-28 23:05:45 +00:00
|
|
|
|
|
|
|
// register our commands
|
2001-02-19 21:15:25 +00:00
|
|
|
Cmd_AddCommand ("version", CL_Version_f, "Report version information");
|
|
|
|
Cmd_AddCommand ("changing", CL_Changing_f, "Used when maps are changing");
|
|
|
|
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "Disconnect from server");
|
2002-07-03 05:40:33 +00:00
|
|
|
Cmd_AddCommand ("record", CL_Record_f, "Record a demo, if no filename "
|
|
|
|
"argument is given\n"
|
|
|
|
"the demo will be called Year-Month-Day-Hour-Minute-"
|
|
|
|
"Mapname");
|
2001-05-14 03:08:24 +00:00
|
|
|
Cmd_AddCommand ("rerecord", CL_ReRecord_f, "Rerecord a demo on the same "
|
|
|
|
"server");
|
2001-08-28 23:05:45 +00:00
|
|
|
Cmd_AddCommand ("snap", CL_RSShot_f, "Take a screenshot and upload it to "
|
|
|
|
"the server");
|
2001-02-19 21:15:25 +00:00
|
|
|
Cmd_AddCommand ("stop", CL_Stop_f, "Stop recording a demo");
|
|
|
|
Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "Play a recorded demo");
|
2001-05-14 03:08:24 +00:00
|
|
|
Cmd_AddCommand ("timedemo", CL_TimeDemo_f, "Play a demo as fast as your "
|
|
|
|
"hardware can. Useful for benchmarking.");
|
2001-11-05 22:24:16 +00:00
|
|
|
Cmd_AddCommand ("maplist", Con_Maplist_f, "List maps available");
|
2001-11-06 07:14:29 +00:00
|
|
|
Cmd_AddCommand ("skinlist", Con_Skinlist_f, "List skins available");
|
|
|
|
Cmd_AddCommand ("skyboxlist", Con_Skyboxlist_f, "List skyboxes available");
|
|
|
|
Cmd_AddCommand ("demolist", Con_Demolist_QWD_f, "List demos available");
|
2002-01-20 00:04:50 +00:00
|
|
|
if (!con_module)
|
|
|
|
Cmd_AddCommand ("quit", CL_Quit_f, "Exit the program");
|
2001-05-14 03:08:24 +00:00
|
|
|
Cmd_AddCommand ("connect", CL_Connect_f, "Connect to a server 'connect "
|
|
|
|
"hostname:port'");
|
|
|
|
Cmd_AddCommand ("reconnect", CL_Reconnect_f, "Reconnect to the last "
|
|
|
|
"server");
|
|
|
|
Cmd_AddCommand ("rcon", CL_Rcon_f, "Issue set of commands to the current "
|
|
|
|
"connected server or the one set in rcon_address");
|
|
|
|
Cmd_AddCommand ("packet", CL_Packet_f, "Send a packet with specified "
|
|
|
|
"contents to the destination");
|
|
|
|
Cmd_AddCommand ("user", CL_User_f, "Queries the user for his setinfo "
|
|
|
|
"information");
|
|
|
|
Cmd_AddCommand ("users", CL_Users_f, "Report information on connected "
|
|
|
|
"players and retrieve user ids");
|
|
|
|
Cmd_AddCommand ("setinfo", CL_SetInfo_f, "Sets information about your "
|
|
|
|
"QuakeWorld user.\n Used without a key it will list all "
|
|
|
|
"of your current settings.\n Specifying a non-existent "
|
|
|
|
"key and a value will create the new key.\n"
|
|
|
|
"Special Keys:\n b_switch - Determines the highest weapon "
|
|
|
|
"that Quake should switch to upon a backpack pickup.\n "
|
|
|
|
"w_switch - Determines the highest weapon that Quake "
|
|
|
|
"should switch to upon a weapon pickup.");
|
2002-07-03 05:40:33 +00:00
|
|
|
Cmd_AddCommand ("getinfo", CL_GetInfo_f, "Returns the value of client "
|
|
|
|
"info key $1");
|
2001-12-19 00:40:34 +00:00
|
|
|
Cmd_AddCommand ("fullinfo", CL_FullInfo_f, "Used by GameSpy and Qlist to "
|
2001-05-14 03:08:24 +00:00
|
|
|
"set setinfo variables");
|
2001-12-19 00:40:34 +00:00
|
|
|
Cmd_AddCommand ("fullserverinfo", CL_FullServerinfo_f, "Used by GameSpy "
|
2001-05-14 03:08:24 +00:00
|
|
|
"and Qlist to obtain server variables");
|
2002-07-03 05:40:33 +00:00
|
|
|
Cmd_AddCommand ("getserverinfo", CL_Getserverinfo_f, "Returns the value "
|
|
|
|
"corresponding to key $1 in the server info.");
|
2001-05-14 03:08:24 +00:00
|
|
|
Cmd_AddCommand ("download", CL_Download_f, "Manually download a quake "
|
|
|
|
"file from the server");
|
|
|
|
Cmd_AddCommand ("nextul", CL_NextUpload, "Tells the client to send the "
|
|
|
|
"next upload");
|
|
|
|
Cmd_AddCommand ("stopul", CL_StopUpload, "Tells the client to stop "
|
|
|
|
"uploading");
|
2001-08-28 23:05:45 +00:00
|
|
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
|
|
|
|
"to be level");
|
|
|
|
// forward to server commands
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_AddCommand ("kill", CL_Cmd_ForwardToServer, "Suicide :)");
|
|
|
|
Cmd_AddCommand ("pause", CL_Cmd_ForwardToServer, "Pause the game");
|
|
|
|
Cmd_AddCommand ("say", CL_Cmd_ForwardToServer, "Say something to all other "
|
2001-05-14 03:08:24 +00:00
|
|
|
"players");
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_AddCommand ("say_team", CL_Cmd_ForwardToServer, "Say something only to "
|
2001-05-14 03:08:24 +00:00
|
|
|
"people on your team");
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_AddCommand ("serverinfo", CL_Cmd_ForwardToServer, "Report the current "
|
2001-05-14 03:08:24 +00:00
|
|
|
"server info");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-02-22 05:48:59 +00:00
|
|
|
static void
|
|
|
|
cl_usleep_f (cvar_t *var)
|
|
|
|
{
|
|
|
|
cl_usleep_cache = var->int_val;
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
CL_Init_Cvars (void)
|
|
|
|
{
|
2001-06-02 23:29:41 +00:00
|
|
|
cl_model_crcs = Cvar_Get ("cl_model_crcs", "1", CVAR_ARCHIVE, NULL,
|
2001-08-28 23:05:45 +00:00
|
|
|
"Controls setting of emodel and pmodel info "
|
|
|
|
"vars. Required by some servers, but clearing "
|
|
|
|
"this can make the difference between "
|
|
|
|
"connecting and not connecting on some others.");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_allow_cmd_pkt = Cvar_Get ("cl_allow_cmd_pkt", "1", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"enables packets from the likes of gamespy");
|
2001-12-05 21:56:52 +00:00
|
|
|
cl_paranoid = Cvar_Get ("cl_paranoid", "1", CVAR_NONE, NULL,
|
|
|
|
"print source address of connectionless packets"
|
|
|
|
" even when coming from the server being connected"
|
|
|
|
" to.");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_autoexec = Cvar_Get ("cl_autoexec", "0", CVAR_ROM, NULL,
|
|
|
|
"exec autoexec.cfg on gamedir change");
|
2001-09-06 23:58:28 +00:00
|
|
|
cl_quakerc = Cvar_Get ("cl_quakerc", "1", CVAR_NONE, NULL,
|
|
|
|
"exec quake.rc on startup");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL,
|
2001-08-28 23:05:45 +00:00
|
|
|
"Show bonus flash on item pickup");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE,
|
|
|
|
NULL, "Shift view colors for contents "
|
|
|
|
"(water, slime, etc)");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL,
|
2001-08-28 23:05:45 +00:00
|
|
|
"Shift view colors on damage");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL,
|
2001-08-28 23:05:45 +00:00
|
|
|
"Shift view colors for powerups");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL,
|
|
|
|
"turn `run' speed multiplier");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"backward speed");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_forwardspeed = Cvar_Get ("cl_forwardspeed", "200", CVAR_ARCHIVE, NULL,
|
|
|
|
"forward speed");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_movespeedkey = Cvar_Get ("cl_movespeedkey", "2.0", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"move `run' speed multiplier");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_pitchspeed = Cvar_Get ("cl_pitchspeed", "150", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"look up/down speed");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_sidespeed = Cvar_Get ("cl_sidespeed", "350", CVAR_NONE, NULL,
|
|
|
|
"strafe speed");
|
|
|
|
cl_upspeed = Cvar_Get ("cl_upspeed", "200", CVAR_NONE, NULL,
|
|
|
|
"swim/fly up/down speed");
|
|
|
|
cl_yawspeed = Cvar_Get ("cl_yawspeed", "140", CVAR_NONE, NULL,
|
|
|
|
"turning speed");
|
2001-05-19 20:57:29 +00:00
|
|
|
cl_writecfg = Cvar_Get ("cl_writecfg", "1", CVAR_NONE, NULL,
|
|
|
|
"write config files?");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"show network packets. 0=off, 1=basic, 2=verbose");
|
2001-08-28 23:05:45 +00:00
|
|
|
cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_f,
|
|
|
|
"status bar mode");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_sbar_separator = Cvar_Get ("cl_sbar_separator", "0", CVAR_ARCHIVE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"turns on status bar separator");
|
2001-12-09 14:05:30 +00:00
|
|
|
cl_hudswap = Cvar_Get ("cl_hudswap", "0", CVAR_ARCHIVE, cl_hudswap_f,
|
2001-02-19 21:15:25 +00:00
|
|
|
"new HUD on left side?");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_maxfps = Cvar_Get ("cl_maxfps", "0", CVAR_ARCHIVE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"maximum frames rendered in one second. 0 == 32");
|
2001-05-14 05:16:59 +00:00
|
|
|
cl_timeout = Cvar_Get ("cl_timeout", "60", CVAR_ARCHIVE, NULL, "server "
|
|
|
|
"connection timeout (since last packet received)");
|
2001-05-14 05:21:27 +00:00
|
|
|
host_speeds = Cvar_Get ("host_speeds", "0", CVAR_NONE, NULL,
|
2001-05-14 05:16:59 +00:00
|
|
|
"display host processing times");
|
|
|
|
lookspring = Cvar_Get ("lookspring", "0", CVAR_ARCHIVE, NULL, "Snap view "
|
|
|
|
"to center when moving and no mlook/klook");
|
|
|
|
m_forward = Cvar_Get ("m_forward", "1", CVAR_NONE, NULL,
|
|
|
|
"mouse forward/back speed");
|
2001-04-10 23:39:30 +00:00
|
|
|
m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"mouse pitch (up/down) multipier");
|
2001-05-14 05:16:59 +00:00
|
|
|
m_side = Cvar_Get ("m_side", "0.8", CVAR_NONE, NULL, "mouse strafe speed");
|
2001-04-10 23:39:30 +00:00
|
|
|
m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"mouse yaw (left/right) multiplier");
|
2001-04-10 23:39:30 +00:00
|
|
|
rcon_password = Cvar_Get ("rcon_password", "", CVAR_NONE, NULL,
|
2001-02-19 21:15:25 +00:00
|
|
|
"remote control password");
|
2001-05-14 03:08:24 +00:00
|
|
|
rcon_address = Cvar_Get ("rcon_address", "", CVAR_NONE, NULL, "server IP "
|
|
|
|
"address when client not connected - for "
|
|
|
|
"sending rcon commands");
|
2002-02-19 00:58:17 +00:00
|
|
|
show_fps = Cvar_Get ("show_fps", "0", CVAR_ARCHIVE, NULL,
|
2001-05-14 05:16:59 +00:00
|
|
|
"display realtime frames per second");
|
2002-02-19 00:58:17 +00:00
|
|
|
show_ping = Cvar_Get ("show_ping", "0", CVAR_ARCHIVE, NULL,
|
2001-08-11 04:14:58 +00:00
|
|
|
"display current ping to server");
|
2002-02-19 00:58:17 +00:00
|
|
|
show_pl = Cvar_Get ("show_pl", "0", CVAR_ARCHIVE, NULL,
|
2001-08-11 04:14:58 +00:00
|
|
|
"display current packet loss to server");
|
2002-02-19 00:58:17 +00:00
|
|
|
show_time = Cvar_Get ("show_time", "0", CVAR_ARCHIVE, NULL,
|
2001-12-19 00:40:34 +00:00
|
|
|
"Display the current time, 1 24hr, 2 AM/PM");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_predict_players = Cvar_Get ("cl_predict_players", "1", CVAR_NONE, NULL,
|
2001-09-07 17:44:02 +00:00
|
|
|
"If this is 0, no player prediction is "
|
|
|
|
"done");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_solid_players = Cvar_Get ("cl_solid_players", "1", CVAR_NONE, NULL,
|
2001-05-14 03:08:24 +00:00
|
|
|
"Are players solid? If off, you can walk "
|
|
|
|
"through them with difficulty");
|
2001-12-19 00:40:34 +00:00
|
|
|
localid = Cvar_Get ("localid", "", CVAR_NONE, NULL, "Used by "
|
|
|
|
"gamespy+others to authenticate when sending "
|
|
|
|
"commands to the client");
|
2001-08-21 05:35:35 +00:00
|
|
|
cl_timeframes = Cvar_Get ("cl_timeframes", "0", CVAR_ARCHIVE, NULL,
|
|
|
|
"write timestamps for every frame");
|
2001-02-19 21:15:25 +00:00
|
|
|
// info mirrors
|
2001-05-13 04:01:06 +00:00
|
|
|
cl_name = Cvar_Get ("name", "unnamed", CVAR_ARCHIVE | CVAR_USERINFO,
|
|
|
|
Cvar_Info, "Player name");
|
2001-04-10 23:39:30 +00:00
|
|
|
password = Cvar_Get ("password", "", CVAR_USERINFO, Cvar_Info,
|
2001-05-14 05:16:59 +00:00
|
|
|
"Server password");
|
2001-03-31 01:02:52 +00:00
|
|
|
spectator = Cvar_Get ("spectator", "", CVAR_USERINFO, Cvar_Info,
|
2001-02-19 21:15:25 +00:00
|
|
|
"Set to 1 before connecting to become a spectator");
|
2001-03-31 01:02:52 +00:00
|
|
|
team = Cvar_Get ("team", "", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
2001-02-19 21:15:25 +00:00
|
|
|
"Team player is on.");
|
2001-03-31 01:02:52 +00:00
|
|
|
rate = Cvar_Get ("rate", "2500", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
2001-05-14 05:16:59 +00:00
|
|
|
"Amount of bytes per second server will send/download "
|
|
|
|
"to you");
|
2001-04-10 23:39:30 +00:00
|
|
|
msg = Cvar_Get ("msg", "1", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
2001-05-14 05:16:59 +00:00
|
|
|
"Determines the type of messages reported 0 is maximum, "
|
|
|
|
"4 is none");
|
2001-03-31 01:02:52 +00:00
|
|
|
noaim = Cvar_Get ("noaim", "0", CVAR_ARCHIVE | CVAR_USERINFO, Cvar_Info,
|
2001-02-19 21:15:25 +00:00
|
|
|
"Auto aim off switch. Set to 1 to turn off.");
|
2001-05-30 18:50:17 +00:00
|
|
|
cl_port = Cvar_Get ("cl_port", PORT_CLIENT, CVAR_NONE, Cvar_Info,
|
|
|
|
"UDP Port for client to use.");
|
2002-02-22 05:48:59 +00:00
|
|
|
cl_usleep = Cvar_Get ("cl_usleep", "0", CVAR_ARCHIVE, cl_usleep_f,
|
|
|
|
"Turn this on to save cpu when fps limited. "
|
|
|
|
"May affect frame rate adversely depending on "
|
|
|
|
"local machine/os conditions");
|
2002-07-03 05:40:33 +00:00
|
|
|
cl_autorecord = Cvar_Get ("cl_autorecord", "0", CVAR_ARCHIVE, NULL, "Turn "
|
|
|
|
"this on, if you want to record every game");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Host_EndGame
|
|
|
|
|
|
|
|
Call this to drop to a console without exiting the qwcl
|
|
|
|
*/
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
Host_EndGame (const char *message, ...)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
char string[1024];
|
2001-08-28 23:05:45 +00:00
|
|
|
va_list argptr;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
va_start (argptr, message);
|
|
|
|
vsnprintf (string, sizeof (string), message, argptr);
|
|
|
|
va_end (argptr);
|
|
|
|
Con_Printf ("\n===========================\n");
|
|
|
|
Con_Printf ("Host_EndGame: %s\n", string);
|
|
|
|
Con_Printf ("===========================\n\n");
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
|
|
|
|
longjmp (host_abort, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Host_Error
|
|
|
|
|
|
|
|
This shuts down the client and exits qwcl
|
|
|
|
*/
|
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
Host_Error (const char *error, ...)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
char string[1024];
|
|
|
|
static qboolean inerror = false;
|
2001-08-28 23:05:45 +00:00
|
|
|
va_list argptr;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (inerror)
|
|
|
|
Sys_Error ("Host_Error: recursively entered");
|
|
|
|
inerror = true;
|
|
|
|
|
|
|
|
va_start (argptr, error);
|
2001-11-12 20:46:11 +00:00
|
|
|
Con_Printf ("Host_Error: ");
|
|
|
|
Con_Print (error, argptr);
|
2001-02-19 21:15:25 +00:00
|
|
|
va_end (argptr);
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
cls.demonum = -1;
|
|
|
|
|
|
|
|
inerror = false;
|
|
|
|
|
|
|
|
// FIXME
|
2001-11-12 20:46:11 +00:00
|
|
|
if (host_initialized) {
|
|
|
|
longjmp (host_abort, 1);
|
|
|
|
} else {
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("Host_Error: %s", string);
|
2001-11-12 20:46:11 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Host_WriteConfiguration
|
|
|
|
|
|
|
|
Writes key bindings and archived cvars to config.cfg
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Host_WriteConfiguration (void)
|
|
|
|
{
|
2001-05-30 03:21:19 +00:00
|
|
|
VFile *f;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-02-19 19:24:18 +00:00
|
|
|
if (host_initialized && cl_writecfg->int_val) {
|
2001-02-19 21:15:25 +00:00
|
|
|
char *path = va ("%s/config.cfg", com_gamedir);
|
|
|
|
|
|
|
|
COM_CreatePath (path);
|
|
|
|
f = Qopen (path, "w");
|
|
|
|
if (!f) {
|
|
|
|
Con_Printf ("Couldn't write config.cfg.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Key_WriteBindings (f);
|
|
|
|
Cvar_WriteVariables (f);
|
|
|
|
|
|
|
|
Qclose (f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Host_SimulationTime
|
|
|
|
|
2001-05-17 10:10:40 +00:00
|
|
|
This determines if enough time has passed to run a simulation frame, or
|
|
|
|
returns the amount of time that has to be waited
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-05-17 10:10:40 +00:00
|
|
|
static inline float
|
2001-02-19 21:15:25 +00:00
|
|
|
Host_SimulationTime (float time)
|
|
|
|
{
|
2001-08-28 23:05:45 +00:00
|
|
|
float fps, timedifference;
|
2001-02-19 21:15:25 +00:00
|
|
|
float timescale = 1.0;
|
|
|
|
|
|
|
|
if (cls.demoplayback) {
|
2002-06-08 23:22:26 +00:00
|
|
|
timescale = max (0, demo_speed->value);
|
2001-02-19 21:15:25 +00:00
|
|
|
time *= timescale;
|
|
|
|
}
|
|
|
|
|
|
|
|
realtime += time;
|
|
|
|
if (oldrealtime > realtime)
|
|
|
|
oldrealtime = 0;
|
|
|
|
|
2002-04-25 19:38:15 +00:00
|
|
|
if (cls.timedemo)
|
|
|
|
return 0;
|
|
|
|
|
2002-04-25 17:16:40 +00:00
|
|
|
if (!cl_maxfps->int_val)
|
2002-04-25 16:50:56 +00:00
|
|
|
return 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-04-25 17:16:40 +00:00
|
|
|
fps = max (1, cl_maxfps->value);
|
|
|
|
|
2001-05-17 10:10:40 +00:00
|
|
|
timedifference = (timescale / fps) - (realtime - oldrealtime);
|
|
|
|
|
2002-04-25 17:16:40 +00:00
|
|
|
if (timedifference > 0)
|
2001-05-17 10:10:40 +00:00
|
|
|
return timedifference; // framerate is too high
|
|
|
|
return 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
int nopacketcount;
|
2001-05-09 22:40:51 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
Host_Frame
|
|
|
|
|
|
|
|
Runs all active servers
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
Host_Frame (float time)
|
|
|
|
{
|
2002-07-03 05:40:33 +00:00
|
|
|
static double time1 = 0;
|
|
|
|
static double time2 = 0;
|
|
|
|
static double time3 = 0;
|
|
|
|
float sleeptime;
|
|
|
|
int pass1, pass2, pass3;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
if (setjmp (host_abort))
|
|
|
|
// something bad happened, or the server disconnected
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
// decide the simulation time
|
2001-05-17 10:10:40 +00:00
|
|
|
if ((sleeptime = Host_SimulationTime (time)) != 0) {
|
2002-02-22 05:48:59 +00:00
|
|
|
#ifdef HAVE_USLEEP
|
|
|
|
if (cl_usleep_cache && sleeptime > 0.002) // minimum sleep time
|
|
|
|
usleep ((unsigned long)(sleeptime * 1000000 / 2));
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
return; // framerate is too high
|
2001-05-17 10:10:40 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
host_frametime = realtime - oldrealtime;
|
|
|
|
oldrealtime = realtime;
|
|
|
|
host_frametime = min (host_frametime, 0.2);
|
|
|
|
|
|
|
|
// get new key events
|
|
|
|
IN_SendKeyEvents ();
|
|
|
|
|
|
|
|
// allow mouses or other external controllers to add commands
|
|
|
|
IN_Commands ();
|
|
|
|
|
|
|
|
// process console commands
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_Execute (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// fetch results from server
|
|
|
|
CL_ReadPackets ();
|
|
|
|
|
2001-11-11 07:02:38 +00:00
|
|
|
if (cl.no_pogo_stick && !no_pogo_stick->int_val)
|
2001-02-19 21:15:25 +00:00
|
|
|
Cvar_Set (no_pogo_stick, "1");
|
|
|
|
|
|
|
|
// send intentions now
|
|
|
|
// resend a connection request if necessary
|
|
|
|
if (cls.state == ca_disconnected) {
|
|
|
|
CL_CheckForResend ();
|
2001-09-11 04:53:20 +00:00
|
|
|
} else {
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_SendCmd ();
|
|
|
|
|
2001-09-11 04:53:20 +00:00
|
|
|
// Set up prediction for other players
|
|
|
|
CL_SetUpPlayerPrediction (false);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-11 04:53:20 +00:00
|
|
|
// do client side motion prediction
|
|
|
|
CL_PredictMove ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-11 04:53:20 +00:00
|
|
|
// Set up prediction for other players
|
2001-11-15 19:37:29 +00:00
|
|
|
CL_SetUpPlayerPrediction (cl_predict_players->int_val);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-11 04:53:20 +00:00
|
|
|
// build a refresh entity list
|
|
|
|
CL_EmitEntities ();
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// update video
|
|
|
|
if (host_speeds->int_val)
|
|
|
|
time1 = Sys_DoubleTime ();
|
|
|
|
|
2001-05-20 20:38:51 +00:00
|
|
|
r_inhibit_viewmodel = (!Cam_DrawViewModel ()
|
|
|
|
|| (cl.stats[STAT_ITEMS] & IT_INVISIBILITY)
|
|
|
|
|| cl.stats[STAT_HEALTH] <= 0);
|
|
|
|
r_force_fullscreen = cl.intermission;
|
2001-05-21 00:22:35 +00:00
|
|
|
r_paused = cl.paused;
|
2001-05-23 04:05:10 +00:00
|
|
|
r_active = cls.state == ca_active;
|
2001-05-20 20:38:51 +00:00
|
|
|
r_view_model = &cl.viewent;
|
2001-05-24 19:22:35 +00:00
|
|
|
r_frametime = host_frametime;
|
2001-05-20 20:38:51 +00:00
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
CL_UpdateScreen (realtime);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (host_speeds->int_val)
|
|
|
|
time2 = Sys_DoubleTime ();
|
|
|
|
|
|
|
|
// update audio
|
|
|
|
if (cls.state == ca_active) {
|
|
|
|
S_Update (r_origin, vpn, vright, vup);
|
2001-05-20 06:23:46 +00:00
|
|
|
R_DecayLights (host_frametime);
|
2001-02-19 21:15:25 +00:00
|
|
|
} else
|
|
|
|
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
|
|
|
|
|
|
|
|
CDAudio_Update ();
|
|
|
|
|
|
|
|
if (host_speeds->int_val) {
|
|
|
|
pass1 = (time1 - time3) * 1000;
|
|
|
|
time3 = Sys_DoubleTime ();
|
|
|
|
pass2 = (time2 - time1) * 1000;
|
|
|
|
pass3 = (time3 - time2) * 1000;
|
|
|
|
Con_Printf ("%3i tot %3i server %3i gfx %3i snd\n",
|
|
|
|
pass1 + pass2 + pass3, pass1, pass2, pass3);
|
|
|
|
}
|
|
|
|
|
2001-11-24 08:21:07 +00:00
|
|
|
// CL_TimeFrames_AddTimestamp ();
|
2001-08-21 05:35:35 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
host_framecount++;
|
|
|
|
fps_count++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_quakerc (void)
|
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *l, *p;
|
2001-02-19 21:15:25 +00:00
|
|
|
int ret = 1;
|
2001-08-28 23:05:45 +00:00
|
|
|
VFile *f;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
COM_FOpenFile ("quake.rc", &f);
|
|
|
|
if (!f)
|
|
|
|
return 1;
|
|
|
|
while ((l = Qgetline (f))) {
|
|
|
|
if ((p = strstr (l, "stuffcmds"))) {
|
|
|
|
if (p == l) { // only known case so far
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Qclose (f);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-11-14 20:18:37 +00:00
|
|
|
CL_Init_Memory (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-11-14 20:18:37 +00:00
|
|
|
int mem_parm = COM_CheckParm ("-mem");
|
|
|
|
int mem_size;
|
|
|
|
void *mem_base;
|
|
|
|
|
|
|
|
cl_mem_size = Cvar_Get ("cl_mem_size", "16", CVAR_NONE, NULL,
|
|
|
|
"Amount of memory (in MB) to allocate for the "
|
|
|
|
PROGRAM " heap");
|
|
|
|
if (mem_parm)
|
|
|
|
Cvar_Set (cl_mem_size, com_argv[mem_parm + 1]);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (COM_CheckParm ("-minmemory"))
|
2001-11-14 20:18:37 +00:00
|
|
|
Cvar_SetValue (cl_mem_size, MINIMUM_MEMORY / (1024 * 1024.0));
|
|
|
|
|
|
|
|
Cvar_SetFlags (cl_mem_size, cl_mem_size->flags | CVAR_ROM);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-14 20:18:37 +00:00
|
|
|
mem_size = (int) (cl_mem_size->value * 1024 * 1024);
|
|
|
|
|
|
|
|
if (mem_size < MINIMUM_MEMORY)
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Error ("Only %4.1f megs of memory reported, can't execute game",
|
2001-11-14 20:18:37 +00:00
|
|
|
mem_size / (float) 0x100000);
|
|
|
|
|
|
|
|
mem_base = malloc (mem_size);
|
|
|
|
|
|
|
|
if (!mem_base)
|
2002-05-14 06:12:29 +00:00
|
|
|
Sys_Error ("Can't allocate %d", mem_size);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-02-19 20:47:45 +00:00
|
|
|
Sys_PageIn (mem_base, mem_size);
|
2001-11-14 20:18:37 +00:00
|
|
|
Memory_Init (mem_base, mem_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Host_Init (void)
|
|
|
|
{
|
2002-07-31 22:03:53 +00:00
|
|
|
cl_cbuf = Cbuf_New (COM_extract_line, COM_parse_line, NULL, NULL);
|
2002-07-31 05:19:03 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
Cvar_Init_Hash ();
|
|
|
|
Cmd_Init_Hash ();
|
|
|
|
Cvar_Init ();
|
|
|
|
Sys_Init_Cvars ();
|
|
|
|
|
|
|
|
Cmd_Init ();
|
|
|
|
|
|
|
|
// execute +set as early as possible
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (cl_cbuf);
|
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// execute the global configuration file if it exists
|
|
|
|
// would have been nice if Cmd_Exec_f could have been used, but it
|
|
|
|
// only reads from within the quake file system, and changing that is
|
|
|
|
// probably Not A Good Thing (tm).
|
2001-04-11 00:10:19 +00:00
|
|
|
fs_globalcfg = Cvar_Get ("fs_globalcfg", FS_GLOBALCFG, CVAR_ROM, NULL,
|
|
|
|
"global configuration file");
|
2002-07-31 06:06:44 +00:00
|
|
|
Cmd_Exec_File (cl_cbuf, fs_globalcfg->string);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// execute +set again to override the config file
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (cl_cbuf);
|
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-04-11 00:10:19 +00:00
|
|
|
fs_usercfg = Cvar_Get ("fs_usercfg", FS_USERCFG, CVAR_ROM, NULL,
|
2001-05-17 07:52:37 +00:00
|
|
|
"user configuration file");
|
2002-07-31 06:06:44 +00:00
|
|
|
Cmd_Exec_File (cl_cbuf, fs_usercfg->string);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
// execute +set again to override the config file
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (cl_cbuf);
|
|
|
|
Cbuf_Execute_Sets (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-14 20:18:37 +00:00
|
|
|
CL_Init_Memory ();
|
|
|
|
|
2002-04-11 18:42:55 +00:00
|
|
|
pr_gametype = "quakeworld";
|
|
|
|
|
2001-11-14 20:18:37 +00:00
|
|
|
cls.userinfo = Info_ParseString ("", MAX_INFO_STRING);
|
|
|
|
cl.serverinfo = Info_ParseString ("", MAX_INFO_STRING);
|
|
|
|
|
2001-04-25 00:20:23 +00:00
|
|
|
PI_Init ();
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Cam_Init_Cvars ();
|
|
|
|
CL_Input_Init_Cvars ();
|
2001-05-11 22:47:15 +00:00
|
|
|
CL_Skin_Init_Cvars ();
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_Init_Cvars ();
|
|
|
|
CL_Prediction_Init_Cvars ();
|
|
|
|
COM_Init_Cvars ();
|
|
|
|
Con_Init_Cvars ();
|
|
|
|
COM_Filesystem_Init_Cvars ();
|
2001-03-30 00:44:35 +00:00
|
|
|
Game_Init_Cvars ();
|
2001-02-19 21:15:25 +00:00
|
|
|
IN_Init_Cvars ();
|
|
|
|
Key_Init_Cvars ();
|
|
|
|
Mod_Init_Cvars ();
|
|
|
|
Netchan_Init_Cvars ();
|
2002-01-18 19:19:33 +00:00
|
|
|
PR_Init_Cvars ();
|
2001-02-19 21:15:25 +00:00
|
|
|
Pmove_Init_Cvars ();
|
|
|
|
R_Init_Cvars ();
|
2002-01-04 03:32:59 +00:00
|
|
|
R_Particles_Init_Cvars ();
|
2001-02-19 21:15:25 +00:00
|
|
|
S_Init_Cvars ();
|
|
|
|
Team_Init_Cvars ();
|
|
|
|
V_Init_Cvars ();
|
|
|
|
VID_Init_Cvars ();
|
|
|
|
|
2002-01-18 19:19:33 +00:00
|
|
|
PR_Init ();
|
2002-01-20 04:10:36 +00:00
|
|
|
BI_Init ();
|
2002-01-18 19:19:33 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
CL_Cmd_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
V_Init ();
|
2001-03-30 00:30:38 +00:00
|
|
|
COM_Filesystem_Init ();
|
|
|
|
Game_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
COM_Init ();
|
|
|
|
|
2002-01-17 04:11:36 +00:00
|
|
|
PI_RegisterPlugins (client_plugin_list);
|
|
|
|
Con_Init ("client");
|
|
|
|
if (con_module) {
|
|
|
|
con_module->data->console->dl_name = cls.downloadname;
|
|
|
|
con_module->data->console->dl_percent = &cls.downloadpercent;
|
|
|
|
con_module->data->console->realtime = &realtime;
|
2002-01-20 00:04:50 +00:00
|
|
|
con_module->data->console->quit = CL_Quit_f;
|
2002-07-31 05:19:03 +00:00
|
|
|
con_module->data->console->cbuf = cl_cbuf;
|
2002-01-17 04:11:36 +00:00
|
|
|
}
|
|
|
|
|
2001-05-30 18:50:17 +00:00
|
|
|
NET_Init (cl_port->int_val);
|
2001-02-19 21:15:25 +00:00
|
|
|
Netchan_Init ();
|
2001-05-29 18:14:12 +00:00
|
|
|
{
|
2001-07-15 07:04:17 +00:00
|
|
|
static const char *sound_precache[MAX_MODELS];
|
2001-05-29 18:14:12 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_MODELS; i++)
|
|
|
|
sound_precache[i] = cl.sound_name[i];
|
|
|
|
Net_Log_Init (sound_precache);
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
W_LoadWadFile ("gfx.wad");
|
|
|
|
Key_Init ();
|
|
|
|
Mod_Init ();
|
|
|
|
|
2002-06-08 23:22:26 +00:00
|
|
|
CL_Demo_Init();
|
2001-08-21 05:35:35 +00:00
|
|
|
|
2002-01-17 04:11:36 +00:00
|
|
|
Con_Printf ("%4.1f megabyte heap.\n", cl_mem_size->value);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
vid_basepal = (byte *) COM_LoadHunkFile ("gfx/palette.lmp");
|
|
|
|
if (!vid_basepal)
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Error ("Couldn't load gfx/palette.lmp");
|
2001-04-15 04:18:22 +00:00
|
|
|
vid_colormap = (byte *) COM_LoadHunkFile ("gfx/colormap.lmp");
|
|
|
|
if (!vid_colormap)
|
2001-02-19 21:15:25 +00:00
|
|
|
Sys_Error ("Couldn't load gfx/colormap.lmp");
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
VID_Init (vid_basepal);
|
2001-02-19 21:15:25 +00:00
|
|
|
Draw_Init ();
|
|
|
|
SCR_Init ();
|
|
|
|
R_Init ();
|
|
|
|
|
2001-10-28 04:23:37 +00:00
|
|
|
S_Init (&cl.worldmodel, &viewentity, &host_frametime);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
CDAudio_Init ();
|
|
|
|
Sbar_Init ();
|
|
|
|
CL_Init ();
|
|
|
|
IN_Init ();
|
2002-01-17 04:11:36 +00:00
|
|
|
|
|
|
|
CL_SetState (ca_disconnected);
|
|
|
|
CL_Skin_Init ();
|
|
|
|
Locs_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-06 23:58:28 +00:00
|
|
|
if (cl_quakerc->int_val)
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_InsertText (cl_cbuf, "exec quake.rc\n");
|
2002-07-31 06:06:44 +00:00
|
|
|
Cmd_Exec_File (cl_cbuf, fs_usercfg->string);
|
2001-02-19 21:15:25 +00:00
|
|
|
// Reparse the command line for + commands.
|
|
|
|
// (Note, no non-base commands exist yet)
|
2001-09-09 01:58:16 +00:00
|
|
|
if (!cl_quakerc->int_val || check_quakerc ())
|
2002-07-31 05:19:03 +00:00
|
|
|
Cmd_StuffCmds (cl_cbuf);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Hunk_AllocName (0, "-HOST_HUNKLEVEL-");
|
|
|
|
host_hunklevel = Hunk_LowMark ();
|
|
|
|
|
|
|
|
host_initialized = true;
|
|
|
|
|
|
|
|
Con_Printf ("\nClient version %s (build %04d)\n\n", VERSION,
|
|
|
|
build_number ());
|
|
|
|
|
2002-01-17 04:11:36 +00:00
|
|
|
Con_Printf ("\x80\x81\x81\x82 %s initialized \x80\x81\x81\x82\n", PROGRAM);
|
2002-07-03 05:40:33 +00:00
|
|
|
Con_NewMap (); // force the menus to be loaded
|
2002-01-18 19:19:33 +00:00
|
|
|
|
2001-05-23 06:33:23 +00:00
|
|
|
CL_UpdateScreen (realtime);
|
2002-04-11 18:42:55 +00:00
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf,
|
|
|
|
"echo Type connect <internet address> or use a server "
|
2002-04-11 18:42:55 +00:00
|
|
|
"browser to connect to a game.\n");
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, "cmd_warncmd 1\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Host_Shutdown (void)
|
|
|
|
{
|
|
|
|
static qboolean isdown = false;
|
|
|
|
|
|
|
|
if (isdown) {
|
|
|
|
printf ("recursive shutdown\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
isdown = true;
|
|
|
|
|
2001-06-09 09:12:24 +00:00
|
|
|
SL_Shutdown ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Host_WriteConfiguration ();
|
|
|
|
|
|
|
|
CDAudio_Shutdown ();
|
|
|
|
NET_Shutdown ();
|
|
|
|
S_Shutdown ();
|
|
|
|
IN_Shutdown ();
|
2001-04-15 04:18:22 +00:00
|
|
|
if (vid_basepal)
|
2001-02-19 21:15:25 +00:00
|
|
|
VID_Shutdown ();
|
|
|
|
}
|
2002-08-01 19:49:10 +00:00
|
|
|
|
|
|
|
qboolean
|
|
|
|
ServerPaused (void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|