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
|
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
2003-01-15 15:31:36 +00:00
|
|
|
"$Id$";
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.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"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/input.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"
|
2002-01-20 00:04:50 +00:00
|
|
|
#include "QF/plugin.h"
|
2010-12-10 04:00:42 +00:00
|
|
|
#include "QF/qfplist.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"
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "chase.h"
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "client.h"
|
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "host.h"
|
|
|
|
#include "host.h"
|
2001-06-29 02:43:04 +00:00
|
|
|
#include "r_cvar.h"
|
2001-05-18 22:07:10 +00:00
|
|
|
#include "r_dynamic.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "server.h"
|
|
|
|
|
2001-04-15 21:11:41 +00:00
|
|
|
byte *vid_colormap;
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
2001-05-13 22:57:27 +00:00
|
|
|
cvar_t *cl_cshift_bonus;
|
|
|
|
cvar_t *cl_cshift_contents;
|
|
|
|
cvar_t *cl_cshift_damage;
|
|
|
|
cvar_t *cl_cshift_powerup;
|
|
|
|
|
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
|
|
|
|
|
|
|
// FIXME: put these on hunk?
|
2001-02-26 06:48:02 +00:00
|
|
|
entity_t cl_entities[MAX_EDICTS];
|
2001-11-27 21:42:49 +00:00
|
|
|
cl_entity_state_t cl_baselines[MAX_EDICTS];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-09 05:41:34 +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
|
|
|
{
|
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)");
|
2001-05-13 22:57:27 +00:00
|
|
|
cl_cshift_damage = Cvar_Get ("cl_cshift_damage", "1", CVAR_ARCHIVE, NULL,
|
|
|
|
"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");
|
2010-12-16 02:46:25 +00:00
|
|
|
Cvar_Alias_Get ("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
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
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);
|
|
|
|
|
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));
|
2005-04-25 01:28:37 +00:00
|
|
|
r_force_fullscreen = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-14 07:55:19 +00:00
|
|
|
CL_Init_Entity (&cl.viewent);
|
2010-11-23 01:48:10 +00:00
|
|
|
r_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-14 19:46:16 +00:00
|
|
|
// clear other arrays
|
2001-02-26 06:48:02 +00:00
|
|
|
memset (cl_entities, 0, sizeof (cl_entities));
|
2001-05-19 01:58:31 +00:00
|
|
|
memset (cl_baselines, 0, sizeof (cl_baselines));
|
2001-05-21 03:08:07 +00:00
|
|
|
memset (r_lightstyle, 0, sizeof (r_lightstyle));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-27 22:44:12 +00:00
|
|
|
Skin_ClearTempSkins ();
|
|
|
|
|
2001-05-19 21:09:48 +00:00
|
|
|
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-05-18 22:33:35 +00:00
|
|
|
for (i = 0; i < MAX_EDICTS; i++) {
|
2001-11-27 21:42:49 +00:00
|
|
|
cl_baselines[i].ent = &cl_entities[i];
|
2002-06-14 07:55:19 +00:00
|
|
|
CL_Init_Entity (cl_entities + i);
|
2001-05-18 22:33:35 +00:00
|
|
|
}
|
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 ();
|
2001-02-26 06:48:02 +00:00
|
|
|
else if (cls.state == ca_connected) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cls.demorecording)
|
|
|
|
CL_Stop_f ();
|
|
|
|
|
2010-11-23 05:09:30 +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
|
|
|
}
|
|
|
|
|
|
|
|
cls.signon = 0;
|
2002-09-08 03:36:34 +00:00
|
|
|
cl.worldmodel = NULL;
|
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");
|
2010-11-23 05:09:30 +00:00
|
|
|
Sys_MaskPrintf (SYS_DEV, "CL_EstablishConnection: connected to %s\n",
|
|
|
|
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);
|
2001-02-26 06:48:02 +00:00
|
|
|
cls.signon = 0; // need all the signon messages
|
2001-05-14 19:46:16 +00:00
|
|
|
// before playing
|
2001-05-15 05:27:14 +00:00
|
|
|
key_dest = key_game;
|
2001-09-05 21:22:55 +00:00
|
|
|
game_target = IMT_0;
|
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
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
char str[8192];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-11-23 05:09:30 +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) {
|
2001-05-14 19:46:16 +00:00
|
|
|
case 1:
|
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
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
case 2:
|
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, va ("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,
|
|
|
|
va ("color %i %i\n", (cl_color->int_val) >> 4,
|
|
|
|
(cl_color->int_val) & 15));
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteByte (&cls.message, clc_stringcmd);
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (str, sizeof (str), "spawn %s", cls.spawnparms);
|
2001-02-19 21:15:25 +00:00
|
|
|
MSG_WriteString (&cls.message, str);
|
|
|
|
break;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
case 3:
|
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
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
case 4:
|
2001-05-11 01:01:27 +00:00
|
|
|
// SCR_EndLoadingPlaque (); // allow normal screen updates
|
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
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
char str[1024];
|
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
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]);
|
2002-07-31 05:19:03 +00:00
|
|
|
Cbuf_InsertText (host_cbuf, str);
|
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);
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!ent->model) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("EMPTY\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("%s:%2i (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n",
|
2001-02-26 06:48:02 +00:00
|
|
|
ent->model->name, ent->frame, ent->origin[0],
|
|
|
|
ent->origin[1], ent->origin[2], ent->angles[0],
|
|
|
|
ent->angles[1], ent->angles[2]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 19:46:16 +00:00
|
|
|
SetPal
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
Debugging tool, just flashes the screen
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
SetPal (int i)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
#if 0
|
2001-02-26 06:48:02 +00:00
|
|
|
byte pal[768];
|
|
|
|
int c;
|
2001-08-29 02:12:57 +00:00
|
|
|
static int old;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (i == old)
|
|
|
|
return;
|
|
|
|
old = i;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (i == 0)
|
2002-09-10 03:51:10 +00:00
|
|
|
VID_SetPalette (vid.palette);
|
2001-02-26 06:48:02 +00:00
|
|
|
else if (i == 1) {
|
|
|
|
for (c = 0; c < 768; c += 3) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pal[c] = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
pal[c + 1] = 255;
|
|
|
|
pal[c + 2] = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
VID_SetPalette (pal);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else {
|
|
|
|
for (c = 0; c < 768; c += 3) {
|
2001-02-19 21:15:25 +00:00
|
|
|
pal[c] = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
pal[c + 1] = 0;
|
|
|
|
pal[c + 2] = 255;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
VID_SetPalette (pal);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-09-05 21:22:55 +00:00
|
|
|
CL_NewDlight (int key, vec3_t org, int effects)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-09-05 21:22:55 +00:00
|
|
|
float radius;
|
|
|
|
float time = 0.1;
|
2001-02-26 06:48:02 +00:00
|
|
|
dlight_t *dl;
|
2004-05-03 06:21:39 +00:00
|
|
|
static quat_t normal = {0.4, 0.2, 0.05, 0.7};
|
|
|
|
static quat_t red = {0.5, 0.05, 0.05, 0.7};
|
|
|
|
static quat_t blue = {0.05, 0.05, 0.5, 0.7};
|
|
|
|
static quat_t purple = {0.5, 0.05, 0.5, 0.7};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-09-05 21:22:55 +00:00
|
|
|
if (!(effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT)))
|
|
|
|
return;
|
|
|
|
|
2001-05-20 05:42:52 +00:00
|
|
|
dl = R_AllocDlight (key);
|
2002-06-05 22:07:38 +00:00
|
|
|
if (!dl)
|
|
|
|
return;
|
2001-09-05 21:22:55 +00:00
|
|
|
VectorCopy (org, dl->origin);
|
2002-06-07 05:21:53 +00:00
|
|
|
radius = 200 + (rand () & 31);
|
|
|
|
if (effects & EF_BRIGHTLIGHT) {
|
|
|
|
radius += 200;
|
|
|
|
dl->origin[2] += 16;
|
|
|
|
}
|
|
|
|
if (effects & EF_DIMLIGHT)
|
|
|
|
if (effects & ~EF_DIMLIGHT)
|
|
|
|
radius -= 100;
|
|
|
|
dl->radius = radius;
|
|
|
|
dl->die = cl.time + time;
|
2002-06-05 22:07:38 +00:00
|
|
|
|
2001-09-05 21:22:55 +00:00
|
|
|
switch (effects & (EF_BLUE | EF_RED)) {
|
2002-06-07 05:21:53 +00:00
|
|
|
case EF_RED | EF_BLUE:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (purple, dl->color);
|
2001-09-05 21:22:55 +00:00
|
|
|
break;
|
|
|
|
case EF_RED:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (red, dl->color);
|
2001-09-05 21:22:55 +00:00
|
|
|
break;
|
2002-06-07 05:21:53 +00:00
|
|
|
case EF_BLUE:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (blue, dl->color);
|
2002-06-07 05:21:53 +00:00
|
|
|
break;
|
2001-09-05 21:22:55 +00:00
|
|
|
default:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (normal, dl->color);
|
2001-09-05 21:22:55 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-05-14 19:46:16 +00:00
|
|
|
CL_LerpPoint
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
Determines the fraction between the last two messages that the objects
|
|
|
|
should be put at.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static float
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_LerpPoint (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
float f, frac;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
f = cl.mtime[0] - cl.mtime[1];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (!f || cl_nolerp->int_val || cls.timedemo || sv.active) {
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.time = cl.mtime[0];
|
|
|
|
return 1;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
if (f > 0.1) { // dropped packet, or start of demo
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.mtime[1] = cl.mtime[0] - 0.1;
|
|
|
|
f = 0.1;
|
|
|
|
}
|
|
|
|
frac = (cl.time - cl.mtime[1]) / f;
|
2002-07-02 21:37:22 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (frac < 0) {
|
|
|
|
if (frac < -0.01) {
|
|
|
|
SetPal (1);
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.time = cl.mtime[1];
|
|
|
|
}
|
|
|
|
frac = 0;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else if (frac > 1) {
|
|
|
|
if (frac > 1.01) {
|
|
|
|
SetPal (2);
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.time = cl.mtime[0];
|
|
|
|
}
|
|
|
|
frac = 1;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else
|
|
|
|
SetPal (0);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return frac;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_RelinkEntities (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
entity_t *ent;
|
2001-11-27 21:42:49 +00:00
|
|
|
cl_entity_state_t *state;
|
2001-08-29 02:12:57 +00:00
|
|
|
dlight_t *dl;
|
|
|
|
float bobjrotate, frac, f, d;
|
2001-02-26 06:48:02 +00:00
|
|
|
int i, j;
|
|
|
|
vec3_t delta;
|
2001-05-21 00:22:35 +00:00
|
|
|
|
|
|
|
r_player_entity = &cl_entities[cl.viewentity];
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// determine partial update time
|
2001-02-19 21:15:25 +00:00
|
|
|
frac = CL_LerpPoint ();
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// interpolate player info
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
cl.velocity[i] = cl.mvelocity[1][i] +
|
2001-02-19 21:15:25 +00:00
|
|
|
frac * (cl.mvelocity[0][i] - cl.mvelocity[1][i]);
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (cls.demoplayback) {
|
|
|
|
// interpolate the angles
|
|
|
|
for (j = 0; j < 3; j++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
d = cl.mviewangles[0][j] - cl.mviewangles[1][j];
|
|
|
|
if (d > 180)
|
|
|
|
d -= 360;
|
|
|
|
else if (d < -180)
|
|
|
|
d += 360;
|
2001-02-26 06:48:02 +00:00
|
|
|
cl.viewangles[j] = cl.mviewangles[1][j] + frac * d;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
bobjrotate = anglemod (100 * cl.time);
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// start on the entity after the world
|
2001-11-27 21:42:49 +00:00
|
|
|
for (i = 1, state = cl_baselines + 1; i < cl.num_entities; i++, state++) {
|
|
|
|
ent = state->ent;
|
2001-02-26 06:48:02 +00:00
|
|
|
if (!ent->model) { // empty slot
|
2004-03-11 04:13:12 +00:00
|
|
|
if (ent->efrag)
|
2001-02-19 21:15:25 +00:00
|
|
|
R_RemoveEfrags (ent); // just became empty
|
|
|
|
continue;
|
|
|
|
}
|
2001-05-14 19:46:16 +00:00
|
|
|
// if the object wasn't included in the last packet, remove it
|
2001-11-27 21:42:49 +00:00
|
|
|
if (state->msgtime != cl.mtime[0]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ent->model = NULL;
|
2010-11-26 00:22:04 +00:00
|
|
|
//johnfitz -- next time this entity slot is reused, the lerp will
|
|
|
|
//need to be reset
|
|
|
|
ent->lerpflags |= LERP_RESETMOVE|LERP_RESETANIM;
|
2004-03-11 04:13:12 +00:00
|
|
|
if (ent->efrag)
|
|
|
|
R_RemoveEfrags (ent); // just became empty
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-12-16 00:34:29 +00:00
|
|
|
ent->colormod[3] = ENTALPHA_DECODE (state->alpha);
|
|
|
|
|
2004-03-15 00:32:49 +00:00
|
|
|
VectorCopy (ent->origin, ent->old_origin);
|
|
|
|
|
2004-03-11 04:13:12 +00:00
|
|
|
if (state->forcelink) {
|
|
|
|
// The entity was not updated in the last message so move to the
|
|
|
|
// final spot
|
2010-11-26 00:22:04 +00:00
|
|
|
VectorCopy (state->msg_origins[0], ent->origin);
|
|
|
|
VectorCopy (state->msg_angles[0], ent->angles);
|
2010-12-04 13:41:44 +00:00
|
|
|
if (i != cl.viewentity || chase_active->int_val) {
|
|
|
|
if (ent->efrag)
|
|
|
|
R_RemoveEfrags (ent);
|
|
|
|
R_AddEfrags (ent);
|
|
|
|
}
|
2004-03-11 04:13:12 +00:00
|
|
|
} else {
|
|
|
|
// If the delta is large, assume a teleport and don't lerp
|
2001-02-19 21:15:25 +00:00
|
|
|
f = frac;
|
2001-11-28 00:19:27 +00:00
|
|
|
VectorSubtract (state->msg_origins[0],
|
|
|
|
state->msg_origins[1], delta);
|
|
|
|
if (fabs (delta[0]) > 100 || fabs (delta[1] > 100)
|
|
|
|
|| fabs (delta[2]) > 100) {
|
|
|
|
// assume a teleportation, not a motion
|
|
|
|
VectorCopy (state->msg_origins[0], ent->origin);
|
|
|
|
VectorCopy (state->msg_angles[0], ent->angles);
|
2010-11-26 00:22:04 +00:00
|
|
|
ent->lerpflags |= LERP_RESETMOVE;
|
2001-11-28 00:19:27 +00:00
|
|
|
} else {
|
|
|
|
// interpolate the origin and angles
|
2010-11-26 00:22:04 +00:00
|
|
|
// FIXME r_lerpmove.value &&
|
|
|
|
if (ent->lerpflags & LERP_MOVESTEP)
|
|
|
|
f = 1;
|
|
|
|
VectorMultAdd (state->msg_origins[1], f, delta, ent->origin);
|
2001-11-28 00:19:27 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
d = state->msg_angles[0][j] - state->msg_angles[1][j];
|
|
|
|
if (d > 180)
|
|
|
|
d -= 360;
|
|
|
|
else if (d < -180)
|
|
|
|
d += 360;
|
|
|
|
ent->angles[j] = state->msg_angles[1][j] + f * d;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2010-12-04 13:41:44 +00:00
|
|
|
if (i != cl.viewentity || chase_active->int_val) {
|
|
|
|
if (ent->efrag) {
|
|
|
|
if (!VectorCompare (ent->origin, ent->old_origin)) {
|
|
|
|
R_RemoveEfrags (ent);
|
|
|
|
R_AddEfrags (ent);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
R_AddEfrags (ent);
|
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// rotate binary objects locally
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->model->flags & EF_ROTATE)
|
|
|
|
ent->angles[1] = bobjrotate;
|
|
|
|
|
2002-06-06 04:42:15 +00:00
|
|
|
if (state->effects & EF_BRIGHTFIELD)
|
2001-02-19 21:15:25 +00:00
|
|
|
R_EntityParticles (ent);
|
2002-06-06 04:42:15 +00:00
|
|
|
if (state->effects & EF_MUZZLEFLASH) {
|
2001-02-26 06:48:02 +00:00
|
|
|
vec3_t fv, rv, uv;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-20 05:42:52 +00:00
|
|
|
dl = R_AllocDlight (i);
|
2002-06-05 22:07:38 +00:00
|
|
|
if (dl) {
|
|
|
|
AngleVectors (ent->angles, fv, rv, uv);
|
|
|
|
|
2003-08-08 15:25:53 +00:00
|
|
|
VectorMultAdd (ent->origin, 18, fv, dl->origin);
|
2002-06-07 05:21:53 +00:00
|
|
|
dl->origin[2] += 16;
|
2002-06-05 22:07:38 +00:00
|
|
|
dl->radius = 200 + (rand () & 31);
|
|
|
|
dl->die = cl.time + 0.1;
|
2002-06-07 05:21:53 +00:00
|
|
|
dl->minlight = 32;
|
2002-06-05 22:07:38 +00:00
|
|
|
dl->color[0] = 0.2;
|
|
|
|
dl->color[1] = 0.1;
|
|
|
|
dl->color[2] = 0.05;
|
2004-05-03 06:21:39 +00:00
|
|
|
dl->color[3] = 0.7;
|
2002-06-05 22:07:38 +00:00
|
|
|
}
|
2010-11-26 00:22:04 +00:00
|
|
|
#if 0 //FIXME how much do we want this?
|
|
|
|
//johnfitz -- assume muzzle flash accompanied by muzzle flare,
|
|
|
|
//which looks bad when lerped
|
|
|
|
if (ent == &cl_entities[cl.viewentity])
|
|
|
|
cl.viewent.lerpflags |= LERP_RESETANIM | LERP_RESETANIM2;
|
|
|
|
else
|
|
|
|
ent->lerpflags |= LERP_RESETANIM | LERP_RESETANIM2;
|
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2002-06-06 04:42:15 +00:00
|
|
|
CL_NewDlight (i, ent->origin, state->effects);
|
2003-03-21 21:26:26 +00:00
|
|
|
if (VectorDistance_fast (state->msg_origins[1], ent->origin)
|
|
|
|
> (256 * 256))
|
2010-08-24 00:53:54 +00:00
|
|
|
VectorCopy (ent->origin, state->msg_origins[1]);
|
2001-05-09 05:41:34 +00:00
|
|
|
if (ent->model->flags & EF_ROCKET) {
|
2001-05-20 05:42:52 +00:00
|
|
|
dl = R_AllocDlight (i);
|
2002-06-05 22:07:38 +00:00
|
|
|
if (dl) {
|
|
|
|
VectorCopy (ent->origin, dl->origin);
|
|
|
|
dl->radius = 200;
|
|
|
|
dl->die = cl.time + 0.1;
|
2002-06-07 05:21:53 +00:00
|
|
|
VectorCopy (r_firecolor->vec, dl->color);
|
2004-05-03 06:21:39 +00:00
|
|
|
dl->color[3] = 0.7;
|
2002-06-05 22:07:38 +00:00
|
|
|
}
|
2001-09-07 05:37:11 +00:00
|
|
|
R_RocketTrail (ent);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else if (ent->model->flags & EF_GRENADE)
|
2001-09-07 05:37:11 +00:00
|
|
|
R_GrenadeTrail (ent);
|
2001-05-09 05:41:34 +00:00
|
|
|
else if (ent->model->flags & EF_GIB)
|
2001-09-07 05:37:11 +00:00
|
|
|
R_BloodTrail (ent);
|
2001-05-09 05:41:34 +00:00
|
|
|
else if (ent->model->flags & EF_ZOMGIB)
|
2001-09-07 05:37:11 +00:00
|
|
|
R_SlightBloodTrail (ent);
|
2001-05-09 05:41:34 +00:00
|
|
|
else if (ent->model->flags & EF_TRACER)
|
2001-12-11 22:37:30 +00:00
|
|
|
R_WizTrail (ent);
|
2001-05-09 05:41:34 +00:00
|
|
|
else if (ent->model->flags & EF_TRACER2)
|
2001-09-07 05:37:11 +00:00
|
|
|
R_FlameTrail (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (ent->model->flags & EF_TRACER3)
|
2001-09-07 05:37:11 +00:00
|
|
|
R_VoorTrail (ent);
|
2002-07-25 14:43:36 +00:00
|
|
|
else if (ent->model->flags & EF_GLOWTRAIL)
|
2002-09-12 22:09:55 +00:00
|
|
|
R_GlowTrail (ent, state->glow_color);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-11-27 21:42:49 +00:00
|
|
|
state->forcelink = false;
|
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;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
cl.oldtime = cl.time;
|
|
|
|
cl.time += 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.last_received_message = realtime;
|
|
|
|
CL_ParseServerMessage ();
|
|
|
|
} 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 ();
|
|
|
|
CL_UpdateTEnts ();
|
|
|
|
|
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
|
|
|
|
|
|
|
if (cls.state != ca_connected)
|
|
|
|
return;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
if (cls.signon == SIGNONS) {
|
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)) {
|
2010-11-23 05:09:30 +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;
|
2002-08-27 08:33:21 +00:00
|
|
|
if (old_state != state) {
|
|
|
|
if (state == ca_active) {
|
|
|
|
// entering active state
|
|
|
|
r_active = true;
|
|
|
|
game_target = IMT_0;
|
|
|
|
key_dest = key_game;
|
|
|
|
IN_ClearStates ();
|
|
|
|
VID_SetCaption ("");
|
|
|
|
} else if (old_state == ca_active) {
|
|
|
|
// leaving active state
|
|
|
|
r_active = false;
|
|
|
|
game_target = IMT_CONSOLE;
|
|
|
|
key_dest = key_console;
|
|
|
|
VID_SetCaption ("Disconnected");
|
|
|
|
}
|
2010-08-24 00:53:54 +00:00
|
|
|
if (state == ca_connected)
|
|
|
|
S_AmbientOn ();
|
|
|
|
else
|
|
|
|
S_AmbientOff ();
|
2001-08-20 17:48:16 +00:00
|
|
|
}
|
2002-08-27 08:33:21 +00:00
|
|
|
if (con_module)
|
|
|
|
con_module->data->console->force_commandline = (state != ca_active);
|
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)
|
|
|
|
{
|
|
|
|
cl.viewangles[PITCH] = 0;
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_Init (void)
|
|
|
|
{
|
2001-02-19 21:15:25 +00:00
|
|
|
SZ_Alloc (&cls.message, 1024);
|
|
|
|
|
|
|
|
CL_InitInput ();
|
2001-05-15 21:34:54 +00:00
|
|
|
CL_TEnts_Init ();
|
2002-12-11 22:09:23 +00:00
|
|
|
CL_ClearState ();
|
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");
|
|
|
|
Cmd_AddCommand ("record", CL_Record_f, "No Description");
|
|
|
|
Cmd_AddCommand ("stop", CL_Stop_f, "No Description");
|
|
|
|
Cmd_AddCommand ("playdemo", CL_PlayDemo_f, "No Description");
|
|
|
|
Cmd_AddCommand ("timedemo", CL_TimeDemo_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");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|