2009-02-28 14:41:18 +00:00
|
|
|
/*
|
2010-06-18 13:58:31 +00:00
|
|
|
* Copyright (C) 1997-2001 Id Software, Inc.
|
|
|
|
*
|
2010-07-13 18:19:42 +00:00
|
|
|
* 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.
|
2010-06-18 13:58:31 +00:00
|
|
|
*
|
2010-07-13 18:19:42 +00:00
|
|
|
* 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.
|
2010-06-18 13:58:31 +00:00
|
|
|
*
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
2010-07-13 18:19:42 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
2012-04-29 13:57:33 +00:00
|
|
|
*
|
2010-06-18 16:34:07 +00:00
|
|
|
* =======================================================================
|
2010-06-18 13:58:31 +00:00
|
|
|
*
|
2010-06-18 16:34:07 +00:00
|
|
|
* This file implements the entity and network protocol parsing
|
|
|
|
*
|
|
|
|
* =======================================================================
|
2010-06-18 13:58:31 +00:00
|
|
|
*/
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2009-03-03 13:43:32 +00:00
|
|
|
#include "header/client.h"
|
2018-08-07 07:43:34 +00:00
|
|
|
#include "input/header/input.h"
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 16:34:07 +00:00
|
|
|
void CL_DownloadFileName(char *dest, int destlen, char *fn);
|
2012-07-22 13:34:45 +00:00
|
|
|
void CL_ParseDownload(void);
|
2010-06-18 16:34:07 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
int bitcounts[32]; /* just for protocol profiling */
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
char *svc_strings[256] = {
|
2009-02-28 14:41:18 +00:00
|
|
|
"svc_bad",
|
|
|
|
|
|
|
|
"svc_muzzleflash",
|
|
|
|
"svc_muzzlflash2",
|
|
|
|
"svc_temp_entity",
|
|
|
|
"svc_layout",
|
|
|
|
"svc_inventory",
|
|
|
|
|
|
|
|
"svc_nop",
|
|
|
|
"svc_disconnect",
|
|
|
|
"svc_reconnect",
|
|
|
|
"svc_sound",
|
|
|
|
"svc_print",
|
|
|
|
"svc_stufftext",
|
|
|
|
"svc_serverdata",
|
|
|
|
"svc_configstring",
|
2010-06-18 13:58:31 +00:00
|
|
|
"svc_spawnbaseline",
|
2009-02-28 14:41:18 +00:00
|
|
|
"svc_centerprint",
|
|
|
|
"svc_download",
|
|
|
|
"svc_playerinfo",
|
|
|
|
"svc_packetentities",
|
|
|
|
"svc_deltapacketentities",
|
|
|
|
"svc_frame"
|
|
|
|
};
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_RegisterSounds(void)
|
|
|
|
{
|
|
|
|
int i;
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
S_BeginRegistration();
|
|
|
|
CL_RegisterTEntSounds();
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
for (i = 1; i < MAX_SOUNDS; i++)
|
|
|
|
{
|
|
|
|
if (!cl.configstrings[CS_SOUNDS + i][0])
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
break;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
cl.sound_precache[i] = S_RegisterSound(cl.configstrings[CS_SOUNDS + i]);
|
2018-02-04 15:45:32 +00:00
|
|
|
IN_Update();
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
S_EndRegistration();
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 19:47:24 +00:00
|
|
|
/*
|
|
|
|
* Returns the entity number and the header bits
|
|
|
|
*/
|
2012-07-22 13:34:45 +00:00
|
|
|
int
|
|
|
|
CL_ParseEntityBits(unsigned *bits)
|
|
|
|
{
|
|
|
|
unsigned b, total;
|
|
|
|
int i;
|
|
|
|
int number;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
total = MSG_ReadByte(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (total & U_MOREBITS1)
|
|
|
|
{
|
|
|
|
b = MSG_ReadByte(&net_message);
|
|
|
|
total |= b << 8;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (total & U_MOREBITS2)
|
|
|
|
{
|
|
|
|
b = MSG_ReadByte(&net_message);
|
|
|
|
total |= b << 16;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (total & U_MOREBITS3)
|
|
|
|
{
|
|
|
|
b = MSG_ReadByte(&net_message);
|
|
|
|
total |= b << 24;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* count the bits for net profiling */
|
2012-07-22 13:34:45 +00:00
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
{
|
2022-02-21 08:39:08 +00:00
|
|
|
if (total & (1u << i))
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
bitcounts[i]++;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (total & U_NUMBER16)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
number = MSG_ReadShort(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
number = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
*bits = total;
|
|
|
|
|
|
|
|
return number;
|
|
|
|
}
|
|
|
|
|
2010-06-18 19:47:24 +00:00
|
|
|
/*
|
|
|
|
* Can go from either a baseline or a previous packet_entity
|
|
|
|
*/
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseDelta(entity_state_t *from, entity_state_t *to, int number, int bits)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* set everything to the state we are delta'ing from */
|
|
|
|
*to = *from;
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
VectorCopy(from->origin, to->old_origin);
|
2010-06-18 15:12:58 +00:00
|
|
|
to->number = number;
|
|
|
|
|
|
|
|
if (bits & U_MODEL)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->modelindex = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_MODEL2)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->modelindex2 = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_MODEL3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->modelindex3 = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_MODEL4)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->modelindex4 = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_FRAME8)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->frame = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_FRAME16)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->frame = MSG_ReadShort(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* used for laser colors */
|
|
|
|
if ((bits & U_SKIN8) && (bits & U_SKIN16))
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->skinnum = MSG_ReadLong(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_SKIN8)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->skinnum = MSG_ReadByte(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_SKIN16)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->skinnum = MSG_ReadShort(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((bits & (U_EFFECTS8 | U_EFFECTS16)) == (U_EFFECTS8 | U_EFFECTS16))
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->effects = MSG_ReadLong(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_EFFECTS8)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->effects = MSG_ReadByte(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_EFFECTS16)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->effects = MSG_ReadShort(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((bits & (U_RENDERFX8 | U_RENDERFX16)) == (U_RENDERFX8 | U_RENDERFX16))
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->renderfx = MSG_ReadLong(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_RENDERFX8)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->renderfx = MSG_ReadByte(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else if (bits & U_RENDERFX16)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->renderfx = MSG_ReadShort(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ORIGIN1)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->origin[0] = MSG_ReadCoord(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ORIGIN2)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->origin[1] = MSG_ReadCoord(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ORIGIN3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->origin[2] = MSG_ReadCoord(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ANGLE1)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->angles[0] = MSG_ReadAngle(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ANGLE2)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->angles[1] = MSG_ReadAngle(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_ANGLE3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->angles[2] = MSG_ReadAngle(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_OLDORIGIN)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
MSG_ReadPos(&net_message, to->old_origin);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_SOUND)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->sound = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_EVENT)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->event = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
to->event = 0;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (bits & U_SOLID)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
to->solid = MSG_ReadShort(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parses deltas from the given base and adds the resulting entity to
|
|
|
|
* the current frame
|
|
|
|
*/
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_DeltaEntity(frame_t *frame, int newnum, entity_state_t *old, int bits)
|
|
|
|
{
|
|
|
|
centity_t *ent;
|
|
|
|
entity_state_t *state;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
ent = &cl_entities[newnum];
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
state = &cl_parse_entities[cl.parse_entities & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
cl.parse_entities++;
|
|
|
|
frame->num_entities++;
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseDelta(old, state, newnum, bits);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* some data changes will force no lerping */
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((state->modelindex != ent->current.modelindex) ||
|
|
|
|
(state->modelindex2 != ent->current.modelindex2) ||
|
|
|
|
(state->modelindex3 != ent->current.modelindex3) ||
|
|
|
|
(state->modelindex4 != ent->current.modelindex4) ||
|
|
|
|
(state->event == EV_PLAYER_TELEPORT) ||
|
|
|
|
(state->event == EV_OTHER_TELEPORT) ||
|
|
|
|
(abs((int)(state->origin[0] - ent->current.origin[0])) > 512) ||
|
|
|
|
(abs((int)(state->origin[1] - ent->current.origin[1])) > 512) ||
|
|
|
|
(abs((int)(state->origin[2] - ent->current.origin[2])) > 512)
|
|
|
|
)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
ent->serverframe = -99;
|
|
|
|
}
|
2012-07-22 13:34:45 +00:00
|
|
|
|
2010-06-18 15:12:58 +00:00
|
|
|
/* wasn't in last update, so initialize some things */
|
2012-07-22 13:34:45 +00:00
|
|
|
if (ent->serverframe != cl.frame.serverframe - 1)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
ent->trailcount = 1024; /* for diminishing rocket / grenade trails */
|
2012-04-29 13:57:33 +00:00
|
|
|
|
|
|
|
/* duplicate the current state so
|
2012-07-22 13:34:45 +00:00
|
|
|
lerping doesn't hurt anything */
|
2010-06-18 15:12:58 +00:00
|
|
|
ent->prev = *state;
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (state->event == EV_OTHER_TELEPORT)
|
|
|
|
{
|
|
|
|
VectorCopy(state->origin, ent->prev.origin);
|
|
|
|
VectorCopy(state->origin, ent->lerp_origin);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
VectorCopy(state->old_origin, ent->prev.origin);
|
|
|
|
VectorCopy(state->old_origin, ent->lerp_origin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* shuffle the last state to previous */
|
|
|
|
ent->prev = ent->current;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->serverframe = cl.frame.serverframe;
|
|
|
|
ent->current = *state;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-07-22 13:34:45 +00:00
|
|
|
* An svc_packetentities has just been
|
|
|
|
* parsed, deal with the rest of the
|
2010-06-18 15:12:58 +00:00
|
|
|
* data stream.
|
|
|
|
*/
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParsePacketEntities(frame_t *oldframe, frame_t *newframe)
|
|
|
|
{
|
|
|
|
unsigned int newnum;
|
|
|
|
unsigned bits;
|
2010-06-18 15:12:58 +00:00
|
|
|
entity_state_t
|
|
|
|
*oldstate = NULL;
|
2012-07-22 13:34:45 +00:00
|
|
|
int oldindex, oldnum;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
newframe->parse_entities = cl.parse_entities;
|
|
|
|
newframe->num_entities = 0;
|
|
|
|
|
|
|
|
/* delta from the entities present in oldframe */
|
|
|
|
oldindex = 0;
|
|
|
|
|
|
|
|
if (!oldframe)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
if (oldindex >= oldframe->num_entities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = &cl_parse_entities[(oldframe->parse_entities +
|
|
|
|
oldindex) & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = oldstate->number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
newnum = CL_ParseEntityBits(&bits);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (newnum >= MAX_EDICTS)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParsePacketEntities: bad number:%i", newnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (net_message.readcount > net_message.cursize)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParsePacketEntities: end of message");
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (!newnum)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
break;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
while (oldnum < newnum)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* one or more entities from the old packet are unchanged */
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" unchanged: %i\n", oldnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_DeltaEntity(newframe, oldnum, oldstate, 0);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
oldindex++;
|
|
|
|
|
|
|
|
if (oldindex >= oldframe->num_entities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = &cl_parse_entities[(oldframe->parse_entities +
|
|
|
|
oldindex) & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = oldstate->number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (bits & U_REMOVE)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* the entity present in oldframe is not in the current frame */
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" remove: %i\n", newnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (oldnum != newnum)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf("U_REMOVE: oldnum != newnum\n");
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
oldindex++;
|
|
|
|
|
|
|
|
if (oldindex >= oldframe->num_entities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = &cl_parse_entities[(oldframe->parse_entities +
|
|
|
|
oldindex) & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = oldstate->number;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (oldnum == newnum)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* delta from previous state */
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" delta: %i\n", newnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_DeltaEntity(newframe, newnum, oldstate, bits);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
oldindex++;
|
|
|
|
|
|
|
|
if (oldindex >= oldframe->num_entities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = &cl_parse_entities[(oldframe->parse_entities +
|
|
|
|
oldindex) & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = oldstate->number;
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (oldnum > newnum)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* delta from baseline */
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" baseline: %i\n", newnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_DeltaEntity(newframe, newnum,
|
|
|
|
&cl_entities[newnum].baseline,
|
|
|
|
bits);
|
2010-06-18 15:12:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* any remaining entities in the old frame are copied over */
|
2012-07-22 13:34:45 +00:00
|
|
|
while (oldnum != 99999)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* one or more entities from the old packet are unchanged */
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" unchanged: %i\n", oldnum);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_DeltaEntity(newframe, oldnum, oldstate, 0);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
oldindex++;
|
|
|
|
|
|
|
|
if (oldindex >= oldframe->num_entities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = 99999;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
oldstate = &cl_parse_entities[(oldframe->parse_entities +
|
|
|
|
oldindex) & (MAX_PARSE_ENTITIES - 1)];
|
2010-06-18 15:12:58 +00:00
|
|
|
oldnum = oldstate->number;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParsePlayerstate(frame_t *oldframe, frame_t *newframe)
|
|
|
|
{
|
|
|
|
int flags;
|
|
|
|
player_state_t *state;
|
|
|
|
int i;
|
|
|
|
int statbits;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
state = &newframe->playerstate;
|
|
|
|
|
|
|
|
/* clear to old value before delta parsing */
|
|
|
|
if (oldframe)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
*state = oldframe->playerstate;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
memset(state, 0, sizeof(*state));
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
flags = MSG_ReadShort(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* parse the pmove_state_t */
|
|
|
|
if (flags & PS_M_TYPE)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->pmove.pm_type = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_M_ORIGIN)
|
|
|
|
{
|
|
|
|
state->pmove.origin[0] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.origin[1] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.origin[2] = MSG_ReadShort(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_M_VELOCITY)
|
|
|
|
{
|
|
|
|
state->pmove.velocity[0] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.velocity[1] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.velocity[2] = MSG_ReadShort(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & PS_M_TIME)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->pmove.pm_time = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (flags & PS_M_FLAGS)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->pmove.pm_flags = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (flags & PS_M_GRAVITY)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->pmove.gravity = MSG_ReadShort(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_M_DELTA_ANGLES)
|
|
|
|
{
|
|
|
|
state->pmove.delta_angles[0] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.delta_angles[1] = MSG_ReadShort(&net_message);
|
|
|
|
state->pmove.delta_angles[2] = MSG_ReadShort(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cl.attractloop)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
state->pmove.pm_type = PM_FREEZE; /* demo playback */
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* parse the rest of the player_state_t */
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_VIEWOFFSET)
|
|
|
|
{
|
|
|
|
state->viewoffset[0] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->viewoffset[1] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->viewoffset[2] = MSG_ReadChar(&net_message) * 0.25f;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_VIEWANGLES)
|
|
|
|
{
|
|
|
|
state->viewangles[0] = MSG_ReadAngle16(&net_message);
|
|
|
|
state->viewangles[1] = MSG_ReadAngle16(&net_message);
|
|
|
|
state->viewangles[2] = MSG_ReadAngle16(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_KICKANGLES)
|
|
|
|
{
|
|
|
|
state->kick_angles[0] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->kick_angles[1] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->kick_angles[2] = MSG_ReadChar(&net_message) * 0.25f;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_WEAPONINDEX)
|
|
|
|
{
|
|
|
|
state->gunindex = MSG_ReadByte(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_WEAPONFRAME)
|
|
|
|
{
|
|
|
|
state->gunframe = MSG_ReadByte(&net_message);
|
|
|
|
state->gunoffset[0] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->gunoffset[1] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->gunoffset[2] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->gunangles[0] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->gunangles[1] = MSG_ReadChar(&net_message) * 0.25f;
|
|
|
|
state->gunangles[2] = MSG_ReadChar(&net_message) * 0.25f;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & PS_BLEND)
|
|
|
|
{
|
|
|
|
state->blend[0] = MSG_ReadByte(&net_message) / 255.0f;
|
|
|
|
state->blend[1] = MSG_ReadByte(&net_message) / 255.0f;
|
|
|
|
state->blend[2] = MSG_ReadByte(&net_message) / 255.0f;
|
|
|
|
state->blend[3] = MSG_ReadByte(&net_message) / 255.0f;
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & PS_FOV)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->fov = (float)MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (flags & PS_RDFLAGS)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
state->rdflags = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* parse stats */
|
2012-07-22 13:34:45 +00:00
|
|
|
statbits = MSG_ReadLong(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
for (i = 0; i < MAX_STATS; i++)
|
|
|
|
{
|
2022-02-21 08:39:08 +00:00
|
|
|
if (statbits & (1u << i))
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
state->stats[i] = MSG_ReadShort(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_FireEntityEvents(frame_t *frame)
|
|
|
|
{
|
|
|
|
entity_state_t *s1;
|
|
|
|
int pnum, num;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
for (pnum = 0; pnum < frame->num_entities; pnum++)
|
|
|
|
{
|
|
|
|
num = (frame->parse_entities + pnum) & (MAX_PARSE_ENTITIES - 1);
|
2010-06-18 15:12:58 +00:00
|
|
|
s1 = &cl_parse_entities[num];
|
|
|
|
|
|
|
|
if (s1->event)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
CL_EntityEvent(s1);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (s1->effects & EF_TELEPORTER)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
CL_TeleporterParticles(s1);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseFrame(void)
|
|
|
|
{
|
|
|
|
int cmd;
|
|
|
|
int len;
|
|
|
|
frame_t *old;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
memset(&cl.frame, 0, sizeof(cl.frame));
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
cl.frame.serverframe = MSG_ReadLong(&net_message);
|
|
|
|
cl.frame.deltaframe = MSG_ReadLong(&net_message);
|
|
|
|
cl.frame.servertime = cl.frame.serverframe * 100;
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* BIG HACK to let old demos continue to work */
|
|
|
|
if (cls.serverProtocol != 26)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
cl.surpressCount = MSG_ReadByte(&net_message);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
if (cl_shownet->value == 3)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf(" frame:%i delta:%i\n", cl.frame.serverframe,
|
|
|
|
cl.frame.deltaframe);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the frame is delta compressed from data that we
|
|
|
|
no longer have available, we must suck up the rest of
|
|
|
|
the frame, but not use it, then ask for a non-compressed
|
|
|
|
message */
|
|
|
|
if (cl.frame.deltaframe <= 0)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
cl.frame.valid = true; /* uncompressed frame */
|
|
|
|
old = NULL;
|
|
|
|
cls.demowaiting = false; /* we can start recording now */
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
old = &cl.frames[cl.frame.deltaframe & UPDATE_MASK];
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (!old->valid)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* should never happen */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Printf("Delta from invalid frame (not supposed to happen!).\n");
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (old->serverframe != cl.frame.deltaframe)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* The frame that the server did the delta from
|
2012-07-22 13:34:45 +00:00
|
|
|
is too old, so we can't reconstruct it properly. */
|
|
|
|
Com_Printf("Delta frame too old.\n");
|
|
|
|
}
|
|
|
|
else if (cl.parse_entities - old->parse_entities > MAX_PARSE_ENTITIES -
|
|
|
|
128)
|
|
|
|
{
|
|
|
|
Com_Printf("Delta parse_entities too old.\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
cl.frame.valid = true; /* valid delta parse */
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clamp time */
|
|
|
|
if (cl.time > cl.frame.servertime)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
cl.time = cl.frame.servertime;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
else if (cl.time < cl.frame.servertime - 100)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
cl.time = cl.frame.servertime - 100;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* read areabits */
|
2012-07-22 13:34:45 +00:00
|
|
|
len = MSG_ReadByte(&net_message);
|
|
|
|
MSG_ReadData(&net_message, &cl.frame.areabits, len);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* read playerinfo */
|
2012-07-22 13:34:45 +00:00
|
|
|
cmd = MSG_ReadByte(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
SHOWNET(svc_strings[cmd]);
|
|
|
|
|
|
|
|
if (cmd != svc_playerinfo)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParseFrame: 0x%X not playerinfo", cmd);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParsePlayerstate(old, &cl.frame);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* read packet entities */
|
2012-07-22 13:34:45 +00:00
|
|
|
cmd = MSG_ReadByte(&net_message);
|
2010-06-18 15:12:58 +00:00
|
|
|
SHOWNET(svc_strings[cmd]);
|
|
|
|
|
|
|
|
if (cmd != svc_packetentities)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParseFrame: 0x%X not packetentities", cmd);
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParsePacketEntities(old, &cl.frame);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
/* save the frame off in the backup array for later delta comparisons */
|
|
|
|
cl.frames[cl.frame.serverframe & UPDATE_MASK] = cl.frame;
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cl.frame.valid)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
/* getting a valid frame message ends the connection process */
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cls.state != ca_active)
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
cls.state = ca_active;
|
|
|
|
cl.force_refdef = true;
|
2012-07-22 13:34:45 +00:00
|
|
|
cl.predicted_origin[0] = cl.frame.playerstate.pmove.origin[0] * 0.125f;
|
|
|
|
cl.predicted_origin[1] = cl.frame.playerstate.pmove.origin[1] * 0.125f;
|
|
|
|
cl.predicted_origin[2] = cl.frame.playerstate.pmove.origin[2] * 0.125f;
|
|
|
|
VectorCopy(cl.frame.playerstate.viewangles, cl.predicted_angles);
|
|
|
|
|
|
|
|
if ((cls.disable_servercount != cl.servercount) && cl.refresh_prepped)
|
|
|
|
{
|
|
|
|
SCR_EndLoadingPlaque(); /* get rid of loading plaque */
|
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
|
|
|
cl.sound_prepped = true;
|
2019-09-03 06:34:57 +00:00
|
|
|
|
|
|
|
if (paused_at_load)
|
|
|
|
{
|
|
|
|
if (cl_loadpaused->value == 1)
|
|
|
|
{
|
|
|
|
Cvar_Set("paused", "0");
|
|
|
|
}
|
2019-09-03 06:45:59 +00:00
|
|
|
|
|
|
|
paused_at_load = false;
|
2019-09-03 06:34:57 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* fire entity events */
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_FireEntityEvents(&cl.frame);
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (!(!cl_predict->value ||
|
2013-05-01 19:12:38 +00:00
|
|
|
(cl.frame.playerstate.pmove.pm_flags &
|
2012-07-22 13:34:45 +00:00
|
|
|
PMF_NO_PREDICTION)))
|
|
|
|
{
|
2010-06-18 15:12:58 +00:00
|
|
|
CL_CheckPredictionError();
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
}
|
2012-04-29 13:57:33 +00:00
|
|
|
}
|
2010-06-18 15:12:58 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseServerData(void)
|
|
|
|
{
|
|
|
|
extern cvar_t *fs_gamedirvar;
|
|
|
|
char *str;
|
|
|
|
int i;
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2020-12-11 18:46:49 +00:00
|
|
|
/* Clear all key states */
|
|
|
|
In_FlushQueue();
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_DPrintf("Serverdata packet received.\n");
|
2010-06-18 13:58:31 +00:00
|
|
|
|
|
|
|
/* wipe the client_state_t struct */
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ClearState();
|
2009-02-28 14:41:18 +00:00
|
|
|
cls.state = ca_connected;
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* parse protocol version number */
|
2012-07-22 13:34:45 +00:00
|
|
|
i = MSG_ReadLong(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
cls.serverProtocol = i;
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* another demo hack */
|
2012-07-22 13:34:45 +00:00
|
|
|
if (Com_ServerState() && (PROTOCOL_VERSION == 34))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else if (i != PROTOCOL_VERSION)
|
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "Server returned version %i, not %i",
|
|
|
|
i, PROTOCOL_VERSION);
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
cl.servercount = MSG_ReadLong(&net_message);
|
|
|
|
cl.attractloop = MSG_ReadByte(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* game directory */
|
2012-07-22 13:34:45 +00:00
|
|
|
str = MSG_ReadString(&net_message);
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(cl.gamedir, str, sizeof(cl.gamedir));
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* set gamedir */
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((*str && (!fs_gamedirvar->string || !*fs_gamedirvar->string ||
|
|
|
|
strcmp(fs_gamedirvar->string, str))) ||
|
2019-07-21 01:02:22 +00:00
|
|
|
(!*str && (fs_gamedirvar->string && !*fs_gamedirvar->string)))
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
Cvar_Set("game", str);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* parse player entity number */
|
2012-07-22 13:34:45 +00:00
|
|
|
cl.playernum = MSG_ReadShort(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* get the full level name */
|
2012-07-22 13:34:45 +00:00
|
|
|
str = MSG_ReadString(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cl.playernum == -1)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* playing a cinematic or showing a pic, not a level */
|
2012-07-22 13:34:45 +00:00
|
|
|
SCR_PlayCinematic(str);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* seperate the printfs so the server
|
2012-07-22 13:34:45 +00:00
|
|
|
* message can have a color */
|
2009-02-28 14:41:18 +00:00
|
|
|
Com_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n");
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Printf("%c%s\n", 2, str);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* need to prep refresh at next oportunity */
|
2009-02-28 14:41:18 +00:00
|
|
|
cl.refresh_prepped = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseBaseline(void)
|
|
|
|
{
|
|
|
|
entity_state_t *es;
|
|
|
|
unsigned bits;
|
|
|
|
int newnum;
|
|
|
|
entity_state_t nullstate;
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
memset(&nullstate, 0, sizeof(nullstate));
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
newnum = CL_ParseEntityBits(&bits);
|
2009-02-28 14:41:18 +00:00
|
|
|
es = &cl_entities[newnum].baseline;
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseDelta(&nullstate, es, newnum, bits);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_LoadClientinfo(clientinfo_t *ci, char *s)
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
int i;
|
2012-07-22 13:34:45 +00:00
|
|
|
char *t;
|
|
|
|
char model_name[MAX_QPATH];
|
|
|
|
char skin_name[MAX_QPATH];
|
|
|
|
char model_filename[MAX_QPATH];
|
|
|
|
char skin_filename[MAX_QPATH];
|
|
|
|
char weapon_filename[MAX_QPATH];
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(ci->cinfo, s, sizeof(ci->cinfo));
|
2015-08-24 15:58:19 +00:00
|
|
|
s = ci->cinfo;
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* isolate the player's name */
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(ci->name, s, sizeof(ci->name));
|
2012-07-22 13:34:45 +00:00
|
|
|
t = strstr(s, "\\");
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (t)
|
|
|
|
{
|
|
|
|
ci->name[t - s] = 0;
|
|
|
|
s = t + 1;
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cl_noskins->value || (*s == 0))
|
|
|
|
{
|
|
|
|
strcpy(model_filename, "players/male/tris.md2");
|
|
|
|
strcpy(weapon_filename, "players/male/weapon.md2");
|
|
|
|
strcpy(skin_filename, "players/male/grunt.pcx");
|
|
|
|
strcpy(ci->iconname, "/players/male/grunt_i.pcx");
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->model = R_RegisterModel(model_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
memset(ci->weaponmodel, 0, sizeof(ci->weaponmodel));
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->weaponmodel[0] = R_RegisterModel(weapon_filename);
|
|
|
|
ci->skin = R_RegisterSkin(skin_filename);
|
|
|
|
ci->icon = Draw_FindPic(ci->iconname);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* isolate the model name */
|
2012-07-22 13:34:45 +00:00
|
|
|
strcpy(model_name, s);
|
2009-02-28 14:41:18 +00:00
|
|
|
t = strstr(model_name, "/");
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
if (!t)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
t = strstr(model_name, "\\");
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
if (!t)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
t = model_name;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
*t = 0;
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* isolate the skin name */
|
2012-07-22 13:34:45 +00:00
|
|
|
strcpy(skin_name, s + strlen(model_name) + 1);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* model file */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(model_filename, sizeof(model_filename),
|
|
|
|
"players/%s/tris.md2", model_name);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->model = R_RegisterModel(model_filename);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (!ci->model)
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
strcpy(model_name, "male");
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(model_filename, sizeof(model_filename),
|
|
|
|
"players/male/tris.md2");
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->model = R_RegisterModel(model_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* skin file */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(skin_filename, sizeof(skin_filename),
|
|
|
|
"players/%s/%s.pcx", model_name, skin_name);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->skin = R_RegisterSkin(skin_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* if we don't have the skin and the model wasn't male,
|
2012-07-22 13:34:45 +00:00
|
|
|
* see if the male has it (this is for CTF's skins) */
|
|
|
|
if (!ci->skin && Q_stricmp(model_name, "male"))
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* change model to male */
|
2009-02-28 14:41:18 +00:00
|
|
|
strcpy(model_name, "male");
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(model_filename, sizeof(model_filename),
|
|
|
|
"players/male/tris.md2");
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->model = R_RegisterModel(model_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* see if the skin exists for the male model */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(skin_filename, sizeof(skin_filename),
|
|
|
|
"players/%s/%s.pcx", model_name, skin_name);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->skin = R_RegisterSkin(skin_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* if we still don't have a skin, it means that the male model didn't have
|
2012-07-22 13:34:45 +00:00
|
|
|
* it, so default to grunt */
|
|
|
|
if (!ci->skin)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* see if the skin exists for the male model */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(skin_filename, sizeof(skin_filename),
|
2015-08-24 15:52:57 +00:00
|
|
|
"players/%s/grunt.pcx", model_name);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->skin = R_RegisterSkin(skin_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* weapon file */
|
2012-07-22 13:34:45 +00:00
|
|
|
for (i = 0; i < num_cl_weaponmodels; i++)
|
|
|
|
{
|
|
|
|
Com_sprintf(weapon_filename, sizeof(weapon_filename),
|
|
|
|
"players/%s/%s", model_name, cl_weaponmodels[i]);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->weaponmodel[i] = R_RegisterModel(weapon_filename);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (!ci->weaponmodel[i] && (strcmp(model_name, "cyborg") == 0))
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* try male */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(weapon_filename, sizeof(weapon_filename),
|
|
|
|
"players/male/%s", cl_weaponmodels[i]);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->weaponmodel[i] = R_RegisterModel(weapon_filename);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
if (!cl_vwep->value)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
break; /* only one when vwep is off */
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* icon file */
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_sprintf(ci->iconname, sizeof(ci->iconname),
|
|
|
|
"/players/%s/%s_i.pcx", model_name, skin_name);
|
2013-05-01 19:12:38 +00:00
|
|
|
ci->icon = Draw_FindPic(ci->iconname);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* must have loaded all data types to be valid */
|
2012-07-22 13:34:45 +00:00
|
|
|
if (!ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0])
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
ci->skin = NULL;
|
|
|
|
ci->icon = NULL;
|
|
|
|
ci->model = NULL;
|
|
|
|
ci->weaponmodel[0] = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-06-18 13:58:31 +00:00
|
|
|
* Load the skin, icon, and model for a client
|
|
|
|
*/
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseClientinfo(int player)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
clientinfo_t *ci;
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
s = cl.configstrings[player + CS_PLAYERSKINS];
|
2009-02-28 14:41:18 +00:00
|
|
|
|
|
|
|
ci = &cl.clientinfo[player];
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_LoadClientinfo(ci, s);
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseConfigString(void)
|
|
|
|
{
|
2015-08-24 15:58:19 +00:00
|
|
|
int i, length;
|
2012-07-22 13:34:45 +00:00
|
|
|
char *s;
|
|
|
|
char olds[MAX_QPATH];
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
i = MSG_ReadShort(&net_message);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((i < 0) || (i >= MAX_CONFIGSTRINGS))
|
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "configstring > MAX_CONFIGSTRINGS");
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
s = MSG_ReadString(&net_message);
|
|
|
|
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(olds, cl.configstrings[i], sizeof(olds));
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2015-08-24 15:58:19 +00:00
|
|
|
length = strlen(s);
|
|
|
|
if (length > sizeof(cl.configstrings) - sizeof(cl.configstrings[0])*i - 1)
|
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParseConfigString: oversize configstring");
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
strcpy(cl.configstrings[i], s);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* do something apropriate */
|
2012-07-22 13:34:45 +00:00
|
|
|
if ((i >= CS_LIGHTS) && (i < CS_LIGHTS + MAX_LIGHTSTYLES))
|
|
|
|
{
|
|
|
|
CL_SetLightstyle(i - CS_LIGHTS);
|
|
|
|
}
|
|
|
|
else if (i == CS_CDTRACK)
|
|
|
|
{
|
|
|
|
if (cl.refresh_prepped)
|
|
|
|
{
|
2023-03-26 03:43:28 +00:00
|
|
|
int track = (int)strtol(cl.configstrings[CS_CDTRACK], (char **)NULL, 10);
|
2023-04-16 09:20:52 +00:00
|
|
|
|
2023-03-26 03:43:28 +00:00
|
|
|
OGG_PlayTrack(track, true, true);
|
2009-10-03 16:06:45 +00:00
|
|
|
}
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else if ((i >= CS_MODELS) && (i < CS_MODELS + MAX_MODELS))
|
|
|
|
{
|
|
|
|
if (cl.refresh_prepped)
|
|
|
|
{
|
2013-05-01 19:12:38 +00:00
|
|
|
cl.model_draw[i - CS_MODELS] = R_RegisterModel(cl.configstrings[i]);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cl.configstrings[i][0] == '*')
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
cl.model_clip[i - CS_MODELS] = CM_InlineModel(cl.configstrings[i]);
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
cl.model_clip[i - CS_MODELS] = NULL;
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else if ((i >= CS_SOUNDS) && (i < CS_SOUNDS + MAX_MODELS))
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cl.refresh_prepped)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2013-05-01 19:12:38 +00:00
|
|
|
cl.sound_precache[i - CS_SOUNDS] =
|
2012-07-22 13:34:45 +00:00
|
|
|
S_RegisterSound(cl.configstrings[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((i >= CS_IMAGES) && (i < CS_IMAGES + MAX_MODELS))
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cl.refresh_prepped)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2013-05-01 19:12:38 +00:00
|
|
|
cl.image_precache[i - CS_IMAGES] = Draw_FindPic(cl.configstrings[i]);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((i >= CS_PLAYERSKINS) && (i < CS_PLAYERSKINS + MAX_CLIENTS))
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cl.refresh_prepped && strcmp(olds, s))
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
CL_ParseClientinfo(i - CS_PLAYERSKINS);
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseStartSoundPacket(void)
|
|
|
|
{
|
|
|
|
vec3_t pos_v;
|
|
|
|
float *pos;
|
|
|
|
int channel, ent;
|
|
|
|
int sound_num;
|
|
|
|
float volume;
|
|
|
|
float attenuation;
|
|
|
|
int flags;
|
|
|
|
float ofs;
|
|
|
|
|
|
|
|
flags = MSG_ReadByte(&net_message);
|
|
|
|
sound_num = MSG_ReadByte(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
if (flags & SND_VOLUME)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
volume = MSG_ReadByte(&net_message) / 255.0f;
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
volume = DEFAULT_SOUND_PACKET_VOLUME;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
|
|
|
if (flags & SND_ATTENUATION)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
attenuation = MSG_ReadByte(&net_message) / 64.0f;
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
if (flags & SND_OFFSET)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
ofs = MSG_ReadByte(&net_message) / 1000.0f;
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
ofs = 0;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & SND_ENT)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* entity reletive */
|
|
|
|
channel = MSG_ReadShort(&net_message);
|
2012-07-22 13:34:45 +00:00
|
|
|
ent = channel >> 3;
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
if (ent > MAX_EDICTS)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParseStartSoundPacket: ent = %i", ent);
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
|
|
|
channel &= 7;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
ent = 0;
|
|
|
|
channel = 0;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (flags & SND_POS)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* positioned in space */
|
2012-07-22 13:34:45 +00:00
|
|
|
MSG_ReadPos(&net_message, pos_v);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
pos = pos_v;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* use entity number */
|
2009-02-28 14:41:18 +00:00
|
|
|
pos = NULL;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
|
|
|
if (!cl.sound_precache[sound_num])
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
return;
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
S_StartSound(pos, ent, channel, cl.sound_precache[sound_num],
|
|
|
|
volume, attenuation, ofs);
|
2010-06-18 13:58:31 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
SHOWNET(char *s)
|
|
|
|
{
|
|
|
|
if (cl_shownet->value >= 2)
|
|
|
|
{
|
|
|
|
Com_Printf("%3i:%s\n", net_message.readcount - 1, s);
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
void
|
|
|
|
CL_ParseServerMessage(void)
|
|
|
|
{
|
|
|
|
int cmd;
|
|
|
|
char *s;
|
|
|
|
int i;
|
2010-06-18 13:58:31 +00:00
|
|
|
|
|
|
|
/* if recording demos, copy the message out */
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cl_shownet->value == 1)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf("%i ", net_message.cursize);
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else if (cl_shownet->value >= 2)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf("------------------\n");
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* parse the message */
|
2012-07-22 13:34:45 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (net_message.readcount > net_message.cursize)
|
|
|
|
{
|
|
|
|
Com_Error(ERR_DROP, "CL_ParseServerMessage: Bad server message");
|
2009-02-28 14:41:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
cmd = MSG_ReadByte(&net_message);
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cmd == -1)
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
SHOWNET("END OF MESSAGE");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cl_shownet->value >= 2)
|
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
if (!svc_strings[cmd])
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
Com_Printf("%3i:BAD CMD %i\n", net_message.readcount - 1, cmd);
|
|
|
|
}
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2009-02-28 14:41:18 +00:00
|
|
|
else
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
2009-02-28 14:41:18 +00:00
|
|
|
SHOWNET(svc_strings[cmd]);
|
2012-07-22 13:34:45 +00:00
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
|
2010-06-18 13:58:31 +00:00
|
|
|
/* other commands */
|
2012-07-22 13:34:45 +00:00
|
|
|
switch (cmd)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
default:
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Error(ERR_DROP, "CL_ParseServerMessage: Illegible server message\n");
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_nop:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_disconnect:
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Error(ERR_DISCONNECT, "Server disconnected\n");
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_reconnect:
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Printf("Server disconnected, reconnecting\n");
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (cls.download)
|
|
|
|
{
|
2010-06-18 13:58:31 +00:00
|
|
|
/* close download */
|
2012-07-22 13:34:45 +00:00
|
|
|
fclose(cls.download);
|
2010-06-18 13:58:31 +00:00
|
|
|
cls.download = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cls.state = ca_connecting;
|
|
|
|
cls.connect_time = -99999; /* CL_CheckForResend() will fire immediately */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_print:
|
2012-07-22 13:34:45 +00:00
|
|
|
i = MSG_ReadByte(&net_message);
|
2010-06-18 13:58:31 +00:00
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
if (i == PRINT_CHAT)
|
|
|
|
{
|
|
|
|
S_StartLocalSound("misc/talk.wav");
|
2010-06-18 13:58:31 +00:00
|
|
|
con.ormask = 128;
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Printf("%s", MSG_ReadString(&net_message));
|
2010-06-18 13:58:31 +00:00
|
|
|
con.ormask = 0;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_centerprint:
|
2012-07-22 13:34:45 +00:00
|
|
|
SCR_CenterPrint(MSG_ReadString(&net_message));
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_stufftext:
|
2012-07-22 13:34:45 +00:00
|
|
|
s = MSG_ReadString(&net_message);
|
|
|
|
Com_DPrintf("stufftext: %s\n", s);
|
|
|
|
Cbuf_AddText(s);
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_serverdata:
|
2012-07-22 13:34:45 +00:00
|
|
|
Cbuf_Execute(); /* make sure any stuffed commands are done */
|
|
|
|
CL_ParseServerData();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_configstring:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseConfigString();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_sound:
|
|
|
|
CL_ParseStartSoundPacket();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_spawnbaseline:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseBaseline();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_temp_entity:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseTEnt();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_muzzleflash:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_AddMuzzleFlash();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_muzzleflash2:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_AddMuzzleFlash2();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_download:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseDownload();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_frame:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseFrame();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_inventory:
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_ParseInventory();
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_layout:
|
2012-07-22 13:34:45 +00:00
|
|
|
s = MSG_ReadString(&net_message);
|
2013-05-11 12:44:36 +00:00
|
|
|
Q_strlcpy(cl.layout, s, sizeof(cl.layout));
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case svc_playerinfo:
|
|
|
|
case svc_packetentities:
|
|
|
|
case svc_deltapacketentities:
|
2012-07-22 13:34:45 +00:00
|
|
|
Com_Error(ERR_DROP, "Out of place frame data");
|
2010-06-18 13:58:31 +00:00
|
|
|
break;
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-22 13:34:45 +00:00
|
|
|
CL_AddNetgraph();
|
2009-02-28 14:41:18 +00:00
|
|
|
|
2013-05-01 19:12:38 +00:00
|
|
|
/* we don't know if it is ok to save a demo message
|
2012-07-22 13:34:45 +00:00
|
|
|
until after we have parsed the frame */
|
2009-02-28 14:41:18 +00:00
|
|
|
if (cls.demorecording && !cls.demowaiting)
|
2012-07-22 13:34:45 +00:00
|
|
|
{
|
|
|
|
CL_WriteDemoMessage();
|
|
|
|
}
|
2009-02-28 14:41:18 +00:00
|
|
|
}
|
2012-07-22 13:34:45 +00:00
|
|
|
|