35 entity_state_t *state;
39 Com_Error(ERR_DROP,
"%s: MAX_EDICTS exceeded", __func__);
47 if (cl_shownet->integer > 2 && bits) {
48 MSG_ShowDeltaEntityBits(bits);
53 MSG_ParseDeltaEntity(old, state, newnum, bits,
cl.
esFlags);
56 if (!(bits & U_OLDORIGIN) && !(state->renderfx & RF_BEAM))
57 VectorCopy(old->origin, state->old_origin);
65 entity_state_t *oldstate;
83 oldnum = oldstate->number;
88 newnum = MSG_ParseEntityBits(&bits);
89 if (newnum < 0 || newnum >= MAX_EDICTS) {
90 Com_Error(ERR_DROP,
"%s: bad number: %d", __func__, newnum);
94 Com_Error(ERR_DROP,
"%s: read past end of message", __func__);
101 while (oldnum < newnum) {
103 SHOWNET(3,
" unchanged: %i\n", oldnum);
113 oldnum = oldstate->number;
117 if (bits & U_REMOVE) {
119 SHOWNET(2,
" remove: %i\n", newnum);
120 if (oldnum != newnum) {
121 Com_DPrintf(
"U_REMOVE: oldnum != newnum\n");
124 Com_Error(ERR_DROP,
"%s: U_REMOVE with NULL oldframe", __func__);
134 oldnum = oldstate->number;
139 if (oldnum == newnum) {
141 SHOWNET(2,
" delta: %i ", newnum);
154 oldnum = oldstate->number;
159 if (oldnum > newnum) {
161 SHOWNET(2,
" baseline: %i ", newnum);
172 while (oldnum != 99999) {
174 SHOWNET(3,
" unchanged: %i\n", oldnum);
184 oldnum = oldstate->number;
191 uint32_t bits, extraflags;
192 int currentframe, deltaframe,
195 player_state_t *from;
198 memset(&frame, 0,
sizeof(frame));
206 currentframe = bits & FRAMENUM_MASK;
207 delta = bits >> FRAMENUM_BITS;
212 deltaframe = currentframe - delta;
217 suppressed = bits & SUPPRESSCOUNT_MASK;
219 if (suppressed & FF_CLIENTPRED) {
221 suppressed &= ~FF_CLIENTDROP;
224 }
else if (suppressed) {
227 extraflags = (extrabits << 4) | (bits >> SUPPRESSCOUNT_BITS);
241 frame.
number = currentframe;
242 frame.
delta = deltaframe;
251 if (deltaframe > 0) {
252 oldframe = &
cl.
frames[deltaframe & UPDATE_MASK];
253 from = &oldframe->
ps;
254 if (deltaframe == currentframe) {
256 Com_DPrintf(
"%s: delta from current frame\n", __func__);
258 }
else if (oldframe->
number != deltaframe) {
261 Com_DPrintf(
"%s: delta frame was never received or too old\n", __func__);
263 }
else if (!oldframe->
valid) {
265 Com_DPrintf(
"%s: delta from invalid frame\n", __func__);
268 MAX_PARSE_ENTITIES - MAX_PACKET_ENTITIES) {
269 Com_DPrintf(
"%s: delta entities too old\n", __func__);
275 Com_DPrintf(
"%s: recovering broken demo\n", __func__);
277 from = &oldframe->
ps;
290 if (length < 0 || msg_read.readcount + length >
msg_read.cursize) {
291 Com_Error(ERR_DROP,
"%s: read past end of message", __func__);
293 if (length >
sizeof(frame.
areabits)) {
294 Com_Error(ERR_DROP,
"%s: invalid areabits length", __func__);
305 Com_Error(ERR_DROP,
"%s: not playerinfo", __func__);
314 MSG_ParseDeltaPlayerstate_Enhanced(from, &frame.
ps, bits, extraflags);
316 if (cl_shownet->integer > 2 && (bits || extraflags)) {
317 MSG_ShowDeltaPlayerstateBits_Enhanced(bits, extraflags);
323 if (extraflags & EPS_CLIENTNUM) {
325 }
else if (oldframe) {
332 MSG_ParseDeltaPlayerstate_Default(from, &frame.
ps, bits);
334 if (cl_shownet->integer > 2 && bits) {
335 MSG_ShowDeltaPlayerstateBits_Default(bits);
345 Com_Error(ERR_DROP,
"%s: not packetentities", __func__);
354 cl.
frames[currentframe & UPDATE_MASK] = frame;
357 if (cl_shownet->integer > 2) {
360 int seq =
cls.
netchan->incoming_acknowledged & CMD_MASK;
363 Com_LPrintf(PRINT_DEVELOPER,
"%3"PRIz
":frame:%d delta:%d rtt:%d\n",
371 cl.keyframe.valid = qfalse;
378 Com_Error(ERR_DROP,
"%s: bad fov", __func__);
389 cl.oldkeyframe =
cl.keyframe;
413 if (index < 0 || index >= MAX_CONFIGSTRINGS) {
414 Com_Error(ERR_DROP,
"%s: bad index: %d", __func__, index);
418 maxlen = CS_SIZE(index);
421 SHOWNET(2,
" %d \"%s\"\n", index, s);
425 "%s: index %d overflowed: %"PRIz
" > %"PRIz
"\n",
426 __func__, index, len, maxlen - 1);
430 Q_SetBit(
cl.
dcs, index);
435 Q_SetBit(
cl.
dcs, index);
444 if (index < 1 || index >= MAX_EDICTS) {
445 Com_Error(ERR_DROP,
"%s: bad index: %d", __func__, index);
448 if (cl_shownet->integer > 2) {
449 MSG_ShowDeltaEntityBits(bits);
464 if (index == MAX_CONFIGSTRINGS) {
471 index = MSG_ParseEntityBits(&bits);
481 char levelname[MAX_QPATH];
482 int i, protocol, attractloop q_unused;
495 Com_DPrintf(
"Serverdata packet received "
496 "(protocol=%d, servercount=%d, attractloop=%d)\n",
502 Com_Error(ERR_DROP,
"Requested protocol version %d, but server returned %d.",
506 if (protocol < PROTOCOL_VERSION_OLD || protocol > PROTOCOL_VERSION_Q2PRO) {
507 Com_Error(ERR_DROP,
"Demo uses unsupported protocol version %d.", protocol);
515 Com_Error(ERR_DROP,
"Oversize gamedir string");
542 cl.frametime = BASE_FRAMETIME;
543 cl.frametime_inv = BASE_1_FRAMETIME;
553 Com_Error(ERR_DROP,
"'Enhanced' R1Q2 servers are not supported");
559 if (!R1Q2_SUPPORTED(i)) {
561 "R1Q2 server reports unsupported protocol version %d.\n"
562 "Assuming it really uses our current client version %d.\n"
563 "Things will break if it does not!\n", i, PROTOCOL_VERSION_R1Q2_CURRENT);
564 clamp(i, PROTOCOL_VERSION_R1Q2_MINIMUM, PROTOCOL_VERSION_R1Q2_CURRENT);
566 Com_DPrintf(
"Using minor R1Q2 protocol version %d\n", i);
571 Com_DPrintf(
"R1Q2 strafejump hack enabled\n");
572 cl.
pmp.strafehack = qtrue;
578 cl.
pmp.speedmult = 2;
581 if (!Q2PRO_SUPPORTED(i)) {
583 "Q2PRO server reports unsupported protocol version %d.\n"
584 "Current client version is %d.", i, PROTOCOL_VERSION_Q2PRO_CURRENT);
586 Com_DPrintf(
"Using minor Q2PRO protocol version %d\n", i);
590 Com_DPrintf(
"Q2PRO server state %d\n", i);
595 Com_DPrintf(
"Q2PRO strafejump hack enabled\n");
596 cl.
pmp.strafehack = qtrue;
600 Com_DPrintf(
"Q2PRO QW mode enabled\n");
616 Com_DPrintf(
"Q2PRO waterjump hack enabled\n");
617 cl.
pmp.waterhack = qtrue;
620 cl.
pmp.speedmult = 2;
621 cl.
pmp.flyhack = qtrue;
622 cl.
pmp.flyfriction = 4;
631 "\35\36\36\36\36\36\36\36\36\36\36\36"
632 "\36\36\36\36\36\36\36\36\36\36\36\36"
633 "\36\36\36\36\36\36\36\36\36\36\36\37"
637 Com_Printf(
"%s\n", levelname);
667 case TE_BULLET_SPARKS:
668 case TE_SCREEN_SPARKS:
669 case TE_SHIELD_SPARKS:
675 case TE_HEATBEAM_SPARKS:
676 case TE_HEATBEAM_STEAM:
678 case TE_ELECTRIC_SPARKS:
684 case TE_LASER_SPARKS:
685 case TE_WELDING_SPARKS:
686 case TE_TUNNEL_SPARKS:
693 case TE_BLUEHYPERBLASTER:
697 case TE_BUBBLETRAIL2:
703 case TE_GRENADE_EXPLOSION:
704 case TE_GRENADE_EXPLOSION_WATER:
706 case TE_PLASMA_EXPLOSION:
707 case TE_ROCKET_EXPLOSION:
708 case TE_ROCKET_EXPLOSION_WATER:
710 case TE_EXPLOSION1_NP:
711 case TE_EXPLOSION1_BIG:
712 case TE_BFG_EXPLOSION:
713 case TE_BFG_BIGEXPLOSION:
715 case TE_PLAIN_EXPLOSION:
716 case TE_CHAINFIST_SMOKE:
717 case TE_TRACKER_EXPLOSION:
718 case TE_TELEPORT_EFFECT:
725 case TE_PARASITE_ATTACK:
726 case TE_MEDIC_CABLE_ATTACK:
728 case TE_MONSTER_HEATBEAM:
734 case TE_GRAPPLE_CABLE:
771 case TE_WIDOWBEAMOUT:
784 Com_Error(ERR_DROP,
"%s: bad type", __func__);
793 if (entity < 1 || entity >= MAX_EDICTS)
794 Com_Error(ERR_DROP,
"%s: bad entity", __func__);
804 int flags, channel, entity;
807 if ((flags & (SND_ENT | SND_POS)) == 0)
808 Com_Error(ERR_DROP,
"%s: neither SND_ENT nor SND_POS set", __func__);
812 Com_Error(ERR_DROP,
"%s: read past end of message", __func__);
814 if (flags & SND_VOLUME)
817 snd.
volume = DEFAULT_SOUND_PACKET_VOLUME;
819 if (flags & SND_ATTENUATION)
824 if (flags & SND_OFFSET)
829 if (flags & SND_ENT) {
832 entity = channel >> 3;
833 if (entity < 0 || entity >= MAX_EDICTS)
834 Com_Error(ERR_DROP,
"%s: bad entity: %d", __func__, entity);
854 Com_Error(ERR_DISCONNECT,
"Server disconnected");
857 Com_Printf(
"Server disconnected, reconnecting\n");
876 static void CL_CheckForVersion(
const char *s)
885 if (strncmp(p + 2,
"!version", 8)) {
894 cl.reply_delta = 1024 + (rand() & 1023);
902 unsigned b1, b2, b3, b4, port;
907 if (sscanf(s,
"%3u.%3u.%3u.%3u", &b1, &b2, &b3, &b4) == 4 &&
908 b1 < 256 && b2 < 256 && b3 < 256 && b4 < 256) {
911 port = strtoul(p + 1, NULL, 10);
912 if (port < 1024 || port > 65535) {
925 a->port = BigShort(port);
936 char s[MAX_STRING_CHARS];
944 if (
level != PRINT_CHAT) {
959 CL_CheckForVersion(s);
985 if (
cl.
serverstate == ss_broadcast && !strncmp(s,
"[MVD] ", 6))
997 char s[MAX_STRING_CHARS];
1011 char s[MAX_STRING_CHARS];
1028 for (i = 0; i < MAX_ITEMS; i++) {
1035 int size, percent, compressed;
1039 Com_Error(ERR_DROP,
"%s: no download requested", __func__);
1051 if (cmd == svc_zdownload) {
1062 Com_Error(ERR_DROP,
"%s: bad size: %d", __func__, size);
1066 Com_Error(ERR_DROP,
"%s: read past end of message", __func__);
1079 byte buffer[MAX_MSGLEN];
1083 Com_Error(ERR_DROP,
"%s: recursively entered", __func__);
1089 if (inlen == -1 || outlen == -1 ||
msg_read.readcount + inlen >
msg_read.cursize) {
1090 Com_Error(ERR_DROP,
"%s: read past end of message", __func__);
1093 if (outlen > MAX_MSGLEN) {
1094 Com_Error(ERR_DROP,
"%s: invalid output length", __func__);
1097 inflateReset(&
cls.z);
1100 cls.z.avail_in = (uInt)inlen;
1101 cls.z.next_out = buffer;
1102 cls.z.avail_out = (uInt)outlen;
1103 if (inflate(&
cls.z, Z_FINISH) != Z_STREAM_END) {
1104 Com_Error(ERR_DROP,
"%s: inflate() failed: %s", __func__,
cls.z.msg);
1117 Com_Error(ERR_DROP,
"Compressed server packet received, "
1118 "but no zlib support linked in.");
1123 static void set_server_fps(
int value)
1125 int framediv = value / BASE_FRAMERATE;
1127 clamp(framediv, 1, MAX_FRAMEDIV);
1129 cl.frametime = BASE_FRAMETIME / framediv;
1130 cl.frametime_inv = framediv * BASE_1_FRAMETIME;
1131 cl.framediv = framediv;
1139 Com_DPrintf(
"client framediv=%d time=%d delta=%d\n",
1155 set_server_fps(value);
1175 if (cl_shownet->integer == 1) {
1177 }
else if (cl_shownet->integer > 1) {
1178 Com_LPrintf(PRINT_DEVELOPER,
"------------------\n");
1187 Com_Error(ERR_DROP,
"%s: read past end of server message", __func__);
1197 extrabits = cmd >> SVCMD_BITS;
1201 if (cl_shownet->integer > 1) {
1210 Com_Error(ERR_DROP,
"%s: illegible server message: %d", __func__, cmd);
1216 case svc_disconnect:
1217 Com_Error(ERR_DISCONNECT,
"Server disconnected");
1228 case svc_centerprint:
1236 case svc_serverdata:
1240 case svc_configstring:
1250 case svc_spawnbaseline:
1251 index = MSG_ParseEntityBits(&bits);
1317 size_t len =
msg_read.readcount - readcount;
1349 if (cl_shownet->integer == 1) {
1351 }
else if (cl_shownet->integer > 1) {
1352 Com_LPrintf(PRINT_DEVELOPER,
"------------------\n");
1361 Com_Error(ERR_DROP,
"%s: read past end of server message", __func__);
1369 extrabits = cmd >> SVCMD_BITS;
1373 if (cl_shownet->integer > 1) {
1381 Com_Error(ERR_DROP,
"%s: illegible server message: %d", __func__, cmd);
1387 case svc_disconnect:
1389 Com_Error(ERR_DISCONNECT,
"Server disconnected");
1396 case svc_centerprint:
1401 case svc_configstring: