2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_main.c
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
entity parsing and management
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2011-12-22 06:44:28 +00:00
|
|
|
#include "QF/cdaudio.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/cmd.h"
|
|
|
|
#include "QF/console.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cvar.h"
|
2011-12-22 06:44:28 +00:00
|
|
|
#include "QF/draw.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/input.h"
|
2013-01-25 19:27:38 +00:00
|
|
|
#include "QF/joystick.h"
|
2001-05-15 05:27:14 +00:00
|
|
|
#include "QF/keys.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/msg.h"
|
2021-03-21 07:13:03 +00:00
|
|
|
#include "QF/plist.h"
|
2001-05-21 22:25:35 +00:00
|
|
|
#include "QF/render.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/screen.h"
|
2001-05-21 22:25:35 +00:00
|
|
|
#include "QF/skin.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/va.h"
|
|
|
|
|
2012-02-13 12:58:34 +00:00
|
|
|
#include "QF/plugin/console.h"
|
2012-02-14 08:28:09 +00:00
|
|
|
#include "QF/plugin/vid_render.h"
|
2021-07-24 05:19:52 +00:00
|
|
|
#include "QF/scene/entity.h"
|
2012-02-13 12:58:34 +00:00
|
|
|
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "compat.h"
|
2011-12-22 06:44:28 +00:00
|
|
|
#include "sbar.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "client/temp_entities.h"
|
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/chase.h"
|
|
|
|
#include "nq/include/cl_skin.h"
|
|
|
|
#include "nq/include/client.h"
|
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/server.h"
|
|
|
|
|
2012-02-26 09:45:50 +00:00
|
|
|
CLIENT_PLUGIN_PROTOS
|
|
|
|
static plugin_list_t client_plugin_list[] = {
|
|
|
|
CLIENT_PLUGIN_LIST
|
|
|
|
};
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
// these two are not intended to be set directly
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_name;
|
2012-01-23 07:16:30 +00:00
|
|
|
cvar_t *cl_color;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-05-19 20:57:29 +00:00
|
|
|
cvar_t *cl_writecfg;
|
2001-05-14 19:46:16 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_shownet;
|
|
|
|
cvar_t *cl_nolerp;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-21 23:23:22 +00:00
|
|
|
cvar_t *cl_cshift_bonus;
|
|
|
|
cvar_t *cl_cshift_contents;
|
|
|
|
cvar_t *cl_cshift_damage;
|
|
|
|
cvar_t *cl_cshift_powerup;
|
2001-05-13 22:57:27 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *lookspring;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *m_pitch;
|
|
|
|
cvar_t *m_yaw;
|
|
|
|
cvar_t *m_forward;
|
|
|
|
cvar_t *m_side;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2003-07-27 23:20:11 +00:00
|
|
|
cvar_t *hud_fps;
|
|
|
|
cvar_t *hud_time;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int fps_count;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
client_static_t cls;
|
|
|
|
client_state_t cl;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-12-22 06:44:28 +00:00
|
|
|
/*
|
|
|
|
CL_WriteConfiguration
|
|
|
|
|
|
|
|
Writes key bindings and archived cvars to config.cfg
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
CL_WriteConfiguration (void)
|
|
|
|
{
|
|
|
|
// dedicated servers initialize the host but don't parse and set the
|
|
|
|
// config.cfg cvars
|
|
|
|
if (host_initialized && !isDedicated && cl_writecfg->int_val) {
|
2021-04-12 13:09:09 +00:00
|
|
|
const char *path = va (0, "%s/quakeforge.cfg", qfs_gamedir->dir.def);
|
|
|
|
QFile *f = QFS_WOpen (path, 0);
|
|
|
|
|
2011-12-22 06:44:28 +00:00
|
|
|
if (!f) {
|
2021-04-12 13:09:09 +00:00
|
|
|
Sys_Printf ("Couldn't write quakeforge.cfg.\n");
|
2011-12-22 06:44:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Key_WriteBindings (f);
|
2013-01-25 19:27:38 +00:00
|
|
|
Joy_WriteBindings (f);
|
2021-04-12 13:09:09 +00:00
|
|
|
Cvar_WriteVariables (f);
|
2011-12-22 06:44:28 +00:00
|
|
|
|
|
|
|
Qclose (f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-12 14:15:26 +00:00
|
|
|
static void
|
2020-06-25 05:03:52 +00:00
|
|
|
CL_Shutdown (void *data)
|
2011-12-22 06:44:28 +00:00
|
|
|
{
|
|
|
|
CL_WriteConfiguration ();
|
|
|
|
}
|
|
|
|
|
2019-07-08 03:46:22 +00:00
|
|
|
void
|
|
|
|
CL_ClearMemory (void)
|
|
|
|
{
|
|
|
|
VID_ClearMemory ();
|
|
|
|
if (r_data)
|
|
|
|
r_data->force_fullscreen = 0;
|
2011-12-22 06:44:28 +00:00
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_InitCvars (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-12-22 06:44:28 +00:00
|
|
|
VID_Init_Cvars ();
|
2012-02-01 12:52:47 +00:00
|
|
|
IN_Init_Cvars ();
|
2011-12-22 06:44:28 +00:00
|
|
|
Mod_Init_Cvars ();
|
2012-02-01 12:52:47 +00:00
|
|
|
S_Init_Cvars ();
|
2011-12-22 06:44:28 +00:00
|
|
|
|
|
|
|
CL_Demo_Init ();
|
2012-02-01 12:52:47 +00:00
|
|
|
Chase_Init_Cvars ();
|
|
|
|
V_Init_Cvars ();
|
2011-12-22 06:44:28 +00:00
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
cl_cshift_bonus = Cvar_Get ("cl_cshift_bonus", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"Show bonus flash on item pickup");
|
2001-05-14 03:08:24 +00:00
|
|
|
cl_cshift_contents = Cvar_Get ("cl_cshift_content", "1", CVAR_ARCHIVE,
|
|
|
|
NULL, "Shift view colors for contents "
|
|
|
|
"(water, slime, etc)");
|
2012-05-21 23:23:22 +00:00
|
|
|
cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"Shift view colors on damage");
|
|
|
|
cl_cshift_powerup = Cvar_Get ("cl_cshift_powerup", "1", CVAR_ARCHIVE, NULL, "Shift view colors for powerups");
|
2001-04-10 23:39:30 +00:00
|
|
|
cl_name = Cvar_Get ("_cl_name", "player", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"Player name");
|
2001-08-29 02:12:57 +00:00
|
|
|
cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL, "Player color");
|
2001-05-14 03:08:24 +00:00
|
|
|
cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", CVAR_NONE, NULL,
|
|
|
|
"turn `run' speed multiplier");
|
2001-05-09 05:41:34 +00:00
|
|
|
cl_backspeed = Cvar_Get ("cl_backspeed", "200", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"backward speed");
|
2001-05-14 03:08:24 +00:00
|
|
|
cl_forwardspeed = Cvar_Get ("cl_forwardspeed", "200", CVAR_ARCHIVE, NULL,
|
|
|
|
"forward speed");
|
2001-05-09 05:41:34 +00:00
|
|
|
cl_movespeedkey = Cvar_Get ("cl_movespeedkey", "2.0", CVAR_NONE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"move `run' speed multiplier");
|
2001-05-09 05:41:34 +00:00
|
|
|
cl_pitchspeed = Cvar_Get ("cl_pitchspeed", "150", CVAR_NONE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"look up/down speed");
|
2001-05-14 03:08:24 +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-05-09 05:41:34 +00:00
|
|
|
cl_shownet = Cvar_Get ("cl_shownet", "0", CVAR_NONE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"show network packets. 0=off, 1=basic, 2=verbose");
|
2001-05-09 05:41:34 +00:00
|
|
|
cl_nolerp = Cvar_Get ("cl_nolerp", "0", CVAR_NONE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"linear motion interpolation");
|
2001-05-14 03:08:24 +00:00
|
|
|
lookspring = Cvar_Get ("lookspring", "0", CVAR_ARCHIVE, NULL, "Snap view "
|
|
|
|
"to center when moving and no mlook/klook");
|
2001-05-09 05:41:34 +00:00
|
|
|
m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"mouse pitch (up/down) multipier");
|
2001-05-09 05:41:34 +00:00
|
|
|
m_yaw = Cvar_Get ("m_yaw", "0.022", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"mouse yaw (left/right) multipiler");
|
2001-05-09 05:41:34 +00:00
|
|
|
m_forward = Cvar_Get ("m_forward", "1", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"mouse forward/back speed");
|
2001-04-10 23:39:30 +00:00
|
|
|
m_side = Cvar_Get ("m_side", "0.8", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"mouse strafe speed");
|
2003-07-27 23:20:11 +00:00
|
|
|
hud_fps = Cvar_Get ("hud_fps", "0", CVAR_ARCHIVE, NULL,
|
|
|
|
"display realtime frames per second");
|
2011-07-05 11:28:57 +00:00
|
|
|
Cvar_MakeAlias ("show_fps", hud_fps);
|
2003-07-27 23:20:11 +00:00
|
|
|
hud_time = Cvar_Get ("hud_time", "0", CVAR_ARCHIVE, NULL,
|
|
|
|
"display the current time");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_ClearState (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (!sv.active)
|
|
|
|
Host_ClearMemory ();
|
|
|
|
|
2010-12-10 04:00:42 +00:00
|
|
|
if (cl.edicts)
|
|
|
|
PL_Free (cl.edicts);
|
|
|
|
|
2013-02-02 07:54:05 +00:00
|
|
|
if (cl.players) {
|
2012-05-26 03:53:03 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < cl.maxclients; i++)
|
2013-02-02 07:54:05 +00:00
|
|
|
Info_Destroy (cl.players[i].userinfo);
|
2012-05-26 03:53:03 +00:00
|
|
|
}
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// wipe the entire cl structure
|
2001-02-26 06:48:02 +00:00
|
|
|
memset (&cl, 0, sizeof (cl));
|
2011-06-19 00:49:39 +00:00
|
|
|
cl.chase = 1;
|
2012-06-03 00:30:31 +00:00
|
|
|
cl.watervis = 1;
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->force_fullscreen = 0;
|
|
|
|
r_data->lightstyle = cl.lightstyle;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-14 07:55:19 +00:00
|
|
|
CL_Init_Entity (&cl.viewent);
|
2012-02-14 08:28:09 +00:00
|
|
|
r_data->view_model = &cl.viewent;
|
2002-06-14 07:55:19 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
|
2001-05-19 21:09:48 +00:00
|
|
|
CL_ClearTEnts ();
|
|
|
|
|
2012-02-14 08:28:09 +00:00
|
|
|
r_funcs->R_ClearState ();
|
2001-05-20 01:58:59 +00:00
|
|
|
|
2011-06-19 11:02:00 +00:00
|
|
|
CL_ClearEnts ();
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-13 23:15:34 +00:00
|
|
|
/*
|
|
|
|
CL_StopCshifts
|
|
|
|
|
|
|
|
Cleans the Cshifts, so your screen doesn't stay red after a timedemo :)
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-05-13 23:15:34 +00:00
|
|
|
CL_StopCshifts (void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-08-29 02:12:57 +00:00
|
|
|
|
2001-05-13 23:15:34 +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
|
|
|
/*
|
2001-05-11 01:01:27 +00:00
|
|
|
CL_Disconnect
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
Sends a disconnect message to the server
|
|
|
|
This is also called on Host_Error, so it shouldn't cause any errors
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_Disconnect (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-13 23:15:34 +00:00
|
|
|
// stop sounds (especially looping!)
|
2007-03-17 03:10:45 +00:00
|
|
|
S_StopAllSounds ();
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-05-13 23:15:34 +00:00
|
|
|
// Clean the Cshifts
|
|
|
|
CL_StopCshifts ();
|
|
|
|
|
|
|
|
// bring the console down and fade the colors back to normal
|
|
|
|
// SCR_BringDownConsole ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
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 ();
|
2012-05-23 12:38:25 +00:00
|
|
|
else if (cls.state >= ca_connected) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.demorecording)
|
2011-06-03 13:47:32 +00:00
|
|
|
CL_StopRecording ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Sending clc_disconnect\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
MSG_WriteByte (&cls.message, clc_disconnect);
|
|
|
|
NET_SendUnreliableMessage (cls.netcon, &cls.message);
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
NET_Close (cls.netcon);
|
|
|
|
|
2001-08-20 17:48:16 +00:00
|
|
|
CL_SetState (ca_disconnected);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (sv.active)
|
2001-02-26 06:48:02 +00:00
|
|
|
Host_ShutdownServer (false);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2002-09-08 03:36:34 +00:00
|
|
|
cl.worldmodel = NULL;
|
2012-07-21 08:53:49 +00:00
|
|
|
cl.intermission = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_Disconnect_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
CL_Disconnect ();
|
|
|
|
if (sv.active)
|
|
|
|
Host_ShutdownServer (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-11 01:01:27 +00:00
|
|
|
CL_EstablishConnection
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
Host should be either "local" or a net address to be passed on
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2001-07-15 07:04:17 +00:00
|
|
|
CL_EstablishConnection (const char *host)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (cls.state == ca_dedicated)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cls.demoplayback)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CL_Disconnect ();
|
|
|
|
|
|
|
|
cls.netcon = NET_Connect (host);
|
|
|
|
if (!cls.netcon)
|
|
|
|
Host_Error ("CL_Connect: connect failed\n");
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "CL_EstablishConnection: connected to %s\n",
|
2010-11-23 05:09:30 +00:00
|
|
|
host);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
cls.demonum = -1; // not in the demo loop now
|
2001-08-20 17:48:16 +00:00
|
|
|
CL_SetState (ca_connected);
|
2013-01-19 13:33:34 +00:00
|
|
|
Key_SetKeyDest (cls.key_dest);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-11 01:01:27 +00:00
|
|
|
CL_SignonReply
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
An svc_signonnum has been received, perform a client side setup
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_SignonReply (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "CL_SignonReply: %i\n", cls.signon);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
switch (cls.signon) {
|
2012-05-23 12:38:25 +00:00
|
|
|
case so_none:
|
|
|
|
break;
|
|
|
|
case so_prespawn:
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.message, "prespawn");
|
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-05-23 12:38:25 +00:00
|
|
|
case so_spawn:
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
2021-01-31 07:01:20 +00:00
|
|
|
MSG_WriteString (&cls.message, va (0, "name \"%s\"\n",
|
|
|
|
cl_name->string));
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
2001-02-26 06:48:02 +00:00
|
|
|
MSG_WriteString (&cls.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, "color %i %i\n", (cl_color->int_val) >> 4,
|
2001-02-26 06:48:02 +00:00
|
|
|
(cl_color->int_val) & 15));
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
2012-05-24 11:17:41 +00:00
|
|
|
MSG_WriteString (&cls.message, "spawn");
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-05-23 12:38:25 +00:00
|
|
|
case so_begin:
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
|
|
|
MSG_WriteString (&cls.message, "begin");
|
2001-02-26 06:48:02 +00:00
|
|
|
Cache_Report (); // print remaining memory
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2012-05-23 12:38:25 +00:00
|
|
|
case so_active:
|
2011-12-09 09:41:52 +00:00
|
|
|
cl.loading = false;
|
2012-05-23 12:38:25 +00:00
|
|
|
CL_SetState (ca_active);
|
2001-02-19 21:15:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-11 01:01:27 +00:00
|
|
|
CL_NextDemo
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-11 01:01:27 +00:00
|
|
|
Called to play the next demo in the demo loop
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_NextDemo (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
if (cls.demonum == -1)
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // don't play demos
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-12-09 09:41:52 +00:00
|
|
|
cl.loading = true;
|
|
|
|
CL_UpdateScreen(cl.time);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!cls.demos[cls.demonum][0] || cls.demonum == MAX_DEMOS) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.demonum = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!cls.demos[cls.demonum][0]) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("No demos listed with startdemos\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.demonum = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-31 07:01:20 +00:00
|
|
|
Cbuf_InsertText (host_cbuf, va (0, "playdemo %s\n",
|
|
|
|
cls.demos[cls.demonum]));
|
2001-02-19 21:15:25 +00:00
|
|
|
cls.demonum++;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_PrintEntities_f (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
entity_t *ent;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0, ent = cl_entities; i < cl.num_entities; i++, ent++) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("%3i:", i);
|
2021-03-09 14:52:40 +00:00
|
|
|
if (!ent->renderer.model) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("EMPTY\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2021-03-19 11:18:45 +00:00
|
|
|
vec4f_t org = Transform_GetWorldPosition (ent->transform);
|
|
|
|
vec4f_t rot = Transform_GetWorldRotation (ent->transform);
|
|
|
|
Sys_Printf ("%s:%2i "VEC4F_FMT" "VEC4F_FMT"\n",
|
2021-03-09 14:52:40 +00:00
|
|
|
ent->renderer.model->path, ent->animation.frame,
|
2021-03-19 11:18:45 +00:00
|
|
|
VEC4_EXP (org), VEC4_EXP (rot));
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 19:46:16 +00:00
|
|
|
CL_ReadFromServer
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
Read all incoming data from the server
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
int
|
|
|
|
CL_ReadFromServer (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int ret;
|
2021-03-10 09:00:16 +00:00
|
|
|
TEntContext_t tentCtx = {
|
2021-03-19 11:18:45 +00:00
|
|
|
Transform_GetWorldPosition (cl_entities[cl.viewentity].transform),
|
2021-03-10 09:00:16 +00:00
|
|
|
cl.worldmodel, cl.viewentity
|
|
|
|
};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cl.oldtime = cl.time;
|
|
|
|
cl.time += host_frametime;
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.frametime = host_frametime;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
do {
|
2001-02-19 21:15:25 +00:00
|
|
|
ret = CL_GetMessage ();
|
|
|
|
if (ret == -1)
|
|
|
|
Host_Error ("CL_ReadFromServer: lost server connection");
|
|
|
|
if (!ret)
|
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_ParseServerMessage ();
|
2012-05-23 12:38:25 +00:00
|
|
|
} while (ret && cls.state >= ca_connected);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl_shownet->int_val)
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
CL_RelinkEntities ();
|
2021-03-10 09:00:16 +00:00
|
|
|
CL_UpdateTEnts (cl.time, &tentCtx);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// bring the links up to date
|
2001-02-19 21:15:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_SendCmd (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
usercmd_t cmd;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-23 12:38:25 +00:00
|
|
|
if (cls.state < ca_connected)
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
|
2012-05-23 12:38:25 +00:00
|
|
|
if (cls.state == ca_active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_BaseMove (&cmd);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
// send the unreliable message
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_SendMove (&cmd);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (cls.demoplayback) {
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
return;
|
|
|
|
}
|
2001-05-14 19:46:16 +00:00
|
|
|
// send the reliable message
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!cls.message.cursize)
|
2001-02-26 06:48:02 +00:00
|
|
|
return; // no message at all
|
|
|
|
|
|
|
|
if (!NET_CanSendMessage (cls.netcon)) {
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "CL_WriteToServer: can't send\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NET_SendMessage (cls.netcon, &cls.message) == -1)
|
|
|
|
Host_Error ("CL_WriteToServer: lost server connection");
|
|
|
|
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
}
|
|
|
|
|
2001-08-20 17:48:16 +00:00
|
|
|
void
|
|
|
|
CL_SetState (cactive_t state)
|
|
|
|
{
|
2002-08-27 08:33:21 +00:00
|
|
|
cactive_t old_state = cls.state;
|
2001-08-20 17:48:16 +00:00
|
|
|
cls.state = state;
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_net, "CL_SetState: %d -> %d\n", old_state, state);
|
2002-08-27 08:33:21 +00:00
|
|
|
if (old_state != state) {
|
2012-05-23 12:38:25 +00:00
|
|
|
if (old_state == ca_active) {
|
2002-08-27 08:33:21 +00:00
|
|
|
// leaving active state
|
2011-12-10 07:14:25 +00:00
|
|
|
Key_SetKeyDest (key_console);
|
2010-08-24 00:53:54 +00:00
|
|
|
S_AmbientOff ();
|
2012-05-23 12:38:25 +00:00
|
|
|
}
|
|
|
|
switch (state) {
|
|
|
|
case ca_dedicated:
|
|
|
|
break;
|
|
|
|
case ca_disconnected:
|
|
|
|
cls.signon = so_none;
|
2012-07-06 01:44:29 +00:00
|
|
|
cl.loading = false;
|
2012-05-23 12:38:25 +00:00
|
|
|
VID_SetCaption ("Disconnected");
|
|
|
|
break;
|
|
|
|
case ca_connected:
|
|
|
|
cls.signon = so_none; // need all the signon messages
|
|
|
|
// before playing
|
2012-07-06 01:44:29 +00:00
|
|
|
cl.loading = true;
|
2013-01-19 13:33:34 +00:00
|
|
|
Key_SetKeyDest (cls.key_dest);
|
2012-05-23 12:38:25 +00:00
|
|
|
IN_ClearStates ();
|
|
|
|
VID_SetCaption ("Connected");
|
|
|
|
break;
|
|
|
|
case ca_active:
|
|
|
|
// entering active state
|
2012-07-06 01:44:29 +00:00
|
|
|
cl.loading = false;
|
2013-01-19 13:33:34 +00:00
|
|
|
Key_SetKeyDest (cls.key_dest);
|
2012-05-23 12:38:25 +00:00
|
|
|
IN_ClearStates ();
|
|
|
|
VID_SetCaption ("");
|
|
|
|
S_AmbientOn ();
|
|
|
|
break;
|
|
|
|
}
|
2012-06-24 02:22:37 +00:00
|
|
|
CL_UpdateScreen (cl.time);
|
2001-08-20 17:48:16 +00:00
|
|
|
}
|
2002-08-27 08:33:21 +00:00
|
|
|
if (con_module)
|
2012-07-21 07:37:14 +00:00
|
|
|
con_module->data->console->force_commandline = (state < ca_connected);
|
2001-08-20 17:48:16 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-07-06 17:42:04 +00:00
|
|
|
Force_CenterView_f (void)
|
|
|
|
{
|
2021-03-19 11:18:45 +00:00
|
|
|
cl.viewstate.angles[PITCH] = 0;
|
2001-07-06 17:42:04 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
2011-12-22 06:44:28 +00:00
|
|
|
CL_Init (cbuf_t *cbuf)
|
2001-02-26 06:48:02 +00:00
|
|
|
{
|
2012-02-01 10:52:13 +00:00
|
|
|
byte *basepal, *colormap;
|
2011-12-22 06:44:28 +00:00
|
|
|
|
2020-06-25 05:03:52 +00:00
|
|
|
Sys_RegisterShutdown (CL_Shutdown, 0);
|
2019-07-12 14:15:26 +00:00
|
|
|
|
2014-01-23 02:57:57 +00:00
|
|
|
basepal = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/palette.lmp"));
|
2011-12-22 06:44:28 +00:00
|
|
|
if (!basepal)
|
|
|
|
Sys_Error ("Couldn't load gfx/palette.lmp");
|
2014-01-23 02:57:57 +00:00
|
|
|
colormap = (byte *) QFS_LoadHunkFile (QFS_FOpenFile ("gfx/colormap.lmp"));
|
2012-02-01 10:52:13 +00:00
|
|
|
if (!colormap)
|
2011-12-22 06:44:28 +00:00
|
|
|
Sys_Error ("Couldn't load gfx/colormap.lmp");
|
|
|
|
|
2012-02-01 12:52:47 +00:00
|
|
|
W_LoadWadFile ("gfx.wad");
|
2012-02-01 10:52:13 +00:00
|
|
|
VID_Init (basepal, colormap);
|
2012-02-01 12:52:47 +00:00
|
|
|
IN_Init (cbuf);
|
2011-12-22 06:44:28 +00:00
|
|
|
R_Init ();
|
2012-02-26 09:45:50 +00:00
|
|
|
r_data->lightstyle = cl.lightstyle;
|
|
|
|
|
2012-06-24 12:13:51 +00:00
|
|
|
S_Init (&cl.viewentity, &host_frametime);
|
2012-02-26 09:45:50 +00:00
|
|
|
|
|
|
|
PI_RegisterPlugins (client_plugin_list);
|
|
|
|
Con_Init ("client");
|
|
|
|
|
2011-12-22 06:44:28 +00:00
|
|
|
CDAudio_Init ();
|
2012-01-24 02:49:42 +00:00
|
|
|
|
2012-02-01 12:52:47 +00:00
|
|
|
Sbar_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-06-19 00:49:39 +00:00
|
|
|
CL_Input_Init ();
|
2001-05-15 21:34:54 +00:00
|
|
|
CL_TEnts_Init ();
|
2002-12-11 22:09:23 +00:00
|
|
|
CL_ClearState ();
|
2012-02-01 12:52:47 +00:00
|
|
|
|
2011-12-22 06:44:28 +00:00
|
|
|
V_Init ();
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-21 19:35:06 +00:00
|
|
|
Cmd_AddCommand ("entities", CL_PrintEntities_f, "No Description");
|
|
|
|
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "No Description");
|
2001-11-06 07:14:29 +00:00
|
|
|
Cmd_AddCommand ("maplist", Con_Maplist_f, "List available maps");
|
2001-11-07 06:56:05 +00:00
|
|
|
Cmd_AddCommand ("skyboxlist", Con_Skyboxlist_f, "List skyboxes available");
|
2001-11-06 07:14:29 +00:00
|
|
|
Cmd_AddCommand ("demolist", Con_Demolist_DEM_f, "List available demos");
|
2001-08-29 02:12:57 +00:00
|
|
|
Cmd_AddCommand ("force_centerview", Force_CenterView_f, "force the view "
|
|
|
|
"to be level");
|
2012-02-01 12:52:47 +00:00
|
|
|
|
|
|
|
SZ_Alloc (&cls.message, 1024);
|
2013-01-19 13:33:34 +00:00
|
|
|
cls.key_dest = key_game;
|
2012-02-01 12:52:47 +00:00
|
|
|
CL_SetState (ca_disconnected);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|