2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
cl_ents.c
|
|
|
|
|
|
|
|
entity parsing and management
|
|
|
|
|
|
|
|
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
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2004-03-23 22:39:17 +00:00
|
|
|
#include "QF/locs.h"
|
2001-05-21 00:22:35 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/render.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-21 00:22:35 +00:00
|
|
|
|
2004-02-21 05:09:02 +00:00
|
|
|
#include "qw/msg_ucmd.h"
|
|
|
|
|
2005-05-08 08:04:50 +00:00
|
|
|
#include "qw/bothdefs.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "cl_cam.h"
|
|
|
|
#include "cl_ents.h"
|
|
|
|
#include "cl_main.h"
|
2001-05-21 22:25:35 +00:00
|
|
|
#include "cl_parse.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "cl_pred.h"
|
|
|
|
#include "cl_tent.h"
|
2001-08-25 02:47:11 +00:00
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
#include "d_iface.h"
|
|
|
|
#include "host.h"
|
2005-05-02 04:09:15 +00:00
|
|
|
#include "qw/pmove.h"
|
2011-07-23 06:56:22 +00:00
|
|
|
#include "clview.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-03 05:36:39 +00:00
|
|
|
entity_t cl_player_ents[MAX_CLIENTS];
|
2001-11-27 21:42:49 +00:00
|
|
|
entity_t cl_flag_ents[MAX_CLIENTS];
|
2001-12-03 05:36:39 +00:00
|
|
|
entity_t cl_packet_ents[512]; // FIXME: magic number
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void
|
2011-08-27 01:25:41 +00:00
|
|
|
CL_ClearEnts (void)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-08-27 01:25:41 +00:00
|
|
|
size_t i;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-12-03 05:36:39 +00:00
|
|
|
for (i = 0; i < sizeof (cl_packet_ents) / sizeof (cl_packet_ents[0]); i++)
|
|
|
|
CL_Init_Entity (&cl_packet_ents[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
for (i = 0; i < sizeof (cl_flag_ents) / sizeof (cl_flag_ents[0]); i++)
|
|
|
|
CL_Init_Entity (&cl_flag_ents[i]);
|
2001-12-03 05:36:39 +00:00
|
|
|
for (i = 0; i < sizeof (cl_player_ents) / sizeof (cl_player_ents[0]); i++)
|
|
|
|
CL_Init_Entity (&cl_player_ents[i]);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-06-18 21:41:24 +00:00
|
|
|
CL_NewDlight (int key, vec3_t org, int effects, byte glow_size,
|
|
|
|
byte glow_color)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2011-08-27 01:25:41 +00:00
|
|
|
float radius;
|
2001-08-28 23:05:45 +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
|
|
|
|
2003-12-02 23:42:09 +00:00
|
|
|
effects &= EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT;
|
|
|
|
if (!effects) {
|
2002-06-18 21:41:24 +00:00
|
|
|
if (!glow_size)
|
|
|
|
return;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-02-14 10:47:02 +00:00
|
|
|
dl = r_funcs->R_AllocDlight (key);
|
2002-06-05 22:07:38 +00:00
|
|
|
if (!dl)
|
|
|
|
return;
|
2001-02-19 21:15:25 +00:00
|
|
|
VectorCopy (org, dl->origin);
|
2002-06-18 21:41:24 +00:00
|
|
|
|
|
|
|
if (effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT)) {
|
|
|
|
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;
|
2002-06-19 17:32:39 +00:00
|
|
|
dl->die = cl.time + 0.1;
|
2011-08-27 01:25:41 +00:00
|
|
|
|
2002-06-18 21:41:24 +00:00
|
|
|
switch (effects & (EF_RED | EF_BLUE)) {
|
|
|
|
case EF_RED | EF_BLUE:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (purple, dl->color);
|
2002-06-18 21:41:24 +00:00
|
|
|
break;
|
|
|
|
case EF_RED:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (red, dl->color);
|
2002-06-18 21:41:24 +00:00
|
|
|
break;
|
|
|
|
case EF_BLUE:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (blue, dl->color);
|
2002-06-18 21:41:24 +00:00
|
|
|
break;
|
|
|
|
default:
|
2004-05-03 06:21:39 +00:00
|
|
|
QuatCopy (normal, dl->color);
|
2002-06-18 21:41:24 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-06-07 05:21:53 +00:00
|
|
|
}
|
2002-06-18 21:41:24 +00:00
|
|
|
|
|
|
|
if (glow_size) {
|
|
|
|
dl->radius += glow_size < 128 ? glow_size * 8.0 :
|
|
|
|
(glow_size - 256) * 8.0;
|
2002-06-19 17:32:39 +00:00
|
|
|
dl->die = cl.time + 0.1;
|
2002-06-18 21:41:24 +00:00
|
|
|
if (glow_color) {
|
|
|
|
if (glow_color == 255) {
|
|
|
|
dl->color[0] = dl->color[1] = dl->color[2] = 1.0;
|
|
|
|
} else {
|
2011-08-27 01:25:41 +00:00
|
|
|
byte *tempcolor;
|
2002-06-18 21:41:24 +00:00
|
|
|
|
|
|
|
tempcolor = (byte *) &d_8to24table[glow_color];
|
2011-08-27 01:25:41 +00:00
|
|
|
VectorScale (tempcolor, 1 / 255.0, dl->color);
|
2002-06-18 21:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
// Hack hack hack
|
|
|
|
static inline int
|
|
|
|
is_dead_body (entity_state_t *s1)
|
|
|
|
{
|
|
|
|
int i = s1->frame;
|
|
|
|
|
|
|
|
if (s1->modelindex == cl_playerindex
|
|
|
|
&& (i == 49 || i == 60 || i == 69 || i == 84 || i == 93 || i == 102))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hack hack hack
|
|
|
|
static inline int
|
|
|
|
is_gib (entity_state_t *s1)
|
|
|
|
{
|
|
|
|
if (s1->modelindex == cl_h_playerindex || s1->modelindex == cl_gib1index
|
|
|
|
|| s1->modelindex == cl_gib2index || s1->modelindex == cl_gib3index)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-12-15 03:06:03 +00:00
|
|
|
void
|
|
|
|
CL_TransformEntity (entity_t *ent, const vec3_t angles, qboolean force)
|
|
|
|
{
|
|
|
|
vec3_t ang;
|
|
|
|
vec_t *forward, *left, *up;
|
|
|
|
|
|
|
|
if (VectorIsZero (angles)) {
|
|
|
|
VectorSet (1, 0, 0, ent->transform + 0);
|
|
|
|
VectorSet (0, 1, 0, ent->transform + 4);
|
|
|
|
VectorSet (0, 0, 1, ent->transform + 8);
|
|
|
|
} else if (force || !VectorCompare (angles, ent->angles)) {
|
|
|
|
forward = ent->transform + 0;
|
|
|
|
left = ent->transform + 4;
|
|
|
|
up = ent->transform + 8;
|
|
|
|
VectorCopy (angles, ang);
|
|
|
|
if (ent->model && ent->model->type == mod_alias) {
|
|
|
|
// stupid quake bug
|
|
|
|
// why, oh, why, do alias models pitch in the opposite direction
|
|
|
|
// to everything else?
|
|
|
|
ang[PITCH] = -ang[PITCH];
|
|
|
|
}
|
|
|
|
AngleVectors (ang, forward, left, up);
|
|
|
|
VectorNegate (left, left); // AngleVectors is right-handed
|
|
|
|
}
|
|
|
|
VectorCopy (angles, ent->angles);
|
|
|
|
ent->transform[3] = 0;
|
|
|
|
ent->transform[7] = 0;
|
|
|
|
ent->transform[11] = 0;
|
|
|
|
VectorCopy (ent->origin, ent->transform + 12);
|
|
|
|
ent->transform[15] = 1;
|
|
|
|
}
|
|
|
|
|
2012-06-19 23:02:29 +00:00
|
|
|
static void
|
|
|
|
CL_ModelEffects (entity_t *ent, int num, int glow_color)
|
|
|
|
{
|
|
|
|
dlight_t *dl;
|
|
|
|
model_t *model = ent->model;
|
|
|
|
|
2012-06-20 11:41:26 +00:00
|
|
|
// add automatic particle trails
|
2012-06-19 23:02:29 +00:00
|
|
|
if (model->flags & EF_ROCKET) {
|
|
|
|
dl = r_funcs->R_AllocDlight (num);
|
|
|
|
if (dl) {
|
|
|
|
VectorCopy (ent->origin, dl->origin);
|
|
|
|
dl->radius = 200.0;
|
|
|
|
dl->die = cl.time + 0.1;
|
|
|
|
//FIXME VectorCopy (r_firecolor->vec, dl->color);
|
|
|
|
VectorSet (0.9, 0.7, 0.0, dl->color);
|
|
|
|
dl->color[3] = 0.7;
|
|
|
|
}
|
|
|
|
r_funcs->particles->R_RocketTrail (ent);
|
|
|
|
} else if (model->flags & EF_GRENADE)
|
|
|
|
r_funcs->particles->R_GrenadeTrail (ent);
|
|
|
|
else if (model->flags & EF_GIB)
|
|
|
|
r_funcs->particles->R_BloodTrail (ent);
|
|
|
|
else if (model->flags & EF_ZOMGIB)
|
|
|
|
r_funcs->particles->R_SlightBloodTrail (ent);
|
|
|
|
else if (model->flags & EF_TRACER)
|
|
|
|
r_funcs->particles->R_WizTrail (ent);
|
|
|
|
else if (model->flags & EF_TRACER2)
|
|
|
|
r_funcs->particles->R_FlameTrail (ent);
|
|
|
|
else if (model->flags & EF_TRACER3)
|
|
|
|
r_funcs->particles->R_VoorTrail (ent);
|
|
|
|
else if (model->flags & EF_GLOWTRAIL)
|
|
|
|
if (r_funcs->particles->R_GlowTrail)
|
|
|
|
r_funcs->particles->R_GlowTrail (ent, glow_color);
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_LinkPacketEntities (void)
|
|
|
|
{
|
2012-01-23 07:16:30 +00:00
|
|
|
int pnum;
|
2010-12-03 05:10:53 +00:00
|
|
|
entity_t *ent;
|
2001-02-19 21:15:25 +00:00
|
|
|
entity_state_t *s1;
|
2001-09-10 17:32:22 +00:00
|
|
|
model_t *model;
|
|
|
|
packet_entities_t *pack;
|
|
|
|
|
2012-06-23 10:39:24 +00:00
|
|
|
pack = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK].packet_entities;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
for (pnum = 0; pnum < pack->num_entities; pnum++) {
|
|
|
|
s1 = &pack->entities[pnum];
|
|
|
|
|
|
|
|
// spawn light flashes, even ones coming from invisible objects
|
2002-06-18 21:41:24 +00:00
|
|
|
CL_NewDlight (s1->number, s1->origin, s1->effects, s1->glow_size,
|
|
|
|
s1->glow_color);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
ent = &cl_packet_ents[s1->number];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
// if set to invisible, skip
|
|
|
|
if (!s1->modelindex
|
|
|
|
|| (cl_deadbodyfilter->int_val && is_dead_body (s1))
|
|
|
|
|| (cl_gibfilter->int_val && is_gib (s1))) {
|
|
|
|
if (ent->efrag)
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_RemoveEfrags (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
2010-12-03 05:10:53 +00:00
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->model = model = cl.model_precache[s1->modelindex];
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->min_light = 0;
|
|
|
|
ent->fullbright = 0;
|
2004-07-11 01:41:01 +00:00
|
|
|
|
|
|
|
if (s1->modelindex == cl_playerindex) {
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->min_light = min (cl.fbskins, cl_fb_players->value);
|
|
|
|
if (ent->min_light >= 1.0)
|
|
|
|
ent->fullbright = 1;
|
2004-07-11 01:41:01 +00:00
|
|
|
}
|
|
|
|
|
2001-12-03 05:36:39 +00:00
|
|
|
// set colormap
|
2012-01-24 01:28:07 +00:00
|
|
|
ent->skin = s1->skin;
|
2012-01-23 14:38:32 +00:00
|
|
|
|
2012-06-28 00:33:23 +00:00
|
|
|
VectorCopy (ent_colormod[s1->colormod], ent->colormod);
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->colormod[3] = s1->alpha / 255.0;
|
|
|
|
ent->scale = s1->scale / 16.0;
|
2001-12-03 05:36:39 +00:00
|
|
|
// Ender: Extend (Colormod) [QSG - End]
|
|
|
|
|
|
|
|
// set skin
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->skinnum = s1->skinnum;
|
2001-12-03 05:36:39 +00:00
|
|
|
|
|
|
|
// set frame
|
2010-12-03 05:10:53 +00:00
|
|
|
ent->frame = s1->frame;
|
2002-03-14 21:33:56 +00:00
|
|
|
|
2010-12-03 11:30:01 +00:00
|
|
|
if (!ent->efrag) {
|
2011-12-13 07:57:45 +00:00
|
|
|
ent->pose1 = ent->pose2 = -1;
|
2002-03-14 21:33:56 +00:00
|
|
|
|
|
|
|
// No trail if new this frame
|
2010-12-03 05:10:53 +00:00
|
|
|
VectorCopy (s1->origin, ent->origin);
|
|
|
|
VectorCopy (ent->origin, ent->old_origin);
|
2002-03-14 21:33:56 +00:00
|
|
|
} else {
|
2010-12-03 05:10:53 +00:00
|
|
|
VectorCopy (ent->origin, ent->old_origin);
|
|
|
|
VectorCopy (s1->origin, ent->origin);
|
|
|
|
if (!VectorCompare (ent->origin, ent->old_origin)) {
|
|
|
|
// the entity moved, it must be relinked
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_RemoveEfrags (ent);
|
2010-12-03 05:10:53 +00:00
|
|
|
}
|
2001-12-03 05:36:39 +00:00
|
|
|
}
|
2010-12-03 05:10:53 +00:00
|
|
|
if (!ent->efrag)
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_AddEfrags (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-06-19 23:02:29 +00:00
|
|
|
// rotate binary objects locally
|
|
|
|
if (model->flags & EF_ROTATE) {
|
|
|
|
vec3_t angles;
|
|
|
|
angles[PITCH] = 0;
|
|
|
|
angles[YAW] = anglemod (100 * cl.time);
|
|
|
|
angles[ROLL] = 0;
|
|
|
|
CL_TransformEntity (ent, angles, false);
|
2001-12-03 05:36:39 +00:00
|
|
|
} else {
|
2011-12-15 03:06:03 +00:00
|
|
|
CL_TransformEntity (ent, s1->angles, false);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2012-06-20 11:41:26 +00:00
|
|
|
if (model->flags & ~EF_ROTATE)
|
|
|
|
CL_ModelEffects (ent, -s1->number, s1->glow_color);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_AddFlagModels
|
|
|
|
|
2010-12-02 08:11:33 +00:00
|
|
|
Called when the CTF flags are set. Flags are effectively temp entities.
|
2011-12-15 03:06:03 +00:00
|
|
|
|
|
|
|
NOTE: this must be called /after/ the entity has been transformed as it
|
|
|
|
uses the entity's transform matrix to get the frame vectors
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-11-25 06:24:26 +00:00
|
|
|
CL_AddFlagModels (entity_t *ent, int team, int key)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2002-08-06 03:52:38 +00:00
|
|
|
static float flag_offsets[] = {
|
|
|
|
16.0, 22.0, 26.0, 25.0, 24.0, 18.0, // 29-34 axpain
|
|
|
|
16.0, 24.0, 24.0, 22.0, 18.0, 16.0, // 35-40 pain
|
|
|
|
};
|
2011-12-15 03:06:03 +00:00
|
|
|
float f;
|
2010-12-03 05:54:39 +00:00
|
|
|
entity_t *fent;
|
2011-12-15 03:06:03 +00:00
|
|
|
vec_t *v_forward, *v_left;
|
|
|
|
vec3_t ang;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (cl_flagindex == -1)
|
|
|
|
return;
|
|
|
|
|
2002-06-30 16:19:37 +00:00
|
|
|
f = 14.0;
|
2001-02-19 21:15:25 +00:00
|
|
|
if (ent->frame >= 29 && ent->frame <= 40) {
|
2002-08-06 03:52:38 +00:00
|
|
|
f = flag_offsets[ent->frame - 29];
|
2001-02-19 21:15:25 +00:00
|
|
|
} else if (ent->frame >= 103 && ent->frame <= 118) {
|
2002-08-03 17:20:07 +00:00
|
|
|
if (ent->frame <= 106) // 103-104 nailattack
|
2002-07-02 18:07:51 +00:00
|
|
|
f = 20.0; // 105-106 light
|
2002-08-03 17:20:07 +00:00
|
|
|
else // 107-112 rocketattack
|
|
|
|
f = 21.0; // 112-118 shotattack
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2010-12-03 05:54:39 +00:00
|
|
|
fent = &cl_flag_ents[key];
|
|
|
|
fent->model = cl.model_precache[cl_flagindex];
|
|
|
|
fent->skinnum = team;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-12-15 03:06:03 +00:00
|
|
|
v_forward = ent->transform + 0;
|
|
|
|
v_left = ent->transform + 4;
|
2010-12-03 05:54:39 +00:00
|
|
|
|
|
|
|
VectorMultAdd (ent->origin, -f, v_forward, fent->origin);
|
2011-12-15 03:06:03 +00:00
|
|
|
VectorMultAdd (fent->origin, -22, v_left, fent->origin);
|
2010-12-03 05:54:39 +00:00
|
|
|
fent->origin[2] -= 16.0;
|
|
|
|
|
2011-12-15 03:06:03 +00:00
|
|
|
VectorCopy (ent->angles, ang);
|
|
|
|
ang[2] -= 45.0;
|
|
|
|
CL_TransformEntity (fent, ang, false);
|
2010-12-03 05:54:39 +00:00
|
|
|
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_EnqueueEntity (fent);//FIXME should use efrag (needs smarter
|
|
|
|
// handling //in the player code)
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_LinkPlayers
|
|
|
|
|
|
|
|
Create visible entities in the correct position
|
|
|
|
for all current players
|
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
CL_LinkPlayers (void)
|
|
|
|
{
|
2001-09-10 17:32:22 +00:00
|
|
|
double playertime;
|
|
|
|
int msec, oldphysent, i, j;
|
2001-11-15 19:37:29 +00:00
|
|
|
entity_t *ent;
|
2001-09-10 17:32:22 +00:00
|
|
|
frame_t *frame;
|
2001-08-28 23:05:45 +00:00
|
|
|
player_info_t *info;
|
2001-09-10 17:32:22 +00:00
|
|
|
player_state_t exact;
|
2001-02-19 21:15:25 +00:00
|
|
|
player_state_t *state;
|
2002-07-27 00:44:54 +00:00
|
|
|
qboolean clientplayer;
|
2012-02-26 07:01:04 +00:00
|
|
|
vec3_t org, ang = {0, 0, 0};
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
playertime = realtime - cls.latency + 0.02;
|
|
|
|
if (playertime > realtime)
|
|
|
|
playertime = realtime;
|
|
|
|
|
|
|
|
frame = &cl.frames[cl.parsecount & UPDATE_MASK];
|
|
|
|
|
|
|
|
for (j = 0, info = cl.players, state = frame->playerstate; j < MAX_CLIENTS;
|
|
|
|
j++, info++, state++) {
|
2002-04-25 04:30:03 +00:00
|
|
|
ent = &cl_player_ents[j];
|
|
|
|
if (ent->efrag)
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_RemoveEfrags (ent);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (state->messagenum != cl.parsecount)
|
2002-07-03 00:37:28 +00:00
|
|
|
continue; // not present this frame
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2012-05-21 14:04:47 +00:00
|
|
|
if (!info->name || !info->name->value[0])
|
2002-03-15 16:49:40 +00:00
|
|
|
continue;
|
|
|
|
|
2002-06-18 21:41:24 +00:00
|
|
|
// spawn light flashes, even ones coming from invisible objects
|
|
|
|
if (j == cl.playernum) {
|
|
|
|
VectorCopy (cl.simorg, org);
|
2012-02-14 10:47:02 +00:00
|
|
|
r_data->player_entity = &cl_player_ents[j];
|
2002-07-27 00:44:54 +00:00
|
|
|
clientplayer = true;
|
|
|
|
} else {
|
2005-04-30 03:59:23 +00:00
|
|
|
VectorCopy (state->pls.origin, org);
|
2002-07-27 00:44:54 +00:00
|
|
|
clientplayer = false;
|
|
|
|
}
|
2012-06-29 08:59:30 +00:00
|
|
|
if (info->chat && info->chat->value[0] != '0') {
|
|
|
|
dlight_t *dl = r_funcs->R_AllocDlight (j + 1);
|
|
|
|
VectorCopy (org, dl->origin);
|
|
|
|
dl->radius = 100;
|
|
|
|
dl->die = cl.time + 0.1;
|
|
|
|
QuatSet (0.0, 1.0, 0.0, 1.0, dl->color);
|
|
|
|
} else {
|
|
|
|
CL_NewDlight (j + 1, org, state->pls.effects, state->pls.glow_size,
|
|
|
|
state->pls.glow_color);
|
|
|
|
}
|
2002-06-18 21:41:24 +00:00
|
|
|
|
2002-07-27 00:44:54 +00:00
|
|
|
// Draw player?
|
|
|
|
if (!Cam_DrawPlayer (j))
|
|
|
|
continue;
|
2002-07-03 00:37:28 +00:00
|
|
|
|
2005-04-30 03:59:23 +00:00
|
|
|
if (!state->pls.modelindex)
|
2001-02-19 21:15:25 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
// Hack hack hack
|
2005-04-30 03:59:23 +00:00
|
|
|
if (cl_deadbodyfilter->int_val
|
|
|
|
&& state->pls.modelindex == cl_playerindex
|
|
|
|
&& ((i = state->pls.frame) == 49 || i == 60 || i == 69 || i == 84
|
2001-02-19 21:15:25 +00:00
|
|
|
|| i == 93 || i == 102))
|
|
|
|
continue;
|
|
|
|
|
2010-01-13 06:42:26 +00:00
|
|
|
// predict only half the move to minimize overruns
|
2002-06-07 11:25:47 +00:00
|
|
|
msec = 500 * (playertime - state->state_time);
|
2002-10-02 21:56:45 +00:00
|
|
|
if (msec <= 0 || (!cl_predict_players->int_val) || cls.demoplayback2) {
|
2005-04-30 03:59:23 +00:00
|
|
|
VectorCopy (state->pls.origin, ent->origin);
|
2002-06-30 16:19:37 +00:00
|
|
|
} else { // predict players movement
|
2005-04-30 03:59:23 +00:00
|
|
|
state->pls.cmd.msec = msec = min (msec, 255);
|
2002-06-07 11:25:47 +00:00
|
|
|
|
|
|
|
oldphysent = pmove.numphysent;
|
|
|
|
CL_SetSolidPlayers (j);
|
2005-04-30 03:59:23 +00:00
|
|
|
CL_PredictUsercmd (state, &exact, &state->pls.cmd, clientplayer);
|
2002-06-07 11:25:47 +00:00
|
|
|
pmove.numphysent = oldphysent;
|
2005-04-30 03:59:23 +00:00
|
|
|
VectorCopy (exact.pls.origin, ent->origin);
|
2002-06-07 11:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// angles
|
|
|
|
if (j == cl.playernum)
|
|
|
|
{
|
2011-12-15 03:06:03 +00:00
|
|
|
ang[PITCH] = -cl.viewangles[PITCH] / 3.0;
|
|
|
|
ang[YAW] = cl.viewangles[YAW];
|
2002-06-18 21:41:24 +00:00
|
|
|
} else {
|
2011-12-15 03:06:03 +00:00
|
|
|
ang[PITCH] = -state->viewangles[PITCH] / 3.0;
|
|
|
|
ang[YAW] = state->viewangles[YAW];
|
2002-06-07 11:25:47 +00:00
|
|
|
}
|
2011-12-15 03:06:03 +00:00
|
|
|
ang[ROLL] = V_CalcRoll (ang, state->pls.velocity) * 4.0;
|
2002-06-07 11:25:47 +00:00
|
|
|
|
2005-04-30 03:59:23 +00:00
|
|
|
ent->model = cl.model_precache[state->pls.modelindex];
|
|
|
|
ent->frame = state->pls.frame;
|
|
|
|
ent->skinnum = state->pls.skinnum;
|
2004-07-11 01:41:01 +00:00
|
|
|
|
2011-12-15 03:06:03 +00:00
|
|
|
CL_TransformEntity (ent, ang, false);
|
|
|
|
|
2004-07-11 01:41:01 +00:00
|
|
|
ent->min_light = 0;
|
|
|
|
ent->fullbright = 0;
|
|
|
|
|
2005-04-30 03:59:23 +00:00
|
|
|
if (state->pls.modelindex == cl_playerindex) { //XXX
|
2001-12-03 05:36:39 +00:00
|
|
|
// use custom skin
|
2012-01-24 01:28:07 +00:00
|
|
|
ent->skin = info->skin;
|
2012-01-23 14:38:32 +00:00
|
|
|
|
2004-07-11 01:41:01 +00:00
|
|
|
ent->min_light = min (cl.fbskins, cl_fb_players->value);
|
|
|
|
|
|
|
|
if (ent->min_light >= 1.0)
|
|
|
|
ent->fullbright = 1;
|
2001-12-03 05:36:39 +00:00
|
|
|
} else {
|
2012-01-24 01:28:07 +00:00
|
|
|
// FIXME no team colors on nonstandard player models
|
|
|
|
ent->skin = 0;
|
2001-12-03 05:36:39 +00:00
|
|
|
}
|
2002-06-19 17:01:31 +00:00
|
|
|
|
2002-06-19 17:32:39 +00:00
|
|
|
// stuff entity in map
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->R_AddEfrags (ent);
|
2002-06-19 17:32:39 +00:00
|
|
|
|
2005-04-30 03:59:23 +00:00
|
|
|
if (state->pls.effects & EF_FLAG1)
|
2001-11-25 06:24:26 +00:00
|
|
|
CL_AddFlagModels (ent, 0, j);
|
2005-04-30 03:59:23 +00:00
|
|
|
else if (state->pls.effects & EF_FLAG2)
|
2001-11-25 06:24:26 +00:00
|
|
|
CL_AddFlagModels (ent, 1, j);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_EmitEntities
|
|
|
|
|
|
|
|
Builds the visedicts array for cl.time
|
|
|
|
|
|
|
|
Made up of: clients, packet_entities, nails, and tents
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_EmitEntities (void)
|
|
|
|
{
|
|
|
|
if (cls.state != ca_active)
|
|
|
|
return;
|
|
|
|
if (!cl.validsequence)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CL_LinkPlayers ();
|
|
|
|
CL_LinkPacketEntities ();
|
|
|
|
CL_UpdateTEnts ();
|
2012-02-14 10:47:02 +00:00
|
|
|
#if 0 //FIXME
|
2004-03-23 22:39:17 +00:00
|
|
|
if (!r_drawentities->int_val) {
|
|
|
|
dlight_t *dl;
|
|
|
|
location_t *nearloc;
|
|
|
|
vec3_t trueloc;
|
2007-09-15 04:20:45 +00:00
|
|
|
int i;
|
2004-03-23 22:39:17 +00:00
|
|
|
|
|
|
|
nearloc = locs_find (r_origin);
|
|
|
|
if (nearloc) {
|
2012-02-14 10:47:02 +00:00
|
|
|
dl = r_funcs->R_AllocDlight (4096);
|
2004-03-23 22:39:17 +00:00
|
|
|
if (dl) {
|
|
|
|
VectorCopy (nearloc->loc, dl->origin);
|
|
|
|
dl->radius = 200;
|
2012-02-14 10:47:02 +00:00
|
|
|
dl->die = r_data->realtime + 0.1;
|
2004-03-23 22:39:17 +00:00
|
|
|
dl->color[0] = 0;
|
|
|
|
dl->color[1] = 1;
|
|
|
|
dl->color[2] = 0;
|
2004-05-03 06:21:39 +00:00
|
|
|
dl->color[3] = 0.7;
|
2004-03-23 22:39:17 +00:00
|
|
|
}
|
|
|
|
VectorCopy (nearloc->loc, trueloc);
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->particles->R_Particle_New (pt_smokecloud, part_tex_smoke,
|
|
|
|
trueloc, 2.0,
|
|
|
|
vec3_origin, r_data->realtime + 9.0, 254,
|
|
|
|
0.25 + qfrandom (0.125), 0.0);
|
2007-09-15 04:20:45 +00:00
|
|
|
for (i = 0; i < 15; i++)
|
2012-02-14 10:47:02 +00:00
|
|
|
r_funcs->particles->R_Particle_NewRandom (pt_fallfade,
|
|
|
|
part_tex_dot, trueloc, 12,
|
|
|
|
0.7, 96, r_data->realtime + 5.0,
|
|
|
|
104 + (rand () & 7), 1.0, 0.0);
|
2004-03-23 22:39:17 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-14 10:47:02 +00:00
|
|
|
#endif
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_Ents_Init (void)
|
|
|
|
{
|
2012-02-14 10:47:02 +00:00
|
|
|
r_data->view_model = &cl.viewent;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|