2001-02-26 06:48:02 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
$Id$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-04-10 23:17:47 +00:00
|
|
|
#include "QF/compat.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#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"
|
|
|
|
#include "QF/screen.h"
|
|
|
|
#include "QF/va.h"
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "client.h"
|
|
|
|
#include "chase.h"
|
|
|
|
#include "host.h"
|
|
|
|
#include "host.h"
|
2001-05-09 05:41:34 +00:00
|
|
|
#include "render.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
|
|
|
// we need to declare some mouse variables here, because the menu system
|
|
|
|
// references them even when on a unix system.
|
|
|
|
|
|
|
|
// these two are not intended to be set directly
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_name;
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
cvar_t *writecfg;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_shownet;
|
|
|
|
cvar_t *cl_nolerp;
|
|
|
|
cvar_t *cl_sbar;
|
2001-05-14 19:46:16 +00:00
|
|
|
cvar_t *cl_sbar_separator;
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *cl_hudswap;
|
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
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
cvar_t *r_firecolor;
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
cvar_t *show_fps;
|
|
|
|
cvar_t *show_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
|
|
|
efrag_t cl_efrags[MAX_EFRAGS];
|
|
|
|
entity_t cl_entities[MAX_EDICTS];
|
|
|
|
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
|
|
|
|
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
|
|
|
|
dlight_t cl_dlights[MAX_DLIGHTS];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
int cl_numvisedicts;
|
|
|
|
entity_t *cl_visedicts[MAX_VISEDICTS];
|
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-05-09 05:41:34 +00:00
|
|
|
cl_warncmd = Cvar_Get ("cl_warncmd", "0", CVAR_NONE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"inform when execing a command");
|
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-05-09 05:41:34 +00:00
|
|
|
cl_color = Cvar_Get ("_cl_color", "0", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"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-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-09 05:41:34 +00:00
|
|
|
cl_sbar = Cvar_Get ("cl_sbar", "0", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"status bar mode");
|
2001-05-09 05:41:34 +00:00
|
|
|
cl_hudswap = Cvar_Get ("cl_hudswap", "0", CVAR_ARCHIVE, NULL,
|
2001-05-13 22:57:27 +00:00
|
|
|
"new HUD on left side?");
|
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");
|
2001-05-14 03:08:24 +00:00
|
|
|
r_firecolor = Cvar_Get ("r_firecolor", "0.9 0.4 0", CVAR_ARCHIVE, NULL,
|
|
|
|
"color of rocket and lava ball fires");
|
|
|
|
show_fps = Cvar_Get ("show_fps", "0", CVAR_NONE, NULL,
|
|
|
|
"display realtime frames per second");
|
|
|
|
show_time = Cvar_Get ("show_time", "0", CVAR_NONE, 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 ();
|
|
|
|
|
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));
|
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_efrags, 0, sizeof (cl_efrags));
|
|
|
|
memset (cl_entities, 0, sizeof (cl_entities));
|
|
|
|
memset (cl_dlights, 0, sizeof (cl_dlights));
|
|
|
|
memset (cl_lightstyle, 0, sizeof (cl_lightstyle));
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// allocate the efrags and chain together into a free list
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.free_efrags = cl_efrags;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_EFRAGS - 1; i++)
|
|
|
|
cl.free_efrags[i].entnext = &cl.free_efrags[i + 1];
|
2001-02-19 21:15:25 +00:00
|
|
|
cl.free_efrags[i].entnext = NULL;
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +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 :)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_StopCshifts (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
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!)
|
2001-02-19 21:15:25 +00:00
|
|
|
S_StopAllSounds (true);
|
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 ();
|
|
|
|
|
|
|
|
Con_DPrintf ("Sending clc_disconnect\n");
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
MSG_WriteByte (&cls.message, clc_disconnect);
|
|
|
|
NET_SendUnreliableMessage (cls.netcon, &cls.message);
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
NET_Close (cls.netcon);
|
|
|
|
|
|
|
|
cls.state = ca_disconnected;
|
|
|
|
if (sv.active)
|
2001-02-26 06:48:02 +00:00
|
|
|
Host_ShutdownServer (false);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cls.demoplayback = cls.timedemo = false;
|
|
|
|
cls.signon = 0;
|
|
|
|
}
|
|
|
|
|
2001-05-11 01:01:27 +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
|
|
|
|
CL_EstablishConnection (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");
|
|
|
|
Con_DPrintf ("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-02-19 21:15:25 +00:00
|
|
|
cls.state = 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-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
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
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_DPrintf ("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-09 05:41:34 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
/*
|
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]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("No demos listed with startdemos\n");
|
|
|
|
cls.demonum = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
snprintf (str, sizeof (str), "playdemo %s\n", cls.demos[cls.demonum]);
|
2001-02-19 21:15:25 +00:00
|
|
|
Cbuf_InsertText (str);
|
|
|
|
cls.demonum++;
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
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++) {
|
|
|
|
Con_Printf ("%3i:", i);
|
|
|
|
if (!ent->model) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_Printf ("EMPTY\n");
|
|
|
|
continue;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
Con_Printf ("%s:%2i (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n",
|
|
|
|
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
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
SetPal (int i)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
|
|
|
#if 0
|
2001-02-26 06:48:02 +00:00
|
|
|
static int old;
|
|
|
|
byte pal[768];
|
|
|
|
int c;
|
|
|
|
|
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)
|
2001-04-15 04:18:22 +00:00
|
|
|
VID_SetPalette (vid_basepal);
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
dlight_t *
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_AllocDlight (int key)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
dlight_t *dl;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
// first look for an exact key match
|
2001-02-26 06:48:02 +00:00
|
|
|
if (key) {
|
2001-02-19 21:15:25 +00:00
|
|
|
dl = cl_dlights;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
|
|
|
if (dl->key == key) {
|
|
|
|
memset (dl, 0, sizeof (*dl));
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->key = key;
|
|
|
|
return dl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-05-14 19:46:16 +00:00
|
|
|
// then look for anything else
|
2001-02-19 21:15:25 +00:00
|
|
|
dl = cl_dlights;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
|
|
|
if (dl->die < cl.time) {
|
|
|
|
memset (dl, 0, sizeof (*dl));
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->key = key;
|
|
|
|
return dl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dl = &cl_dlights[0];
|
2001-02-26 06:48:02 +00:00
|
|
|
memset (dl, 0, sizeof (*dl));
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->key = key;
|
|
|
|
return dl;
|
|
|
|
}
|
|
|
|
|
2001-05-09 05:41:34 +00:00
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_NewDlight (int key, float x, float y, float z, float radius, float time,
|
|
|
|
int type)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
dlight_t *dl;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
dl = CL_AllocDlight (key);
|
|
|
|
dl->origin[0] = x;
|
|
|
|
dl->origin[1] = y;
|
|
|
|
dl->origin[2] = z;
|
|
|
|
dl->radius = radius;
|
|
|
|
dl->die = cl.time + time;
|
2001-02-26 06:48:02 +00:00
|
|
|
switch (type) {
|
2001-05-14 19:46:16 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
2001-02-26 06:48:02 +00:00
|
|
|
dl->color[0] = 0.4;
|
|
|
|
dl->color[1] = 0.2;
|
|
|
|
dl->color[2] = 0.05;
|
|
|
|
break;
|
2001-05-14 19:46:16 +00:00
|
|
|
case 1: // blue
|
2001-02-26 06:48:02 +00:00
|
|
|
dl->color[0] = 0.05;
|
|
|
|
dl->color[1] = 0.05;
|
|
|
|
dl->color[2] = 0.5;
|
|
|
|
break;
|
2001-05-14 19:46:16 +00:00
|
|
|
case 2: // red
|
2001-02-26 06:48:02 +00:00
|
|
|
dl->color[0] = 0.5;
|
|
|
|
dl->color[1] = 0.05;
|
|
|
|
dl->color[2] = 0.05;
|
|
|
|
break;
|
2001-05-14 19:46:16 +00:00
|
|
|
case 3: // purple
|
2001-02-26 06:48:02 +00:00
|
|
|
dl->color[0] = 0.5;
|
|
|
|
dl->color[1] = 0.05;
|
|
|
|
dl->color[2] = 0.5;
|
|
|
|
break;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_DecayLights (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-02-26 06:48:02 +00:00
|
|
|
int i;
|
|
|
|
dlight_t *dl;
|
|
|
|
float time;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
time = cl.time - cl.oldtime;
|
|
|
|
|
|
|
|
dl = cl_dlights;
|
2001-02-26 06:48:02 +00:00
|
|
|
for (i = 0; i < MAX_DLIGHTS; i++, dl++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (dl->die < cl.time || !dl->radius)
|
|
|
|
continue;
|
2001-02-26 06:48:02 +00:00
|
|
|
|
|
|
|
dl->radius -= time * dl->decay;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (dl->radius < 0)
|
|
|
|
dl->radius = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
*/
|
2001-02-26 06:48:02 +00:00
|
|
|
float
|
|
|
|
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;
|
2001-05-14 19:46:16 +00:00
|
|
|
// Con_Printf ("frac: %f\n",frac);
|
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];
|
2001-05-14 19:46:16 +00:00
|
|
|
// Con_Printf ("low frac\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
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];
|
2001-05-14 19:46:16 +00:00
|
|
|
// Con_Printf ("high frac\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
frac = 1;
|
2001-02-26 06:48:02 +00:00
|
|
|
} else
|
|
|
|
SetPal (0);
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
return frac;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
void
|
|
|
|
CL_RelinkEntities (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2001-05-15 21:34:54 +00:00
|
|
|
entity_t **_ent;
|
2001-02-26 06:48:02 +00:00
|
|
|
entity_t *ent;
|
|
|
|
int i, j;
|
|
|
|
float frac, f, d;
|
|
|
|
vec3_t delta;
|
|
|
|
float bobjrotate;
|
|
|
|
vec3_t oldorg;
|
|
|
|
dlight_t *dl;
|
|
|
|
|
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-02-26 06:48:02 +00:00
|
|
|
for (i = 1, ent = cl_entities + 1; i < cl.num_entities; i++, ent++) {
|
|
|
|
if (!ent->model) { // empty slot
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->forcelink)
|
|
|
|
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-02-26 06:48:02 +00:00
|
|
|
if (ent->msgtime != cl.mtime[0]) {
|
2001-02-19 21:15:25 +00:00
|
|
|
ent->model = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorCopy (ent->origin, oldorg);
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
if (ent->forcelink) { // the entity was not updated in the
|
|
|
|
// last message so move to the final spot
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (ent->msg_origins[0], ent->origin);
|
|
|
|
VectorCopy (ent->msg_angles[0], ent->angles);
|
2001-05-14 19:46:16 +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-02-26 06:48:02 +00:00
|
|
|
for (j = 0; j < 3; j++) {
|
2001-02-19 21:15:25 +00:00
|
|
|
delta[j] = ent->msg_origins[0][j] - ent->msg_origins[1][j];
|
|
|
|
if (delta[j] > 100 || delta[j] < -100)
|
2001-05-14 19:46:16 +00:00
|
|
|
f = 1; // assume a teleportation, not a motion
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2001-02-26 06:48:02 +00:00
|
|
|
// interpolate the origin and angles
|
|
|
|
for (j = 0; j < 3; j++) {
|
|
|
|
ent->origin[j] = ent->msg_origins[1][j] + f * delta[j];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
d = ent->msg_angles[0][j] - ent->msg_angles[1][j];
|
|
|
|
if (d > 180)
|
|
|
|
d -= 360;
|
|
|
|
else if (d < -180)
|
|
|
|
d += 360;
|
2001-02-26 06:48:02 +00:00
|
|
|
ent->angles[j] = ent->msg_angles[1][j] + f * d;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (ent->effects & EF_BRIGHTFIELD)
|
|
|
|
R_EntityParticles (ent);
|
|
|
|
#ifdef QUAKE2
|
|
|
|
if (ent->effects & EF_DARKFIELD)
|
|
|
|
R_DarkFieldParticles (ent);
|
|
|
|
#endif
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ent->effects & EF_MUZZLEFLASH) {
|
|
|
|
vec3_t fv, rv, uv;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
dl = CL_AllocDlight (i);
|
2001-02-26 06:48:02 +00:00
|
|
|
VectorCopy (ent->origin, dl->origin);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->origin[2] += 16;
|
|
|
|
AngleVectors (ent->angles, fv, rv, uv);
|
2001-02-26 06:48:02 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorMA (dl->origin, 18, fv, dl->origin);
|
2001-02-26 06:48:02 +00:00
|
|
|
dl->radius = 200 + (rand () & 31);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->minlight = 32;
|
|
|
|
dl->die = cl.time + 0.1;
|
|
|
|
dl->color[0] = 0.2;
|
|
|
|
dl->color[1] = 0.1;
|
|
|
|
dl->color[2] = 0.05;
|
|
|
|
}
|
|
|
|
if ((ent->effects & (EF_BLUE | EF_RED)) == (EF_BLUE | EF_RED))
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2],
|
|
|
|
200 + (rand () & 31), 0.1, 3);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->effects & EF_BLUE)
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2],
|
|
|
|
200 + (rand () & 31), 0.1, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->effects & EF_RED)
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2],
|
|
|
|
200 + (rand () & 31), 0.1, 2);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->effects & EF_BRIGHTLIGHT)
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_NewDlight (i, ent->origin[0], ent->origin[1],
|
|
|
|
ent->origin[2] + 16, 400 + (rand () & 31), 0.001, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->effects & EF_DIMLIGHT)
|
2001-02-26 06:48:02 +00:00
|
|
|
CL_NewDlight (i, ent->origin[0], ent->origin[1], ent->origin[2],
|
|
|
|
200 + (rand () & 31), 0.001, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef QUAKE2
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ent->effects & EF_DARKLIGHT) {
|
2001-02-19 21:15:25 +00:00
|
|
|
dl = CL_AllocDlight (i);
|
2001-02-26 06:48:02 +00:00
|
|
|
VectorCopy (ent->origin, dl->origin);
|
|
|
|
dl->radius = 200.0 + (rand () & 31);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->die = cl.time + 0.001;
|
|
|
|
dl->dark = true;
|
|
|
|
}
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ent->effects & EF_LIGHT) {
|
2001-02-19 21:15:25 +00:00
|
|
|
dl = CL_AllocDlight (i);
|
2001-02-26 06:48:02 +00:00
|
|
|
VectorCopy (ent->origin, dl->origin);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->radius = 200;
|
|
|
|
dl->die = cl.time + 0.001;
|
|
|
|
}
|
|
|
|
#endif
|
2001-05-09 05:41:34 +00:00
|
|
|
if (VectorDistance_fast(ent->msg_origins[1], ent->origin) > (256*256))
|
|
|
|
VectorCopy (ent ->origin, ent->msg_origins[1]);
|
|
|
|
if (ent->model->flags & EF_ROCKET) {
|
2001-02-19 21:15:25 +00:00
|
|
|
dl = CL_AllocDlight (i);
|
|
|
|
VectorCopy (ent->origin, dl->origin);
|
2001-05-09 05:41:34 +00:00
|
|
|
VectorCopy (r_firecolor->vec, dl->color);
|
2001-02-19 21:15:25 +00:00
|
|
|
dl->radius = 200;
|
2001-05-09 05:41:34 +00:00
|
|
|
dl->die = cl.time + 0.1;
|
|
|
|
R_RocketTrail (0, ent);
|
2001-02-26 06:48:02 +00:00
|
|
|
} else if (ent->model->flags & EF_GRENADE)
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RocketTrail (1, ent);
|
|
|
|
else if (ent->model->flags & EF_GIB)
|
|
|
|
R_RocketTrail (2, ent);
|
|
|
|
else if (ent->model->flags & EF_ZOMGIB)
|
|
|
|
R_RocketTrail (4, ent);
|
|
|
|
else if (ent->model->flags & EF_TRACER)
|
|
|
|
R_RocketTrail (3, ent);
|
|
|
|
else if (ent->model->flags & EF_TRACER2)
|
|
|
|
R_RocketTrail (5, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (ent->model->flags & EF_TRACER3)
|
2001-05-09 05:41:34 +00:00
|
|
|
R_RocketTrail (6, ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
ent->forcelink = false;
|
|
|
|
|
|
|
|
if (i == cl.viewentity && !chase_active->int_val)
|
|
|
|
continue;
|
|
|
|
#ifdef QUAKE2
|
2001-02-26 06:48:02 +00:00
|
|
|
if (ent->effects & EF_NODRAW)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
#endif
|
2001-05-15 21:34:54 +00:00
|
|
|
if ((_ent = CL_NewTempEntity ()))
|
|
|
|
*_ent = ent;
|
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)
|
|
|
|
Con_Printf ("\n");
|
|
|
|
|
2001-05-15 21:34:54 +00:00
|
|
|
cl_numvisedicts = 0;
|
|
|
|
|
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-05-14 19:46:16 +00:00
|
|
|
|
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)) {
|
2001-02-19 21:15:25 +00:00
|
|
|
Con_DPrintf ("CL_WriteToServer: can't send\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NET_SendMessage (cls.netcon, &cls.message) == -1)
|
|
|
|
Host_Error ("CL_WriteToServer: lost server connection");
|
|
|
|
|
|
|
|
SZ_Clear (&cls.message);
|
|
|
|
}
|
|
|
|
|
2001-05-14 19:46:16 +00:00
|
|
|
|
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 ();
|
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");
|
|
|
|
Cmd_AddCommand ("maplist", COM_Maplist_f, "No Description");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|