31 #define Q2PRO_OPTIMIZE(c) \
32 ((c)->protocol == PROTOCOL_VERSION_Q2PRO && !(c)->settings[CLS_RECORDING])
46 entity_packed_t *newent;
47 const entity_packed_t *oldent;
48 unsigned i, oldindex, newindex, from_num_entities;
53 from_num_entities = 0;
59 oldent = newent = NULL;
60 while (newindex < to->num_entities || oldindex < from_num_entities) {
66 newnum = newent->number;
69 if (oldindex >= from_num_entities) {
74 oldnum = oldent->number;
77 if (newnum == oldnum) {
85 flags |= MSG_ES_NEWENTITY;
87 if (newnum == clientEntityNum) {
88 flags |= MSG_ES_FIRSTPERSON;
89 VectorCopy(oldent->origin, newent->origin);
90 VectorCopy(oldent->angles, newent->angles);
93 flags |= MSG_ES_SHORTANGLES;
101 if (newnum < oldnum) {
103 flags = client->
esFlags | MSG_ES_FORCE | MSG_ES_NEWENTITY;
110 if (newnum == clientEntityNum) {
111 flags |= MSG_ES_FIRSTPERSON;
112 VectorCopy(oldent->origin, newent->origin);
113 VectorCopy(oldent->angles, newent->angles);
116 flags |= MSG_ES_SHORTANGLES;
123 if (newnum > oldnum) {
148 Com_DPrintf(
"%s: delta request from out-of-date packet.\n", client->
name);
156 Com_DPrintf(
"%s: delta request from dropped frame.\n", client->
name);
162 Com_DPrintf(
"%s: delta request from out-of-date entities.\n", client->
name);
177 player_packed_t *oldstate;
186 oldstate = &oldframe->
ps;
221 player_packed_t *oldstate;
223 int delta, suppressed;
225 msgPsFlags_t psFlags;
234 oldstate = &oldframe->
ps;
255 if (!client->
settings[CLS_RECORDING]) {
257 psFlags |= MSG_PS_IGNORE_GUNFRAMES;
258 if (client->
settings[CLS_NOGUN] != 2) {
259 psFlags |= MSG_PS_IGNORE_GUNINDEX;
262 if (client->
settings[CLS_NOBLEND]) {
263 psFlags |= MSG_PS_IGNORE_BLEND;
265 if (frame->
ps.pmove.pm_type < PM_DEAD) {
266 if (!(frame->
ps.pmove.pm_flags & PMF_NO_PREDICTION)) {
267 psFlags |= MSG_PS_IGNORE_VIEWANGLES;
271 psFlags |= MSG_PS_IGNORE_DELTAANGLES;
276 if (client->
protocol == PROTOCOL_VERSION_Q2PRO) {
277 if (frame->
ps.pmove.pm_type < PM_DEAD && !client->
settings[CLS_RECORDING]) {
280 if (client->
settings[CLS_NOPREDICT]) {
281 psFlags |= MSG_PS_IGNORE_PREDICTION;
291 if (client->
protocol == PROTOCOL_VERSION_Q2PRO) {
293 if (client->
version < PROTOCOL_VERSION_Q2PRO_CLIENTNUM_FIX) {
295 extraflags |= EPS_CLIENTNUM;
299 int clientNum = oldframe ? oldframe->
clientNum : 0;
301 extraflags |= EPS_CLIENTNUM;
308 *b1 = svc_frame | (((extraflags & 0x70) << 1));
311 *b2 = (suppressed & SUPPRESSCOUNT_MASK) |
312 ((extraflags & 0x0F) << SUPPRESSCOUNT_BITS);
331 fix_old_origin(
client_t *client, entity_packed_t *state, edict_t *ent,
int e)
336 if (ent->s.renderfx & RF_BEAM)
348 if (state->event == EV_PLAYER_TELEPORT && !
Q2PRO_OPTIMIZE(client)) {
350 VectorCopy(state->origin, state->old_origin);
354 if (sent->create_framenum >
sv.
framenum - client->framediv) {
356 VectorScale(sent->create_origin, 8.0f, state->old_origin);
361 for (i = 0; i < client->framediv - 1; i++) {
363 k = j & ENT_HISTORY_MASK;
364 if (sent->history[k].framenum == j) {
365 VectorScale(sent->history[k].origin, 8.0f, state->old_origin);
389 entity_packed_t *state;
393 int clientarea, clientcluster;
395 byte clientphs[VIS_MAX_BYTES];
396 byte clientpvs[VIS_MAX_BYTES];
397 qboolean ent_visible;
398 int cull_nonvisible_entities =
Cvar_Get(
"sv_cull_nonvisible_entities",
"1", CVAR_CHEAT)->integer;
400 clent = client->
edict;
413 ps = &clent->client->ps;
414 VectorMA(ps->viewoffset, 0.125f, ps->pmove.origin, org);
417 clientarea = CM_LeafArea(leaf);
418 clientcluster = CM_LeafCluster(leaf);
432 frame->
clientNum = clent->client->clientNum;
437 if (clientcluster >= 0)
453 for (e = 1; e < client->
pool->num_edicts; e++) {
457 if (!ent->inuse && (
g_features->integer & GMF_PROPERINUSE)) {
462 if (ent->svflags & SVF_NOCLIENT)
466 if (!ent->s.modelindex && !ent->s.effects && !ent->s.sound) {
470 if (ent->s.event == EV_FOOTSTEP && client->
settings[CLS_NOFOOTSTEPS]) {
475 if ((ent->s.effects & EF_GIB) && client->
settings[CLS_NOGIBS]) {
488 ent_visible = qfalse;
495 if (ent->s.renderfx & RF_BEAM) {
496 l = ent->clusternums[0];
497 if (!Q_IsBitSet(clientphs, l))
498 ent_visible = qfalse;
502 ent_visible = qfalse;
505 if (!ent->s.modelindex) {
510 VectorSubtract(org, ent->s.origin, delta);
511 len = VectorLength(delta);
513 ent_visible = qfalse;
519 if(!ent_visible && (!
sv_novis->integer || !ent->s.modelindex))
522 if (ent->s.number != e) {
523 Com_WPrintf(
"%s: fixing ent->s.number: %d to %d\n",
524 __func__, ent->s.number, e);
528 memcpy(&es, &ent->s,
sizeof(entity_state_t));
542 if (client->framediv != 1)
543 fix_old_origin(client, state, ent, e);
547 if (state->event == EV_FOOTSTEP && client->
settings[CLS_NOFOOTSTEPS]) {
552 if (e == frame->
clientNum + 1 && ent != clent &&
554 state->modelindex = 0;
558 if (
sv.
state == ss_broadcast) {
560 if (state->solid != PACKED_BSP)
564 if (ent->owner == clent) {
567 }
else if (client->
esFlags & MSG_ES_LONGSOLID) {