2011-06-19 12:34:48 +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
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/cvar.h"
|
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/render.h"
|
|
|
|
#include "QF/skin.h"
|
|
|
|
#include "QF/sys.h"
|
|
|
|
|
2022-05-05 05:41:46 +00:00
|
|
|
#include "QF/scene/scene.h"
|
|
|
|
|
2011-06-19 12:34:48 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
2021-03-10 09:00:16 +00:00
|
|
|
#include "client/temp_entities.h"
|
2021-03-12 02:48:53 +00:00
|
|
|
#include "client/view.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-10 09:00:16 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/msg_ucmd.h"
|
|
|
|
#include "qw/pmove.h"
|
|
|
|
#include "qw/bothdefs.h"
|
|
|
|
|
|
|
|
#include "qw/include/cl_cam.h"
|
|
|
|
#include "qw/include/cl_ents.h"
|
|
|
|
#include "qw/include/cl_main.h"
|
|
|
|
#include "qw/include/cl_parse.h"
|
|
|
|
#include "qw/include/cl_pred.h"
|
|
|
|
#include "qw/include/host.h"
|
|
|
|
|
2011-06-19 12:34:48 +00:00
|
|
|
static struct predicted_player {
|
|
|
|
int flags;
|
|
|
|
qboolean active;
|
|
|
|
vec3_t origin; // predicted origin
|
|
|
|
} predicted_players[MAX_CLIENTS];
|
|
|
|
|
|
|
|
|
|
|
|
// PACKET ENTITY PARSING / LINKING ============================================
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_ParseDelta
|
|
|
|
|
|
|
|
Can go from either a baseline or a previous packet_entity
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// set everything to the state we are delta'ing from
|
|
|
|
*to = *from;
|
|
|
|
|
|
|
|
to->number = bits & 511;
|
|
|
|
bits &= ~511;
|
|
|
|
|
|
|
|
if (bits & U_MOREBITS) { // read in the low order bits
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
bits |= i;
|
|
|
|
}
|
|
|
|
|
|
|
|
// LordHavoc: Endy neglected to mark this as being part of the QSG
|
|
|
|
// version 2 stuff...
|
|
|
|
if (bits & U_EXTEND1) {
|
|
|
|
bits |= MSG_ReadByte (net_message) << 16;
|
|
|
|
if (bits & U_EXTEND2)
|
|
|
|
bits |= MSG_ReadByte (net_message) << 24;
|
|
|
|
}
|
|
|
|
|
|
|
|
to->flags = bits;
|
|
|
|
|
|
|
|
if (bits & U_MODEL)
|
|
|
|
to->modelindex = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (bits & U_FRAME)
|
|
|
|
to->frame = MSG_ReadByte (net_message);
|
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
if (bits & U_COLORMAP)
|
|
|
|
to->colormap = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (bits & U_SKIN)
|
|
|
|
to->skinnum = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (bits & U_EFFECTS)
|
|
|
|
to->effects = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ORIGIN1)
|
|
|
|
to->origin[0] = MSG_ReadCoord (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ANGLE1)
|
|
|
|
to->angles[0] = MSG_ReadAngle (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ORIGIN2)
|
|
|
|
to->origin[1] = MSG_ReadCoord (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ANGLE2)
|
|
|
|
to->angles[1] = MSG_ReadAngle (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ORIGIN3)
|
|
|
|
to->origin[2] = MSG_ReadCoord (net_message);
|
|
|
|
|
|
|
|
if (bits & U_ANGLE3)
|
|
|
|
to->angles[2] = MSG_ReadAngle (net_message);
|
|
|
|
|
2021-03-19 11:18:45 +00:00
|
|
|
to->origin[3] = 1;
|
|
|
|
|
2011-06-19 12:34:48 +00:00
|
|
|
if (bits & U_SOLID) {
|
|
|
|
// FIXME
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(bits & U_EXTEND1))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// LordHavoc: Endy neglected to mark this as being part of the QSG
|
|
|
|
// version 2 stuff... rearranged it and implemented missing effects
|
|
|
|
// Ender (QSG - Begin)
|
|
|
|
if (bits & U_ALPHA)
|
|
|
|
to->alpha = MSG_ReadByte (net_message);
|
|
|
|
if (bits & U_SCALE)
|
|
|
|
to->scale = MSG_ReadByte (net_message);
|
|
|
|
if (bits & U_EFFECTS2)
|
|
|
|
to->effects = (to->effects & 0xFF) | (MSG_ReadByte (net_message) << 8);
|
|
|
|
if (bits & U_GLOWSIZE)
|
|
|
|
to->glow_size = MSG_ReadByte (net_message);
|
|
|
|
if (bits & U_GLOWCOLOR)
|
|
|
|
to->glow_color = MSG_ReadByte (net_message);
|
|
|
|
if (bits & U_COLORMOD)
|
|
|
|
to->colormod = MSG_ReadByte (net_message);
|
|
|
|
|
|
|
|
if (!(bits & U_EXTEND2))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (bits & U_FRAME2)
|
|
|
|
to->frame = (to->frame & 0xFF) | (MSG_ReadByte (net_message) << 8);
|
|
|
|
// Ender (QSG - End)
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
FlushEntityPacket (void)
|
|
|
|
{
|
|
|
|
entity_state_t olde, newe;
|
|
|
|
int word;
|
|
|
|
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "FlushEntityPacket\n");
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
memset (&olde, 0, sizeof (olde));
|
|
|
|
|
|
|
|
cl.validsequence = 0; // can't render a frame
|
|
|
|
cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK].invalid = true;
|
|
|
|
|
|
|
|
// read it all, but ignore it
|
|
|
|
while (1) {
|
2011-08-28 09:29:46 +00:00
|
|
|
word = MSG_ReadShort (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
if (net_message->badread) { // something didn't parse right...
|
|
|
|
Host_Error ("msg_badread in packetentities");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!word)
|
|
|
|
break; // done
|
|
|
|
|
|
|
|
CL_ParseDelta (&olde, &newe, word);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
static void
|
|
|
|
copy_state (packet_entities_t *newp, packet_entities_t *oldp, int newindex,
|
|
|
|
int oldindex, int num)
|
|
|
|
{
|
|
|
|
newp->entities[num] = oldp->entities[num];
|
|
|
|
newp->ent_nums[newindex] = num;
|
|
|
|
cl_entity_valid[0][num] = 1;
|
|
|
|
}
|
|
|
|
|
2011-06-19 12:34:48 +00:00
|
|
|
void
|
|
|
|
CL_ParsePacketEntities (qboolean delta)
|
|
|
|
{
|
2012-07-05 10:06:35 +00:00
|
|
|
byte from;
|
|
|
|
int oldindex, newindex, newnum, oldnum, oldpacket, word;
|
2011-06-19 12:34:48 +00:00
|
|
|
packet_entities_t *oldp, *newp, dummy;
|
2012-07-05 10:06:35 +00:00
|
|
|
qboolean full;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
cl.prev_sequence = cl.link_sequence;
|
|
|
|
cl.link_sequence = cls.netchan.incoming_sequence;
|
|
|
|
newp = &cl.frames[cl.link_sequence & UPDATE_MASK].packet_entities;
|
|
|
|
cl.frames[cl.link_sequence & UPDATE_MASK].invalid = false;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (delta) {
|
|
|
|
from = MSG_ReadByte (net_message);
|
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
oldpacket = cl.frames[cl.link_sequence & UPDATE_MASK].delta_sequence;
|
2011-06-19 12:34:48 +00:00
|
|
|
if (cls.demoplayback2)
|
|
|
|
from = oldpacket = (cls.netchan.incoming_sequence - 1);
|
|
|
|
if ((from & UPDATE_MASK) != (oldpacket & UPDATE_MASK))
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "WARNING: from mismatch\n");
|
2011-06-19 12:34:48 +00:00
|
|
|
} else
|
|
|
|
oldpacket = -1;
|
|
|
|
|
|
|
|
full = false;
|
2012-07-05 10:06:35 +00:00
|
|
|
//memcpy (cl_entity_valid[1], cl_entity_valid[0],
|
|
|
|
// sizeof (cl_entity_valid[0]));
|
2011-06-19 12:34:48 +00:00
|
|
|
if (oldpacket != -1) {
|
|
|
|
if (cls.netchan.outgoing_sequence - oldpacket >= UPDATE_BACKUP - 1) {
|
|
|
|
// we can't use this, it is too old
|
|
|
|
FlushEntityPacket ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cl.validsequence = cls.netchan.incoming_sequence;
|
|
|
|
oldp = &cl.frames[oldpacket & UPDATE_MASK].packet_entities;
|
|
|
|
} else { // a full update that we can start delta compressing from now
|
|
|
|
oldp = &dummy;
|
|
|
|
dummy.num_entities = 0;
|
|
|
|
cl.validsequence = cls.netchan.incoming_sequence;
|
|
|
|
full = true;
|
2012-07-05 10:06:35 +00:00
|
|
|
memset (cl_entity_valid[0], 0, sizeof (cl_entity_valid[0]));
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
oldindex = 0;
|
|
|
|
newindex = 0;
|
|
|
|
newp->num_entities = 0;
|
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
newnum = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
while (1) {
|
2011-08-28 09:29:46 +00:00
|
|
|
word = MSG_ReadShort (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
if (net_message->badread) { // something didn't parse right...
|
|
|
|
Host_Error ("msg_badread in packetentities");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!word) { // copy rest of ents from old packet
|
|
|
|
while (oldindex < oldp->num_entities) {
|
|
|
|
if (newindex >= MAX_DEMO_PACKET_ENTITIES)
|
|
|
|
Host_Error ("CL_ParsePacketEntities: newindex == "
|
|
|
|
"MAX_DEMO_PACKET_ENTITIES");
|
2012-07-05 10:06:35 +00:00
|
|
|
oldnum = oldp->ent_nums[oldindex];
|
|
|
|
copy_state (newp, oldp, newindex++, oldindex++, oldnum);
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
newnum = word & 511;
|
|
|
|
oldnum = oldindex >= oldp->num_entities ? 9999 :
|
2012-07-05 10:06:35 +00:00
|
|
|
oldp->ent_nums[oldindex];
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
while (newnum > oldnum) {
|
|
|
|
if (full) {
|
|
|
|
Sys_Printf ("WARNING: oldcopy on full update");
|
|
|
|
FlushEntityPacket ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// copy one of the old entities over to the new packet unchanged
|
|
|
|
if (newindex >= MAX_DEMO_PACKET_ENTITIES)
|
|
|
|
Host_Error ("CL_ParsePacketEntities: newindex == "
|
|
|
|
"MAX_DEMO_PACKET_ENTITIES");
|
2012-07-05 10:06:35 +00:00
|
|
|
copy_state (newp, oldp, newindex++, oldindex++, oldnum);
|
2011-06-19 12:34:48 +00:00
|
|
|
oldnum = oldindex >= oldp->num_entities ? 9999 :
|
2012-07-05 10:06:35 +00:00
|
|
|
oldp->ent_nums[oldindex];
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (newnum < oldnum) { // new from baseline
|
|
|
|
if (word & U_REMOVE) {
|
2012-07-05 10:06:35 +00:00
|
|
|
cl_entity_valid[0][newnum] = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
if (full) {
|
|
|
|
cl.validsequence = 0;
|
|
|
|
Sys_Printf ("WARNING: U_REMOVE on full update\n");
|
|
|
|
FlushEntityPacket ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newindex >= MAX_DEMO_PACKET_ENTITIES)
|
|
|
|
Host_Error ("CL_ParsePacketEntities: newindex == "
|
|
|
|
"MAX_DEMO_PACKET_ENTITIES");
|
2012-07-01 02:36:47 +00:00
|
|
|
CL_ParseDelta (&qw_entstates.baseline[newnum],
|
2012-07-05 10:06:35 +00:00
|
|
|
&newp->entities[newnum], word);
|
|
|
|
newp->ent_nums[newindex] = newnum;
|
|
|
|
cl_entity_valid[0][newnum] = 1;
|
2011-06-19 12:34:48 +00:00
|
|
|
newindex++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newnum == oldnum) { // delta from previous
|
|
|
|
if (full) {
|
|
|
|
cl.validsequence = 0;
|
|
|
|
Sys_Printf ("WARNING: delta on full update");
|
|
|
|
}
|
|
|
|
if (word & U_REMOVE) { // Clear the entity
|
2012-07-05 10:06:35 +00:00
|
|
|
cl_entity_valid[0][newnum] = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
oldindex++;
|
|
|
|
continue;
|
|
|
|
}
|
2012-07-05 10:06:35 +00:00
|
|
|
CL_ParseDelta (&oldp->entities[oldnum],
|
|
|
|
&newp->entities[newnum], word);
|
|
|
|
newp->ent_nums[newindex] = newnum;
|
|
|
|
cl_entity_valid[0][newnum] = 1;
|
2011-06-19 12:34:48 +00:00
|
|
|
newindex++;
|
|
|
|
oldindex++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-05 10:06:35 +00:00
|
|
|
cl.num_entities = max (cl.num_entities, newnum);
|
2011-06-19 12:34:48 +00:00
|
|
|
newp->num_entities = newindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
TranslateFlags (int src)
|
|
|
|
{
|
|
|
|
int dst = 0;
|
|
|
|
|
|
|
|
if (src & DF_EFFECTS)
|
|
|
|
dst |= PF_EFFECTS;
|
|
|
|
if (src & DF_SKINNUM)
|
|
|
|
dst |= PF_SKINNUM;
|
|
|
|
if (src & DF_DEAD)
|
|
|
|
dst |= PF_DEAD;
|
|
|
|
if (src & DF_GIB)
|
|
|
|
dst |= PF_GIB;
|
|
|
|
if (src & DF_WEAPONFRAME)
|
|
|
|
dst |= PF_WEAPONFRAME;
|
|
|
|
if (src & DF_MODEL)
|
|
|
|
dst |= PF_MODEL;
|
|
|
|
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
CL_ParseDemoPlayerinfo (int num)
|
|
|
|
{
|
|
|
|
int flags, i;
|
|
|
|
player_info_t *info;
|
|
|
|
player_state_t *state, *prevstate;
|
|
|
|
static player_state_t dummy;
|
|
|
|
|
|
|
|
info = &cl.players[num];
|
|
|
|
state = &cl.frames[parsecountmod].playerstate[num];
|
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.number = num;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (info->prevcount > cl.parsecount || !cl.parsecount) {
|
|
|
|
prevstate = &dummy;
|
|
|
|
} else {
|
|
|
|
if (cl.parsecount - info->prevcount >= UPDATE_BACKUP-1)
|
|
|
|
prevstate = &dummy;
|
|
|
|
else
|
|
|
|
prevstate = &cl.frames[info->prevcount
|
|
|
|
& UPDATE_MASK].playerstate[num];
|
|
|
|
}
|
|
|
|
info->prevcount = cl.parsecount;
|
|
|
|
|
|
|
|
if (cls.findtrack && info->stats[STAT_HEALTH] != 0) {
|
|
|
|
autocam = CAM_TRACK;
|
|
|
|
Cam_Lock (num);
|
|
|
|
ideal_track = num;
|
|
|
|
cls.findtrack = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy (state, prevstate, sizeof (player_state_t));
|
|
|
|
|
|
|
|
flags = MSG_ReadShort (net_message);
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.flags = TranslateFlags (flags);
|
2011-06-19 12:34:48 +00:00
|
|
|
state->messagenum = cl.parsecount;
|
|
|
|
state->pls.cmd.msec = 0;
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.frame = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
state->state_time = parsecounttime;
|
|
|
|
for (i=0; i <3; i++)
|
|
|
|
if (flags & (DF_ORIGIN << i))
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.origin[i] = MSG_ReadCoord (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
for (i=0; i <3; i++)
|
|
|
|
if (flags & (DF_ANGLES << i))
|
|
|
|
state->pls.cmd.angles[i] = MSG_ReadAngle16 (net_message);
|
|
|
|
if (flags & DF_MODEL)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.modelindex = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
if (flags & DF_SKINNUM)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.skinnum = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
if (flags & DF_EFFECTS)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.effects = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
if (flags & DF_WEAPONFRAME)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.weaponframe = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
VectorCopy (state->pls.cmd.angles, state->viewangles);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ParsePlayerinfo (void)
|
|
|
|
{
|
|
|
|
int flags, msec, num, i;
|
|
|
|
player_state_t *state;
|
|
|
|
|
|
|
|
num = MSG_ReadByte (net_message);
|
|
|
|
if (num > MAX_CLIENTS)
|
|
|
|
Host_Error ("CL_ParsePlayerinfo: bad num");
|
|
|
|
|
|
|
|
if (cls.demoplayback2) {
|
|
|
|
CL_ParseDemoPlayerinfo (num);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = &cl.frames[parsecountmod].playerstate[num];
|
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.number = num;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
flags = state->pls.es.flags = MSG_ReadShort (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
state->messagenum = cl.parsecount;
|
2022-03-30 15:07:20 +00:00
|
|
|
MSG_ReadCoordV (net_message, (vec_t*)&state->pls.es.origin);//FIXME
|
2021-03-19 11:18:45 +00:00
|
|
|
state->pls.es.origin[3] = 1;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.frame = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
// the other player's last move was likely some time
|
|
|
|
// before the packet was sent out, so accurately track
|
|
|
|
// the exact time it was valid at
|
|
|
|
if (flags & PF_MSEC) {
|
|
|
|
msec = MSG_ReadByte (net_message);
|
|
|
|
state->state_time = parsecounttime - msec * 0.001;
|
|
|
|
} else
|
|
|
|
state->state_time = parsecounttime;
|
|
|
|
|
|
|
|
if (flags & PF_COMMAND)
|
|
|
|
MSG_ReadDeltaUsercmd (net_message, &nullcmd, &state->pls.cmd);
|
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (flags & (PF_VELOCITY1 << i))
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.velocity[i] = (short) MSG_ReadShort (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
else
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.velocity[i] = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (flags & PF_MODEL)
|
|
|
|
i = MSG_ReadByte (net_message);
|
|
|
|
else
|
|
|
|
i = cl_playerindex;
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.modelindex = i;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (flags & PF_SKINNUM)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.skinnum = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
else
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.skinnum = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (flags & PF_EFFECTS)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.effects = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
else
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.effects = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
if (flags & PF_WEAPONFRAME)
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.weaponframe = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
else
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.weaponframe = 0;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
VectorCopy (state->pls.cmd.angles, state->viewangles);
|
|
|
|
|
|
|
|
if (cl.stdver >= 2.0 && (flags & PF_QF)) {
|
|
|
|
// QSG2
|
|
|
|
int bits;
|
|
|
|
byte val;
|
|
|
|
entity_t *ent;
|
|
|
|
|
2022-03-04 16:48:10 +00:00
|
|
|
ent = CL_GetEntity (num + 1);
|
2011-06-19 12:34:48 +00:00
|
|
|
bits = MSG_ReadByte (net_message);
|
|
|
|
if (bits & PF_ALPHA) {
|
|
|
|
val = MSG_ReadByte (net_message);
|
2021-03-09 14:52:40 +00:00
|
|
|
ent->renderer.colormod[3] = val / 255.0;
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_SCALE) {
|
|
|
|
val = MSG_ReadByte (net_message);
|
2021-03-19 11:18:45 +00:00
|
|
|
state->pls.es.scale = val;
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_EFFECTS2) {
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.effects |= MSG_ReadByte (net_message) << 8;
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_GLOWSIZE) {
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.glow_size = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_GLOWCOLOR) {
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.glow_color = MSG_ReadByte (net_message);
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_COLORMOD) {
|
|
|
|
float r = 1.0, g = 1.0, b = 1.0;
|
|
|
|
val = MSG_ReadByte (net_message);
|
|
|
|
if (val != 255) {
|
|
|
|
r = (float) ((val >> 5) & 7) * (1.0 / 7.0);
|
|
|
|
g = (float) ((val >> 2) & 7) * (1.0 / 7.0);
|
|
|
|
b = (float) (val & 3) * (1.0 / 3.0);
|
|
|
|
}
|
2021-03-09 14:52:40 +00:00
|
|
|
VectorSet (r, g, b, ent->renderer.colormod);
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
if (bits & PF_FRAME2) {
|
2021-03-11 05:27:36 +00:00
|
|
|
state->pls.es.frame |= MSG_ReadByte (net_message) << 8;
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_SetSolid
|
|
|
|
|
|
|
|
Builds all the pmove physents for the current frame
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_SetSolidEntities (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
entity_state_t *state;
|
|
|
|
frame_t *frame;
|
|
|
|
packet_entities_t *pak;
|
|
|
|
|
2022-05-05 05:41:46 +00:00
|
|
|
pmove.physents[0].model = cl_world.scene->worldmodel;
|
2011-06-19 12:34:48 +00:00
|
|
|
VectorZero (pmove.physents[0].origin);
|
2011-09-05 12:05:09 +00:00
|
|
|
VectorZero (pmove.physents[0].angles);
|
2011-06-19 12:34:48 +00:00
|
|
|
pmove.physents[0].info = 0;
|
|
|
|
pmove.numphysent = 1;
|
|
|
|
|
|
|
|
frame = &cl.frames[parsecountmod];
|
|
|
|
pak = &frame->packet_entities;
|
|
|
|
|
|
|
|
for (i = 0; i < pak->num_entities; i++) {
|
|
|
|
state = &pak->entities[i];
|
|
|
|
|
|
|
|
if (!state->modelindex)
|
|
|
|
continue;
|
2022-03-04 16:48:10 +00:00
|
|
|
if (!cl_world.models.a[state->modelindex])
|
2011-06-19 12:34:48 +00:00
|
|
|
continue;
|
2022-03-04 16:48:10 +00:00
|
|
|
if (cl_world.models.a[state->modelindex]->brush.hulls[1].firstclipnode
|
|
|
|
|| cl_world.models.a[state->modelindex]->clipbox) {
|
2011-06-19 12:34:48 +00:00
|
|
|
if (pmove.numphysent == MAX_PHYSENTS) {
|
|
|
|
Sys_Printf ("WARNING: entity physent overflow, email "
|
|
|
|
"quakeforge-devel@lists.quakeforge.net\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pmove.physents[pmove.numphysent].model =
|
2022-03-04 16:48:10 +00:00
|
|
|
cl_world.models.a[state->modelindex];
|
2011-06-19 12:34:48 +00:00
|
|
|
VectorCopy (state->origin,
|
|
|
|
pmove.physents[pmove.numphysent].origin);
|
2011-09-05 12:05:09 +00:00
|
|
|
VectorCopy (state->angles,
|
|
|
|
pmove.physents[pmove.numphysent].angles);
|
2011-06-19 12:34:48 +00:00
|
|
|
pmove.numphysent++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CL_ClearPredict (void)
|
|
|
|
{
|
|
|
|
memset (predicted_players, 0, sizeof (predicted_players));
|
|
|
|
//fixangle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calculate the new position of players, without other player clipping
|
|
|
|
|
|
|
|
We do this to set up real player prediction.
|
|
|
|
Players are predicted twice, first without clipping other players,
|
|
|
|
then with clipping against them.
|
|
|
|
This sets up the first phase.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_SetUpPlayerPrediction (qboolean dopred)
|
|
|
|
{
|
|
|
|
double playertime;
|
|
|
|
frame_t *frame;
|
|
|
|
int msec, j;
|
|
|
|
player_state_t exact;
|
|
|
|
player_state_t *state;
|
|
|
|
struct predicted_player *pplayer;
|
|
|
|
|
|
|
|
playertime = realtime - cls.latency + 0.02;
|
|
|
|
if (playertime > realtime)
|
|
|
|
playertime = realtime;
|
|
|
|
|
|
|
|
frame = &cl.frames[cl.parsecount & UPDATE_MASK];
|
|
|
|
|
|
|
|
for (j = 0, pplayer = predicted_players, state = frame->playerstate;
|
|
|
|
j < MAX_CLIENTS; j++, pplayer++, state++) {
|
|
|
|
|
|
|
|
pplayer->active = false;
|
|
|
|
|
|
|
|
if (state->messagenum != cl.parsecount)
|
|
|
|
continue; // not present this frame
|
|
|
|
|
2021-03-11 05:27:36 +00:00
|
|
|
if (!state->pls.es.modelindex)
|
2011-06-19 12:34:48 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
pplayer->active = true;
|
2021-03-11 05:27:36 +00:00
|
|
|
pplayer->flags = state->pls.es.flags;
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
// note that the local player is special, since he moves locally
|
|
|
|
// we use his last predicted postition
|
|
|
|
if (j == cl.playernum) {
|
|
|
|
VectorCopy (cl.frames[cls.netchan.outgoing_sequence & UPDATE_MASK].
|
2021-03-11 05:27:36 +00:00
|
|
|
playerstate[cl.playernum].pls.es.origin,
|
|
|
|
pplayer->origin);
|
2011-06-19 12:34:48 +00:00
|
|
|
} else {
|
|
|
|
// predict only half the move to minimize overruns
|
|
|
|
msec = 500 * (playertime - state->state_time);
|
|
|
|
if (msec <= 0 || !dopred) {
|
2021-03-11 05:27:36 +00:00
|
|
|
VectorCopy (state->pls.es.origin, pplayer->origin);
|
2021-03-29 10:58:00 +00:00
|
|
|
// Sys_MaskPrintf (SYS_dev, "nopredict\n");
|
2011-06-19 12:34:48 +00:00
|
|
|
} else {
|
|
|
|
// predict players movement
|
|
|
|
state->pls.cmd.msec = msec = min (msec, 255);
|
2021-03-29 10:58:00 +00:00
|
|
|
// Sys_MaskPrintf (SYS_dev, "predict: %i\n", msec);
|
2011-06-19 12:34:48 +00:00
|
|
|
|
|
|
|
CL_PredictUsercmd (state, &exact, &state->pls.cmd, false);
|
2021-03-11 05:27:36 +00:00
|
|
|
VectorCopy (exact.pls.es.origin, pplayer->origin);
|
2011-06-19 12:34:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_SetSolid
|
|
|
|
|
|
|
|
Builds all the pmove physents for the current frame
|
|
|
|
Note that CL_SetUpPlayerPrediction () must be called first!
|
|
|
|
pmove must be setup with world and solid entity hulls before calling
|
|
|
|
(via CL_PredictMove)
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
CL_SetSolidPlayers (int playernum)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
physent_t *pent;
|
|
|
|
struct predicted_player *pplayer;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!cl_solid_players)
|
2011-06-19 12:34:48 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
pent = pmove.physents + pmove.numphysent;
|
|
|
|
|
|
|
|
for (j = 0, pplayer = predicted_players; j < MAX_CLIENTS; j++, pplayer++) {
|
|
|
|
if (!pplayer->active)
|
|
|
|
continue; // not present this frame
|
|
|
|
|
|
|
|
// the player object never gets added
|
|
|
|
if (j == playernum)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (pplayer->flags & PF_DEAD)
|
|
|
|
continue; // dead players aren't solid
|
|
|
|
|
|
|
|
if (pmove.numphysent == MAX_PHYSENTS) {
|
|
|
|
Sys_Printf ("WARNING: player physent overflow, email "
|
|
|
|
"quakeforge-devel@lists.quakeforge.net\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pent->model = 0;
|
|
|
|
VectorCopy (pplayer->origin, pent->origin);
|
|
|
|
VectorCopy (player_mins, pent->mins);
|
|
|
|
VectorCopy (player_maxs, pent->maxs);
|
|
|
|
pmove.numphysent++;
|
|
|
|
pent++;
|
|
|
|
}
|
|
|
|
}
|