2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 // cl_parse.c -- parse a message received from the server
24 #include "cl_collision.h"
27 char *svc_strings[128] =
33 "svc_version", // [int] server version
34 "svc_setview", // [short] entity number
35 "svc_sound", // <see code>
36 "svc_time", // [float] server time
37 "svc_print", // [string] null terminated string
38 "svc_stufftext", // [string] stuffed into client's console buffer
39 // the string should be \n terminated
40 "svc_setangle", // [vec3] set the view angle to this absolute value
42 "svc_serverinfo", // [int] version
43 // [string] signon string
44 // [string]..[0]model cache [string]...[0]sounds cache
45 // [string]..[0]item cache
46 "svc_lightstyle", // [byte] [string]
47 "svc_updatename", // [byte] [string]
48 "svc_updatefrags", // [byte] [short]
49 "svc_clientdata", // <shortbits + data>
50 "svc_stopsound", // <see code>
51 "svc_updatecolors", // [byte] [byte]
52 "svc_particle", // [vec3] <variable>
53 "svc_damage", // [byte] impact [byte] blood [vec3] from
56 "OBSOLETE svc_spawnbinary",
59 "svc_temp_entity", // <variable>
65 "svc_spawnstaticsound",
67 "svc_finale", // [string] music [string] text
68 "svc_cdtrack", // [byte] track [byte] looptrack
71 "svc_showlmp", // [string] iconlabel [string] lmpfile [short] x [short] y
72 "svc_hidelmp", // [string] iconlabel
73 "svc_skybox", // [string] skyname
86 "svc_cgame", // 50 // [short] length [bytes] data
87 "svc_updatestatubyte", // 51 // [byte] stat [byte] value
88 "svc_effect", // 52 // [vector] org [byte] modelindex [byte] startframe [byte] framecount [byte] framerate
89 "svc_effect2", // 53 // [vector] org [short] modelindex [short] startframe [byte] framecount [byte] framerate
90 "svc_sound2", // 54 // short soundindex instead of byte
91 "svc_spawnbaseline2", // 55 // short modelindex instead of byte
92 "svc_spawnstatic2", // 56 // short modelindex instead of byte
93 "svc_entities", // 57 // [int] deltaframe [int] thisframe [float vector] eye [variable length] entitydata
94 "svc_csqcentities", // 58 // [short] entnum [variable length] entitydata ... [short] 0x0000
95 "svc_spawnstaticsound2", // 59 // [coord3] [short] samp [byte] vol [byte] aten
98 char *qw_svc_strings[128] =
102 "qw_svc_disconnect", // 2
103 "qw_svc_updatestat", // 3 // [byte] [byte]
105 "qw_svc_setview", // 5 // [short] entity number
106 "qw_svc_sound", // 6 // <see code>
108 "qw_svc_print", // 8 // [byte] id [string] null terminated string
109 "qw_svc_stufftext", // 9 // [string] stuffed into client's console buffer
110 "qw_svc_setangle", // 10 // [angle3] set the view angle to this absolute value
111 "qw_svc_serverdata", // 11 // [long] protocol ...
112 "qw_svc_lightstyle", // 12 // [byte] [string]
114 "qw_svc_updatefrags", // 14 // [byte] [short]
116 "qw_svc_stopsound", // 16 // <see code>
119 "qw_svc_damage", // 19
120 "qw_svc_spawnstatic", // 20
122 "qw_svc_spawnbaseline", // 22
123 "qw_svc_temp_entity", // 23 // variable
124 "qw_svc_setpause", // 24 // [byte] on / off
126 "qw_svc_centerprint", // 26 // [string] to put in center of the screen
127 "qw_svc_killedmonster", // 27
128 "qw_svc_foundsecret", // 28
129 "qw_svc_spawnstaticsound", // 29 // [coord3] [byte] samp [byte] vol [byte] aten
130 "qw_svc_intermission", // 30 // [vec3_t] origin [vec3_t] angle
131 "qw_svc_finale", // 31 // [string] text
132 "qw_svc_cdtrack", // 32 // [byte] track
133 "qw_svc_sellscreen", // 33
134 "qw_svc_smallkick", // 34 // set client punchangle to 2
135 "qw_svc_bigkick", // 35 // set client punchangle to 4
136 "qw_svc_updateping", // 36 // [byte] [short]
137 "qw_svc_updateentertime", // 37 // [byte] [float]
138 "qw_svc_updatestatlong", // 38 // [byte] [long]
139 "qw_svc_muzzleflash", // 39 // [short] entity
140 "qw_svc_updateuserinfo", // 40 // [byte] slot [long] uid
141 "qw_svc_download", // 41 // [short] size [size bytes]
142 "qw_svc_playerinfo", // 42 // variable
143 "qw_svc_nails", // 43 // [byte] num [48 bits] xyzpy 12 12 12 4 8
144 "qw_svc_chokecount", // 44 // [byte] packets choked
145 "qw_svc_modellist", // 45 // [strings]
146 "qw_svc_soundlist", // 46 // [strings]
147 "qw_svc_packetentities", // 47 // [...]
148 "qw_svc_deltapacketentities", // 48 // [...]
149 "qw_svc_maxspeed", // 49 // maxspeed change, for prediction
150 "qw_svc_entgravity", // 50 // gravity change, for prediction
151 "qw_svc_setinfo", // 51 // setinfo on a client
152 "qw_svc_serverinfo", // 52 // serverinfo
153 "qw_svc_updatepl", // 53 // [byte] [byte]
156 //=============================================================================
158 cvar_t demo_nehahra = {0, "demo_nehahra", "0", "reads all quake demos as nehahra movie protocol"};
159 cvar_t developer_networkentities = {0, "developer_networkentities", "0", "prints received entities, value is 0-4 (higher for more info)"};
161 static qboolean QW_CL_CheckOrDownloadFile(const char *filename);
162 static void QW_CL_RequestNextDownload(void);
163 static void QW_CL_NextUpload(void);
164 void QW_CL_StartUpload(unsigned char *data, int size);
165 //static qboolean QW_CL_IsUploading(void);
166 static void QW_CL_StopUpload(void);
170 CL_ParseStartSoundPacket
173 void CL_ParseStartSoundPacket(int largesoundindex)
182 if (cls.protocol == PROTOCOL_QUAKEWORLD)
184 channel = MSG_ReadShort();
186 if (channel & (1<<15))
187 volume = MSG_ReadByte ();
189 volume = DEFAULT_SOUND_PACKET_VOLUME;
191 if (channel & (1<<14))
192 attenuation = MSG_ReadByte () / 64.0;
194 attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
196 ent = (channel>>3)&1023;
199 sound_num = MSG_ReadByte ();
203 field_mask = MSG_ReadByte();
205 if (field_mask & SND_VOLUME)
206 volume = MSG_ReadByte ();
208 volume = DEFAULT_SOUND_PACKET_VOLUME;
210 if (field_mask & SND_ATTENUATION)
211 attenuation = MSG_ReadByte () / 64.0;
213 attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
215 if (field_mask & SND_LARGEENTITY)
217 ent = (unsigned short) MSG_ReadShort ();
218 channel = MSG_ReadByte ();
222 channel = (unsigned short) MSG_ReadShort ();
227 if (largesoundindex || field_mask & SND_LARGESOUND)
228 sound_num = (unsigned short) MSG_ReadShort ();
230 sound_num = MSG_ReadByte ();
233 MSG_ReadVector(pos, cls.protocol);
235 if (sound_num >= MAX_SOUNDS)
237 Con_Printf("CL_ParseStartSoundPacket: sound_num (%i) >= MAX_SOUNDS (%i)\n", sound_num, MAX_SOUNDS);
241 if (ent >= MAX_EDICTS)
243 Con_Printf("CL_ParseStartSoundPacket: ent = %i", ent);
247 S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation);
254 When the client is taking a long time to load stuff, send keepalive messages
255 so the server doesn't disconnect.
259 static unsigned char olddata[NET_MAXMESSAGE];
260 void CL_KeepaliveMessage (void)
263 static double nextmsg = -1;
268 // no need if server is local and definitely not if this is a demo
269 if (sv.active || !cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD)
272 // read messages from server, should just be nops
273 oldreadcount = msg_readcount;
274 oldbadread = msg_badread;
276 memcpy(olddata, net_message.data, net_message.cursize);
278 NetConn_ClientFrame();
280 msg_readcount = oldreadcount;
281 msg_badread = oldbadread;
283 memcpy(net_message.data, olddata, net_message.cursize);
285 if (cls.netcon && (time = Sys_DoubleTime()) >= nextmsg)
288 unsigned char buf[4];
291 // LordHavoc: must use unreliable because reliable could kill the sigon message!
292 Con_Print("--> client to server keepalive\n");
293 memset(&msg, 0, sizeof(msg));
295 msg.maxsize = sizeof(buf);
296 MSG_WriteChar(&msg, svc_nop);
297 NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol);
301 void CL_ParseEntityLump(char *entdata)
304 char key[128], value[MAX_INPUTLINE];
305 FOG_clear(); // LordHavoc: no fog until set
306 // LordHavoc: default to the map's sky (q3 shader parsing sets this)
307 R_SetSkyBox(cl.worldmodel->brush.skybox);
311 if (!COM_ParseToken(&data, false))
313 if (com_token[0] != '{')
317 if (!COM_ParseToken(&data, false))
319 if (com_token[0] == '}')
320 break; // end of worldspawn
321 if (com_token[0] == '_')
322 strlcpy (key, com_token + 1, sizeof (key));
324 strlcpy (key, com_token, sizeof (key));
325 while (key[strlen(key)-1] == ' ') // remove trailing spaces
326 key[strlen(key)-1] = 0;
327 if (!COM_ParseToken(&data, false))
329 strlcpy (value, com_token, sizeof (value));
330 if (!strcmp("sky", key))
332 else if (!strcmp("skyname", key)) // non-standard, introduced by QuakeForge... sigh.
334 else if (!strcmp("qlsky", key)) // non-standard, introduced by QuakeLives (EEK)
336 else if (!strcmp("fog", key))
337 sscanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
338 else if (!strcmp("fog_density", key))
339 fog_density = atof(value);
340 else if (!strcmp("fog_red", key))
341 fog_red = atof(value);
342 else if (!strcmp("fog_green", key))
343 fog_green = atof(value);
344 else if (!strcmp("fog_blue", key))
345 fog_blue = atof(value);
349 static qboolean QW_CL_CheckOrDownloadFile(const char *filename)
353 // see if the file already exists
354 file = FS_Open(filename, "rb", true, false);
361 // download messages in a demo would be bad
362 if (cls.demorecording)
364 Con_Printf("Unable to download \"%s\" when recording.\n", filename);
368 // don't try to download when playing a demo
372 strlcpy(cls.qw_downloadname, filename, sizeof(cls.qw_downloadname));
373 Con_Printf("Downloading %s\n", filename);
375 if (!cls.qw_downloadmemory)
377 cls.qw_downloadmemory = NULL;
378 cls.qw_downloadmemorycursize = 0;
379 cls.qw_downloadmemorymaxsize = 1024*1024; // start out with a 1MB buffer
382 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
383 MSG_WriteString(&cls.netcon->message, va("download %s", filename));
385 cls.qw_downloadnumber++;
386 cls.qw_downloadpercent = 0;
391 static void QW_CL_RequestNextDownload(void)
395 // clear name of file that just finished
396 cls.qw_downloadname[0] = 0;
398 switch (cls.qw_downloadtype)
406 if (cls.qw_downloadnumber == 0)
408 Con_Printf("Checking models...\n");
409 cls.qw_downloadnumber = 1;
412 cls.qw_downloadtype = dl_model;
413 for (;cls.qw_downloadnumber < MAX_MODELS && cl.model_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
416 if (cl.model_name[cls.qw_downloadnumber][0] == '*')
418 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/spike.mdl"))
419 cl.qw_modelindex_spike = cls.qw_downloadnumber;
420 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/player.mdl"))
421 cl.qw_modelindex_player = cls.qw_downloadnumber;
422 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/flag.mdl"))
423 cl.qw_modelindex_flag = cls.qw_downloadnumber;
424 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/s_explod.spr"))
425 cl.qw_modelindex_s_explod = cls.qw_downloadnumber;
426 // check if we need to download the file, and return if so
427 if (!QW_CL_CheckOrDownloadFile(cl.model_name[cls.qw_downloadnumber]))
431 // touch all of the precached models that are still loaded so we can free
432 // anything that isn't needed
434 for (i = 1;i < MAX_MODELS && cl.model_name[i][0];i++)
435 Mod_FindName(cl.model_name[i]);
436 // precache any models used by the client (this also marks them used)
437 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
438 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
439 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
440 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
443 // now we try to load everything that is new
446 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
447 if (cl.model_precache[1]->Draw == NULL)
448 Con_Printf("Map %s could not be found or downloaded\n", cl.model_name[1]);
451 for (i = 2;i < MAX_MODELS && cl.model_name[i][0];i++)
452 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
453 Con_Printf("Model %s could not be found or downloaded\n", cl.model_name[i]);
455 // done checking sounds and models, send a prespawn command now
456 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
457 // FIXME: calculate the checksum2 this wants
458 //MSG_WriteString(&cls.netcon->message, va(qw_prespawn_name, cl.qw_servercount, cl.worldmodel->checksum2));
459 MSG_WriteString(&cls.netcon->message, va(qw_prespawn_name, cl.qw_servercount, 0));
461 if (cls.qw_downloadmemory)
463 Mem_Free(cls.qw_downloadmemory);
464 cls.qw_downloadmemory = NULL;
468 if (cls.qw_downloadnumber == 0)
470 Con_Printf("Checking sounds...\n");
471 cls.qw_downloadnumber = 1;
474 cls.qw_downloadtype = dl_sound;
475 for (;cl.sound_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
478 if (cl.sound_name[cls.qw_downloadnumber][0] == '*')
480 // check if we need to download the file, and return if so
481 if (!QW_CL_CheckOrDownloadFile(cl.sound_name[cls.qw_downloadnumber]))
485 // load new sounds and unload old ones
486 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
487 S_ServerSounds(cl.sound_name, cls.qw_downloadnumber);
489 // precache any sounds used by the client
490 cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
491 cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
492 cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
493 cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
494 cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
495 cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
496 cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
499 for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++)
501 // Don't lock the sfx here, S_ServerSounds already did that
502 cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, false);
505 // done with sound downloads, next we check models
506 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
507 MSG_WriteString(&cls.netcon->message, va(qw_modellist_name, cl.qw_servercount, 0));
511 Con_Printf("Unknown download type.\n");
515 static void QW_CL_ParseDownload(void)
517 int size = MSG_ReadShort();
518 int percent = MSG_ReadByte();
520 // skip the download fragment if playing a demo
524 msg_readcount += size;
530 Con_Printf("File not found.\n");
531 QW_CL_RequestNextDownload();
535 if (msg_readcount + (unsigned short)size > net_message.cursize)
536 Host_Error("corrupt download message\n");
538 // make sure the buffer is big enough to include this new fragment
539 if (!cls.qw_downloadmemory || cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
542 while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
543 cls.qw_downloadmemorymaxsize *= 2;
544 old = cls.qw_downloadmemory;
545 cls.qw_downloadmemory = Mem_Alloc(cl_mempool, cls.qw_downloadmemorymaxsize);
548 memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize);
553 // read the fragment out of the packet
554 MSG_ReadBytes(size, cls.qw_downloadmemory + cls.qw_downloadmemorycursize);
555 cls.qw_downloadmemorycursize += size;
557 cls.qw_downloadpercent = percent;
561 // request next fragment
562 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
563 MSG_WriteString(&cls.netcon->message, "nextdl");
568 Con_Printf("Downloaded \"%s\"\n", cls.qw_downloadname);
570 FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
572 cls.qw_downloadpercent = 0;
574 // start downloading the next file (or join the game)
575 QW_CL_RequestNextDownload();
579 static void QW_CL_ParseModelList(void)
582 int nummodels = MSG_ReadByte();
585 // parse model precache list
588 str = MSG_ReadString();
592 if (nummodels==MAX_MODELS)
593 Host_Error("Server sent too many model precaches");
594 if (strlen(str) >= MAX_QPATH)
595 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
596 strlcpy(cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
601 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
602 MSG_WriteString(&cls.netcon->message, va(qw_modellist_name, cl.qw_servercount, n));
606 cls.qw_downloadnumber = 0;
607 cls.qw_downloadtype = dl_model;
608 QW_CL_RequestNextDownload();
611 static void QW_CL_ParseSoundList(void)
614 int numsounds = MSG_ReadByte();
617 // parse sound precache list
620 str = MSG_ReadString();
624 if (numsounds==MAX_SOUNDS)
625 Host_Error("Server sent too many sound precaches");
626 if (strlen(str) >= MAX_QPATH)
627 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
628 strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
635 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
636 MSG_WriteString(&cls.netcon->message, va(qw_soundlist_name, cl.qw_servercount, n));
640 cls.qw_downloadnumber = 0;
641 cls.qw_downloadtype = dl_sound;
642 QW_CL_RequestNextDownload();
645 void QW_CL_NextUpload(void)
647 int r, percent, size;
649 if (!cls.qw_uploaddata)
652 r = cls.qw_uploadsize - cls.qw_uploadpos;
655 size = min(1, cls.qw_uploadsize);
656 percent = (cls.qw_uploadpos+r)*100/size;
658 MSG_WriteByte(&cls.netcon->message, qw_clc_upload);
659 MSG_WriteShort(&cls.netcon->message, r);
660 MSG_WriteByte(&cls.netcon->message, percent);
661 SZ_Write(&cls.netcon->message, cls.qw_uploaddata + cls.qw_uploadpos, r);
663 Con_DPrintf("UPLOAD: %6d: %d written\n", cls.qw_uploadpos, r);
665 cls.qw_uploadpos += r;
667 if (cls.qw_uploadpos < cls.qw_uploadsize)
670 Con_Printf("Upload completed\n");
675 void QW_CL_StartUpload(unsigned char *data, int size)
677 // do nothing in demos or if not connected
681 // abort existing upload if in progress
684 Con_DPrintf("Starting upload of %d bytes...\n", size);
686 cls.qw_uploaddata = Mem_Alloc(cl_mempool, size);
687 memcpy(cls.qw_uploaddata, data, size);
688 cls.qw_uploadsize = size;
689 cls.qw_uploadpos = 0;
695 qboolean QW_CL_IsUploading(void)
697 return cls.qw_uploaddata != NULL;
701 void QW_CL_StopUpload(void)
703 if (cls.qw_uploaddata)
704 Mem_Free(cls.qw_uploaddata);
705 cls.qw_uploaddata = NULL;
706 cls.qw_uploadsize = 0;
707 cls.qw_uploadpos = 0;
710 static void QW_CL_ProcessUserInfo(int slot)
712 int topcolor, bottomcolor;
714 InfoString_GetValue(cl.scores[slot].qw_userinfo, "name", cl.scores[slot].name, sizeof(cl.scores[slot].name));
715 InfoString_GetValue(cl.scores[slot].qw_userinfo, "topcolor", temp, sizeof(temp));topcolor = atoi(temp);
716 InfoString_GetValue(cl.scores[slot].qw_userinfo, "bottomcolor", temp, sizeof(temp));bottomcolor = atoi(temp);
717 cl.scores[slot].colors = topcolor * 16 + bottomcolor;
718 InfoString_GetValue(cl.scores[slot].qw_userinfo, "*spectator", temp, sizeof(temp));
719 cl.scores[slot].qw_spectator = temp[0] != 0;
720 InfoString_GetValue(cl.scores[slot].qw_userinfo, "skin", cl.scores[slot].qw_skin, sizeof(cl.scores[slot].qw_skin));
721 // LordHavoc: abusing Draw_CachePic for caching skins...
722 cl.scores[slot].qw_skin_cachepic = Draw_CachePic(cl.scores[slot].qw_skin, true);
725 static void QW_CL_UpdateUserInfo(void)
728 slot = MSG_ReadByte();
729 if (slot >= cl.maxclients)
731 Con_Printf("svc_updateuserinfo >= cl.maxclients\n");
736 cl.scores[slot].qw_userid = MSG_ReadLong();
737 strlcpy(cl.scores[slot].qw_userinfo, MSG_ReadString(), sizeof(cl.scores[slot].qw_userinfo));
739 QW_CL_ProcessUserInfo(slot);
742 static void QW_CL_SetInfo(void)
747 slot = MSG_ReadByte();
748 strlcpy(key, MSG_ReadString(), sizeof(key));
749 strlcpy(value, MSG_ReadString(), sizeof(value));
750 if (slot >= cl.maxclients)
752 Con_Printf("svc_setinfo >= cl.maxclients\n");
755 InfoString_SetValue(cl.scores[slot].qw_userinfo, sizeof(cl.scores[slot].qw_userinfo), key, value);
757 QW_CL_ProcessUserInfo(slot);
760 static void QW_CL_ServerInfo(void)
764 strlcpy(key, MSG_ReadString(), sizeof(key));
765 strlcpy(value, MSG_ReadString(), sizeof(value));
766 Con_DPrintf("SERVERINFO: %s=%s\n", key, value);
767 InfoString_SetValue(cl.qw_serverinfo, sizeof(cl.qw_serverinfo), key, value);
770 static void QW_CL_ParseNails(void)
773 int numnails = MSG_ReadByte();
775 unsigned char bits[6];
777 for (i = 0;i < numnails;i++)
779 v = cl.qw_nails[cl.qw_num_nails++];
780 for (j = 0;j < 6;j++)
781 bits[j] = MSG_ReadByte();
782 v[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096;
783 v[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096;
784 v[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096;
785 v[3] = 360*(bits[4]>>4)/16;
786 v[4] = 360*bits[5]/256;
791 static void QW_CL_UpdateItemsAndWeapon(void)
794 // check for important changes
797 if (cl.olditems != cl.stats[STAT_ITEMS])
798 for (j = 0;j < 32;j++)
799 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
800 cl.item_gettime[j] = cl.time;
801 cl.olditems = cl.stats[STAT_ITEMS];
803 // GAME_NEXUIZ hud needs weapon change time
804 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
805 cl.weapontime = cl.time;
806 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
810 =====================
813 An svc_signonnum has been received, perform a client side setup
814 =====================
816 static void CL_SignonReply (void)
818 Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
825 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
826 MSG_WriteString (&cls.netcon->message, "prespawn");
833 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
834 MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
836 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
837 MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
839 if (cl_pmodel.integer)
841 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
842 MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
844 if (*cl_playermodel.string)
846 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
847 MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
849 if (*cl_playerskin.string)
851 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
852 MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
855 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
856 MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
858 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
859 MSG_WriteString (&cls.netcon->message, "spawn");
866 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
867 MSG_WriteString (&cls.netcon->message, "begin");
882 void CL_ParseServerInfo (void)
886 protocolversion_t protocol;
887 int nummodels, numsounds;
890 Con_DPrint("Serverinfo packet received.\n");
892 // check memory integrity
893 Mem_CheckSentinelsGlobal();
896 // wipe the client_state_t struct
900 // parse protocol version number
902 protocol = Protocol_EnumForNumber(i);
903 if (protocol == PROTOCOL_UNKNOWN)
905 Host_Error("CL_ParseServerInfo: Server is unrecognized protocol number (%i)", i);
908 // hack for unmarked Nehahra movie demos which had a custom protocol
909 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
910 protocol = PROTOCOL_NEHAHRAMOVIE;
911 cls.protocol = protocol;
912 Con_DPrintf("Server protocol is %s\n", Protocol_NameForEnum(cls.protocol));
914 if (protocol == PROTOCOL_QUAKEWORLD)
916 cl.qw_servercount = MSG_ReadLong();
918 str = MSG_ReadString();
919 Con_Printf("server gamedir is %s\n", str);
921 // FIXME: change gamedir if needed!
922 if (strcasecmp(gamedirfile, str))
928 Com_Gamedir(str); // change gamedir
932 // exec the new config stuff
937 cl.maxclients = MSG_ReadByte ();
938 if (cl.maxclients & 128)
940 cl.qw_spectator = true;
941 cl.maxclients &= ~128;
943 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
945 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
948 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
950 cl.gametype = GAME_DEATHMATCH;
952 // get the full level name
953 str = MSG_ReadString ();
954 strlcpy (cl.levelname, str, sizeof(cl.levelname));
957 cl.qw_movevars_gravity = MSG_ReadFloat();
958 cl.qw_movevars_stopspeed = MSG_ReadFloat();
959 cl.qw_movevars_maxspeed = MSG_ReadFloat();
960 cl.qw_movevars_spectatormaxspeed = MSG_ReadFloat();
961 cl.qw_movevars_accelerate = MSG_ReadFloat();
962 cl.qw_movevars_airaccelerate = MSG_ReadFloat();
963 cl.qw_movevars_wateraccelerate = MSG_ReadFloat();
964 cl.qw_movevars_friction = MSG_ReadFloat();
965 cl.qw_movevars_waterfriction = MSG_ReadFloat();
966 cl.qw_movevars_entgravity = MSG_ReadFloat();
968 // seperate the printfs so the server message can have a color
969 Con_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\2%s\n", str);
971 // check memory integrity
972 Mem_CheckSentinelsGlobal();
975 // if server is active, we already began a loading plaque
977 SCR_BeginLoadingPlaque();
979 // disable until we get textures for it
982 memset(cl.csqc_model_precache, 0, sizeof(cl.csqc_model_precache)); //[515]: csqc
983 memset(cl.model_precache, 0, sizeof(cl.model_precache));
984 memset(cl.sound_precache, 0, sizeof(cl.sound_precache));
986 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
987 MSG_WriteString(&cls.netcon->message, va(qw_soundlist_name, cl.qw_servercount, 0));
989 cls.state = ca_connected;
995 cl.maxclients = MSG_ReadByte ();
996 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
998 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
1001 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
1004 cl.gametype = MSG_ReadByte ();
1006 // parse signon message
1007 str = MSG_ReadString ();
1008 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1010 // seperate the printfs so the server message can have a color
1011 if (cls.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
1012 Con_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\2%s\n", str);
1014 // check memory integrity
1015 Mem_CheckSentinelsGlobal();
1018 // if server is active, we already began a loading plaque
1020 SCR_BeginLoadingPlaque();
1022 // disable until we get textures for it
1025 memset(cl.csqc_model_precache, 0, sizeof(cl.csqc_model_precache)); //[515]: csqc
1026 memset(cl.model_precache, 0, sizeof(cl.model_precache));
1027 memset(cl.sound_precache, 0, sizeof(cl.sound_precache));
1029 // parse model precache list
1030 for (nummodels=1 ; ; nummodels++)
1032 str = MSG_ReadString();
1035 if (nummodels==MAX_MODELS)
1036 Host_Error ("Server sent too many model precaches");
1037 if (strlen(str) >= MAX_QPATH)
1038 Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1039 strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
1041 // parse sound precache list
1042 for (numsounds=1 ; ; numsounds++)
1044 str = MSG_ReadString();
1047 if (numsounds==MAX_SOUNDS)
1048 Host_Error("Server sent too many sound precaches");
1049 if (strlen(str) >= MAX_QPATH)
1050 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1051 strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
1054 // touch all of the precached models that are still loaded so we can free
1055 // anything that isn't needed
1057 for (i = 1;i < nummodels;i++)
1058 Mod_FindName(cl.model_name[i]);
1059 // precache any models used by the client (this also marks them used)
1060 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
1061 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
1062 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
1063 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
1066 // do the same for sounds
1067 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
1068 S_ServerSounds (cl.sound_name, numsounds);
1070 // precache any sounds used by the client
1071 cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
1072 cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
1073 cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
1074 cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
1075 cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
1076 cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
1077 cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
1079 // now we try to load everything that is new
1082 CL_KeepaliveMessage ();
1083 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
1084 if (cl.model_precache[1]->Draw == NULL)
1085 Con_Printf("Map %s not found\n", cl.model_name[1]);
1088 for (i=2 ; i<nummodels ; i++)
1090 CL_KeepaliveMessage();
1091 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
1092 Con_Printf("Model %s not found\n", cl.model_name[i]);
1096 for (i=1 ; i<numsounds ; i++)
1098 CL_KeepaliveMessage();
1100 // Don't lock the sfx here, S_ServerSounds already did that
1101 cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i], true, false);
1106 ent = &cl_entities[0];
1107 // entire entity array was cleared, so just fill in a few fields
1108 ent->state_current.active = true;
1109 ent->render.model = cl.worldmodel = cl.model_precache[1];
1110 ent->render.scale = 1; // some of the renderer still relies on scale
1111 ent->render.alpha = 1;
1112 ent->render.colormap = -1; // no special coloring
1113 ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
1114 Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, 0, 0, 0, 0, 0, 0, 1);
1115 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1116 CL_BoundingBoxForEntity(&ent->render);
1118 cl_num_entities = 1;
1123 // noclip is turned off at start
1124 noclip_anglehack = false;
1126 // check memory integrity
1127 Mem_CheckSentinelsGlobal();
1130 void CL_ValidateState(entity_state_t *s)
1137 if (s->modelindex >= MAX_MODELS && (65536-s->modelindex) >= MAX_MODELS)
1138 Host_Error("CL_ValidateState: modelindex (%i) >= MAX_MODELS (%i)\n", s->modelindex, MAX_MODELS);
1140 // colormap is client index + 1
1141 if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
1143 Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
1147 model = cl.model_precache[s->modelindex];
1148 if (model && model->type && s->frame >= model->numframes)
1150 Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
1153 if (model && model->type && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
1155 Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\" (which has %i skins)\n", s->skin, model->name, model->numskins);
1160 void CL_MoveLerpEntityStates(entity_t *ent)
1162 float odelta[3], adelta[3];
1163 CL_ValidateState(&ent->state_current);
1164 VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
1165 VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
1166 if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
1168 // reset all persistent stuff if this is a new entity
1169 ent->persistent.lerpdeltatime = 0;
1170 ent->persistent.lerpstarttime = cl.mtime[1];
1171 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1172 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1173 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1174 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1175 // reset animation interpolation as well
1176 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
1177 ent->render.frame1time = ent->render.frame2time = cl.time;
1178 ent->render.framelerp = 1;
1179 // reset various persistent stuff
1180 ent->persistent.muzzleflash = 0;
1181 VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
1183 else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000)
1185 // don't interpolate the move
1186 ent->persistent.lerpdeltatime = 0;
1187 ent->persistent.lerpstarttime = cl.mtime[1];
1188 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1189 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1190 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1191 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1193 else if (ent->state_current.flags & RENDER_STEP)
1195 // monster interpolation
1196 if (DotProduct(odelta, odelta) + DotProduct(adelta, adelta) > 0.01)
1198 ent->persistent.lerpdeltatime = bound(0, cl.mtime[1] - ent->persistent.lerpstarttime, 0.1);
1199 ent->persistent.lerpstarttime = cl.mtime[1];
1200 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1201 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1202 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1203 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1209 ent->persistent.lerpstarttime = ent->state_previous.time;
1210 // no lerp if it's singleplayer
1211 if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
1212 ent->persistent.lerpdeltatime = 0;
1214 ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
1215 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1216 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1217 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1218 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1227 void CL_ParseBaseline (entity_t *ent, int large)
1231 ent->state_baseline = defaultstate;
1232 // FIXME: set ent->state_baseline.number?
1233 ent->state_baseline.active = true;
1236 ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
1237 ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
1241 ent->state_baseline.modelindex = MSG_ReadByte ();
1242 ent->state_baseline.frame = MSG_ReadByte ();
1244 ent->state_baseline.colormap = MSG_ReadByte();
1245 ent->state_baseline.skin = MSG_ReadByte();
1246 for (i = 0;i < 3;i++)
1248 ent->state_baseline.origin[i] = MSG_ReadCoord(cls.protocol);
1249 ent->state_baseline.angles[i] = MSG_ReadAngle(cls.protocol);
1251 CL_ValidateState(&ent->state_baseline);
1252 ent->state_previous = ent->state_current = ent->state_baseline;
1260 Server information pertaining to this client only
1263 void CL_ParseClientdata (void)
1267 VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
1268 VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
1269 VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
1270 cl.mviewzoom[1] = cl.mviewzoom[0];
1272 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5)
1274 cl.stats[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
1275 cl.stats[STAT_ITEMS] = 0;
1276 cl.stats[STAT_VIEWZOOM] = 255;
1279 cl.mpunchangle[0][0] = 0;
1280 cl.mpunchangle[0][1] = 0;
1281 cl.mpunchangle[0][2] = 0;
1282 cl.mpunchvector[0][0] = 0;
1283 cl.mpunchvector[0][1] = 0;
1284 cl.mpunchvector[0][2] = 0;
1285 cl.mvelocity[0][0] = 0;
1286 cl.mvelocity[0][1] = 0;
1287 cl.mvelocity[0][2] = 0;
1288 cl.mviewzoom[0] = 1;
1290 bits = (unsigned short) MSG_ReadShort ();
1291 if (bits & SU_EXTEND1)
1292 bits |= (MSG_ReadByte() << 16);
1293 if (bits & SU_EXTEND2)
1294 bits |= (MSG_ReadByte() << 24);
1296 if (bits & SU_VIEWHEIGHT)
1297 cl.stats[STAT_VIEWHEIGHT] = MSG_ReadChar ();
1299 if (bits & SU_IDEALPITCH)
1300 cl.idealpitch = MSG_ReadChar ();
1302 for (i = 0;i < 3;i++)
1304 if (bits & (SU_PUNCH1<<i) )
1306 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
1307 cl.mpunchangle[0][i] = MSG_ReadChar();
1309 cl.mpunchangle[0][i] = MSG_ReadAngle16i();
1311 if (bits & (SU_PUNCHVEC1<<i))
1313 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1314 cl.mpunchvector[0][i] = MSG_ReadCoord16i();
1316 cl.mpunchvector[0][i] = MSG_ReadCoord32f();
1318 if (bits & (SU_VELOCITY1<<i) )
1320 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1321 cl.mvelocity[0][i] = MSG_ReadChar()*16;
1323 cl.mvelocity[0][i] = MSG_ReadCoord32f();
1327 // LordHavoc: hipnotic demos don't have this bit set but should
1328 if (bits & SU_ITEMS || cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4 || cls.protocol == PROTOCOL_DARKPLACES5)
1329 cl.stats[STAT_ITEMS] = MSG_ReadLong ();
1331 cl.onground = (bits & SU_ONGROUND) != 0;
1332 csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
1333 cl.inwater = (bits & SU_INWATER) != 0;
1335 if (cls.protocol == PROTOCOL_DARKPLACES5)
1337 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadShort() : 0;
1338 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadShort() : 0;
1339 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadShort() : 0;
1340 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1341 cl.stats[STAT_AMMO] = MSG_ReadShort();
1342 cl.stats[STAT_SHELLS] = MSG_ReadShort();
1343 cl.stats[STAT_NAILS] = MSG_ReadShort();
1344 cl.stats[STAT_ROCKETS] = MSG_ReadShort();
1345 cl.stats[STAT_CELLS] = MSG_ReadShort();
1346 cl.stats[STAT_ACTIVEWEAPON] = (unsigned short) MSG_ReadShort ();
1348 else if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE || cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1350 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadByte() : 0;
1351 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadByte() : 0;
1352 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadByte() : 0;
1353 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1354 cl.stats[STAT_AMMO] = MSG_ReadByte();
1355 cl.stats[STAT_SHELLS] = MSG_ReadByte();
1356 cl.stats[STAT_NAILS] = MSG_ReadByte();
1357 cl.stats[STAT_ROCKETS] = MSG_ReadByte();
1358 cl.stats[STAT_CELLS] = MSG_ReadByte();
1359 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
1360 cl.stats[STAT_ACTIVEWEAPON] = (1<<MSG_ReadByte ());
1362 cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte ();
1365 if (bits & SU_VIEWZOOM)
1367 if (cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1368 cl.stats[STAT_VIEWZOOM] = MSG_ReadByte();
1370 cl.stats[STAT_VIEWZOOM] = (unsigned short) MSG_ReadShort();
1373 // check for important changes
1376 if (cl.olditems != cl.stats[STAT_ITEMS])
1377 for (j = 0;j < 32;j++)
1378 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
1379 cl.item_gettime[j] = cl.time;
1380 cl.olditems = cl.stats[STAT_ITEMS];
1382 // GAME_NEXUIZ hud needs weapon change time
1383 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
1384 cl.weapontime = cl.time;
1385 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
1387 // viewzoom interpolation
1388 cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
1392 =====================
1394 =====================
1396 void CL_ParseStatic (int large)
1400 if (cl_num_static_entities >= cl_max_static_entities)
1401 Host_Error ("Too many static entities");
1402 ent = &cl_static_entities[cl_num_static_entities++];
1403 CL_ParseBaseline (ent, large);
1405 // copy it to the current state
1406 ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
1407 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_baseline.frame;
1408 ent->render.framelerp = 0;
1409 // make torchs play out of sync
1410 ent->render.frame1time = ent->render.frame2time = lhrandom(-10, -1);
1411 ent->render.colormap = -1; // no special coloring
1412 ent->render.skinnum = ent->state_baseline.skin;
1413 ent->render.effects = ent->state_baseline.effects;
1414 ent->render.alpha = 1;
1415 //ent->render.scale = 1;
1417 //VectorCopy (ent->state_baseline.origin, ent->render.origin);
1418 //VectorCopy (ent->state_baseline.angles, ent->render.angles);
1420 Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, ent->state_baseline.origin[0], ent->state_baseline.origin[1], ent->state_baseline.origin[2], ent->state_baseline.angles[0], ent->state_baseline.angles[1], ent->state_baseline.angles[2], 1);
1421 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1422 CL_BoundingBoxForEntity(&ent->render);
1424 // This is definitely cheating...
1425 if (ent->render.model == NULL)
1426 cl_num_static_entities--;
1434 void CL_ParseStaticSound (int large)
1437 int sound_num, vol, atten;
1439 MSG_ReadVector(org, cls.protocol);
1441 sound_num = (unsigned short) MSG_ReadShort ();
1443 sound_num = MSG_ReadByte ();
1444 vol = MSG_ReadByte ();
1445 atten = MSG_ReadByte ();
1447 S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
1450 void CL_ParseEffect (void)
1453 int modelindex, startframe, framecount, framerate;
1455 MSG_ReadVector(org, cls.protocol);
1456 modelindex = MSG_ReadByte ();
1457 startframe = MSG_ReadByte ();
1458 framecount = MSG_ReadByte ();
1459 framerate = MSG_ReadByte ();
1461 CL_Effect(org, modelindex, startframe, framecount, framerate);
1464 void CL_ParseEffect2 (void)
1467 int modelindex, startframe, framecount, framerate;
1469 MSG_ReadVector(org, cls.protocol);
1470 modelindex = (unsigned short) MSG_ReadShort ();
1471 startframe = (unsigned short) MSG_ReadShort ();
1472 framecount = MSG_ReadByte ();
1473 framerate = MSG_ReadByte ();
1475 CL_Effect(org, modelindex, startframe, framecount, framerate);
1478 void CL_ParseBeam (model_t *m, int lightning)
1484 ent = (unsigned short) MSG_ReadShort ();
1485 MSG_ReadVector(start, cls.protocol);
1486 MSG_ReadVector(end, cls.protocol);
1488 if (ent >= MAX_EDICTS)
1490 Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
1494 if (ent >= cl_max_entities)
1495 CL_ExpandEntities(ent);
1497 // override any beam with the same entity
1500 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1501 if (b->entity == ent)
1503 // if the entity was not found then just replace an unused beam
1504 if (i == cl_max_beams)
1505 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1506 if (!b->model || b->endtime < cl.time)
1508 if (i < cl_max_beams)
1511 b->lightning = lightning;
1513 b->endtime = cl.time + 0.2;
1514 VectorCopy (start, b->start);
1515 VectorCopy (end, b->end);
1516 b->relativestartvalid = 0;
1517 if (ent && cl_entities[ent].state_current.active)
1520 matrix4x4_t matrix, imatrix;
1521 if (ent == cl.viewentity && cl.movement)
1522 p = &cl_entities[b->entity].state_previous;
1524 p = &cl_entities[b->entity].state_current;
1525 // not really valid yet, we need to get the orientation now
1526 // (ParseBeam flagged this because it is received before
1527 // entities are received, by now they have been received)
1528 // note: because players create lightning in their think
1529 // function (which occurs before movement), they actually
1530 // have some lag in it's location, so compare to the
1531 // previous player state, not the latest
1532 Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
1533 Matrix4x4_Invert_Simple(&imatrix, &matrix);
1534 Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
1535 Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
1536 b->relativestartvalid = 1;
1540 Con_Print("beam list overflow!\n");
1543 void CL_ParseTempEntity(void)
1551 int colorStart, colorLength, count;
1552 float velspeed, radius;
1553 unsigned char *tempcolor;
1554 matrix4x4_t tempmatrix;
1556 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1558 type = MSG_ReadByte();
1561 case QW_TE_WIZSPIKE:
1562 // spike hitting wall
1563 MSG_ReadVector(pos, cls.protocol);
1564 CL_FindNonSolidLocation(pos, pos, 4);
1565 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1566 //CL_AllocDlight(NULL, &tempmatrix, 100, 0.12f, 0.50f, 0.12f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1567 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1568 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1571 case QW_TE_KNIGHTSPIKE:
1572 // spike hitting wall
1573 MSG_ReadVector(pos, cls.protocol);
1574 CL_FindNonSolidLocation(pos, pos, 4);
1575 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1576 //CL_AllocDlight(NULL, &tempmatrix, 100, 0.50f, 0.30f, 0.10f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1577 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1578 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1582 // spike hitting wall
1583 MSG_ReadVector(pos, cls.protocol);
1584 CL_FindNonSolidLocation(pos, pos, 4);
1585 if (cl_particles_quake.integer)
1586 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1587 else if (cl_particles_bulletimpacts.integer)
1589 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1590 CL_Smoke(pos, vec3_origin, 15, 0);
1594 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1599 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1601 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1603 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1606 case QW_TE_SUPERSPIKE:
1607 // super spike hitting wall
1608 MSG_ReadVector(pos, cls.protocol);
1609 CL_FindNonSolidLocation(pos, pos, 4);
1610 if (cl_particles_quake.integer)
1611 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1612 else if (cl_particles_bulletimpacts.integer)
1614 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1615 CL_Smoke(pos, vec3_origin, 30, 0);
1619 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1624 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1626 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1628 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1632 case QW_TE_EXPLOSION:
1634 MSG_ReadVector(pos, cls.protocol);
1635 CL_FindNonSolidLocation(pos, pos, 10);
1636 CL_ParticleExplosion(pos);
1637 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1638 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1639 CL_AllocDlight(NULL, &tempmatrix, 350, 4.0f, 2.0f, 0.50f, 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1640 if (gamemode != GAME_NEXUIZ)
1641 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1642 CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
1645 case QW_TE_TAREXPLOSION:
1646 // tarbaby explosion
1647 MSG_ReadVector(pos, cls.protocol);
1648 CL_FindNonSolidLocation(pos, pos, 10);
1649 CL_BlobExplosion(pos);
1651 if (gamemode != GAME_NEXUIZ)
1652 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1653 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1654 CL_AllocDlight(NULL, &tempmatrix, 600, 1.6f, 0.8f, 2.0f, 1200, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1657 case QW_TE_LIGHTNING1:
1659 CL_ParseBeam(cl.model_bolt, true);
1662 case QW_TE_LIGHTNING2:
1664 CL_ParseBeam(cl.model_bolt2, true);
1667 case QW_TE_LIGHTNING3:
1669 CL_ParseBeam(cl.model_bolt3, false);
1672 case QW_TE_LAVASPLASH:
1673 MSG_ReadVector(pos, cls.protocol);
1677 case QW_TE_TELEPORT:
1678 MSG_ReadVector(pos, cls.protocol);
1679 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1680 CL_AllocDlight(NULL, &tempmatrix, 200, 1.0f, 1.0f, 1.0f, 600, 99.0f, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1681 CL_TeleportSplash(pos);
1685 // bullet hitting wall
1686 radius = MSG_ReadByte();
1687 MSG_ReadVector(pos, cls.protocol);
1688 CL_FindNonSolidLocation(pos, pos, 4);
1689 if (cl_particles_quake.integer)
1690 CL_RunParticleEffect(pos, vec3_origin, 0, 20*radius);
1693 CL_SparkShower(pos, vec3_origin, 15*radius, 1, radius);
1694 CL_Smoke(pos, vec3_origin, 15*radius, radius);
1696 // TODO: scatter bullet marks throughout the sphere?
1701 count = MSG_ReadByte();
1702 MSG_ReadVector(pos, cls.protocol);
1703 CL_FindNonSolidLocation(pos, pos, 4);
1704 CL_BloodPuff(pos, vec3_origin, 20*count);
1707 case QW_TE_LIGHTNINGBLOOD:
1708 MSG_ReadVector(pos, cls.protocol);
1709 CL_FindNonSolidLocation(pos, pos, 4);
1710 CL_BloodPuff(pos, vec3_origin, 50);
1714 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
1719 type = MSG_ReadByte();
1723 // spike hitting wall
1724 MSG_ReadVector(pos, cls.protocol);
1725 CL_FindNonSolidLocation(pos, pos, 4);
1726 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1727 //CL_AllocDlight(NULL, &tempmatrix, 100, 0.12f, 0.50f, 0.12f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1728 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1729 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1732 case TE_KNIGHTSPIKE:
1733 // spike hitting wall
1734 MSG_ReadVector(pos, cls.protocol);
1735 CL_FindNonSolidLocation(pos, pos, 4);
1736 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1737 //CL_AllocDlight(NULL, &tempmatrix, 100, 0.50f, 0.30f, 0.10f, 500, 0.2, 0, -1, false, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1738 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1739 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1743 // spike hitting wall
1744 MSG_ReadVector(pos, cls.protocol);
1745 CL_FindNonSolidLocation(pos, pos, 4);
1746 if (cl_particles_quake.integer)
1747 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1748 else if (cl_particles_bulletimpacts.integer)
1750 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1751 CL_Smoke(pos, vec3_origin, 15, 0);
1755 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1760 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1762 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1764 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1768 // quad spike hitting wall
1769 MSG_ReadVector(pos, cls.protocol);
1770 CL_FindNonSolidLocation(pos, pos, 4);
1771 if (cl_particles_quake.integer)
1772 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1773 else if (cl_particles_bulletimpacts.integer)
1775 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1776 CL_Smoke(pos, vec3_origin, 15, 0);
1779 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1780 CL_AllocDlight(NULL, &tempmatrix, 100, 0.15f, 0.15f, 1.5f, 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1782 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1787 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1789 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1791 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1795 // super spike hitting wall
1796 MSG_ReadVector(pos, cls.protocol);
1797 CL_FindNonSolidLocation(pos, pos, 4);
1798 if (cl_particles_quake.integer)
1799 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1800 else if (cl_particles_bulletimpacts.integer)
1802 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1803 CL_Smoke(pos, vec3_origin, 30, 0);
1807 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1812 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1814 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1816 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1819 case TE_SUPERSPIKEQUAD:
1820 // quad super spike hitting wall
1821 MSG_ReadVector(pos, cls.protocol);
1822 CL_FindNonSolidLocation(pos, pos, 4);
1823 if (cl_particles_quake.integer)
1824 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1825 else if (cl_particles_bulletimpacts.integer)
1827 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1828 CL_Smoke(pos, vec3_origin, 30, 0);
1831 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1832 CL_AllocDlight(NULL, &tempmatrix, 100, 0.15f, 0.15f, 1.5f, 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1834 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1839 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1841 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1843 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1846 // LordHavoc: added for improved blood splatters
1849 MSG_ReadVector(pos, cls.protocol);
1850 CL_FindNonSolidLocation(pos, pos, 4);
1851 dir[0] = MSG_ReadChar();
1852 dir[1] = MSG_ReadChar();
1853 dir[2] = MSG_ReadChar();
1854 count = MSG_ReadByte();
1855 CL_BloodPuff(pos, dir, count);
1859 MSG_ReadVector(pos, cls.protocol);
1860 CL_FindNonSolidLocation(pos, pos, 4);
1861 dir[0] = MSG_ReadChar();
1862 dir[1] = MSG_ReadChar();
1863 dir[2] = MSG_ReadChar();
1864 count = MSG_ReadByte();
1865 CL_SparkShower(pos, dir, count, 1, 0);
1868 MSG_ReadVector(pos, cls.protocol);
1869 CL_FindNonSolidLocation(pos, pos, 4);
1870 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1871 CL_AllocDlight(NULL, &tempmatrix, 200, 1, 1, 1, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1874 // LordHavoc: added for improved gore
1875 case TE_BLOODSHOWER:
1877 MSG_ReadVector(pos, cls.protocol); // mins
1878 MSG_ReadVector(pos2, cls.protocol); // maxs
1879 velspeed = MSG_ReadCoord(cls.protocol); // speed
1880 count = (unsigned short) MSG_ReadShort(); // number of particles
1881 CL_BloodShower(pos, pos2, velspeed, count);
1883 case TE_PARTICLECUBE:
1884 // general purpose particle effect
1885 MSG_ReadVector(pos, cls.protocol); // mins
1886 MSG_ReadVector(pos2, cls.protocol); // maxs
1887 MSG_ReadVector(dir, cls.protocol); // dir
1888 count = (unsigned short) MSG_ReadShort(); // number of particles
1889 colorStart = MSG_ReadByte(); // color
1890 colorLength = MSG_ReadByte(); // gravity (1 or 0)
1891 velspeed = MSG_ReadCoord(cls.protocol); // randomvel
1892 CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength, velspeed);
1895 case TE_PARTICLERAIN:
1896 // general purpose particle effect
1897 MSG_ReadVector(pos, cls.protocol); // mins
1898 MSG_ReadVector(pos2, cls.protocol); // maxs
1899 MSG_ReadVector(dir, cls.protocol); // dir
1900 count = (unsigned short) MSG_ReadShort(); // number of particles
1901 colorStart = MSG_ReadByte(); // color
1902 CL_ParticleRain(pos, pos2, dir, count, colorStart, 0);
1905 case TE_PARTICLESNOW:
1906 // general purpose particle effect
1907 MSG_ReadVector(pos, cls.protocol); // mins
1908 MSG_ReadVector(pos2, cls.protocol); // maxs
1909 MSG_ReadVector(dir, cls.protocol); // dir
1910 count = (unsigned short) MSG_ReadShort(); // number of particles
1911 colorStart = MSG_ReadByte(); // color
1912 CL_ParticleRain(pos, pos2, dir, count, colorStart, 1);
1916 // bullet hitting wall
1917 MSG_ReadVector(pos, cls.protocol);
1918 CL_FindNonSolidLocation(pos, pos, 4);
1919 if (cl_particles_quake.integer)
1920 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1923 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1924 CL_Smoke(pos, vec3_origin, 15, 0);
1929 case TE_GUNSHOTQUAD:
1930 // quad bullet hitting wall
1931 MSG_ReadVector(pos, cls.protocol);
1932 CL_FindNonSolidLocation(pos, pos, 4);
1933 if (cl_particles_quake.integer)
1934 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1937 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1938 CL_Smoke(pos, vec3_origin, 15, 0);
1941 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1942 CL_AllocDlight(NULL, &tempmatrix, 100, 0.15f, 0.15f, 1.5f, 500, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1947 MSG_ReadVector(pos, cls.protocol);
1948 CL_FindNonSolidLocation(pos, pos, 10);
1949 CL_ParticleExplosion(pos);
1950 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1951 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1952 CL_AllocDlight(NULL, &tempmatrix, 350, 4.0f, 2.0f, 0.50f, 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1953 if (gamemode != GAME_NEXUIZ)
1954 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1957 case TE_EXPLOSIONQUAD:
1958 // quad rocket explosion
1959 MSG_ReadVector(pos, cls.protocol);
1960 CL_FindNonSolidLocation(pos, pos, 10);
1961 CL_ParticleExplosion(pos);
1962 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1963 CL_AllocDlight(NULL, &tempmatrix, 350, 2.5f, 2.0f, 4.0f, 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1964 if (gamemode != GAME_NEXUIZ)
1965 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1969 // Nehahra movie colored lighting explosion
1970 MSG_ReadVector(pos, cls.protocol);
1971 CL_FindNonSolidLocation(pos, pos, 10);
1972 CL_ParticleExplosion(pos);
1973 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1974 color[0] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1975 color[1] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1976 color[2] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1977 CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1978 if (gamemode != GAME_NEXUIZ)
1979 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1982 case TE_EXPLOSIONRGB:
1983 // colored lighting explosion
1984 MSG_ReadVector(pos, cls.protocol);
1985 CL_FindNonSolidLocation(pos, pos, 10);
1986 CL_ParticleExplosion(pos);
1987 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1988 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1989 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1990 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1991 CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1992 if (gamemode != GAME_NEXUIZ)
1993 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1996 case TE_TAREXPLOSION:
1997 // tarbaby explosion
1998 MSG_ReadVector(pos, cls.protocol);
1999 CL_FindNonSolidLocation(pos, pos, 10);
2000 CL_BlobExplosion(pos);
2002 if (gamemode != GAME_NEXUIZ)
2003 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2004 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2005 CL_AllocDlight(NULL, &tempmatrix, 600, 1.6f, 0.8f, 2.0f, 1200, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2009 MSG_ReadVector(pos, cls.protocol);
2010 CL_FindNonSolidLocation(pos, pos, 10);
2011 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2012 CL_AllocDlight(NULL, &tempmatrix, 200, 2, 2, 2, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2015 case TE_CUSTOMFLASH:
2016 MSG_ReadVector(pos, cls.protocol);
2017 CL_FindNonSolidLocation(pos, pos, 4);
2018 radius = (MSG_ReadByte() + 1) * 8;
2019 velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0);
2020 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
2021 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
2022 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
2023 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2024 CL_AllocDlight(NULL, &tempmatrix, radius, color[0], color[1], color[2], radius / velspeed, velspeed, 0, -1, true, 1, 0.25, 1, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2028 MSG_ReadVector(pos, cls.protocol);
2029 MSG_ReadVector(dir, cls.protocol);
2030 count = MSG_ReadByte();
2031 CL_Flames(pos, dir, count);
2036 CL_ParseBeam(cl.model_bolt, true);
2041 CL_ParseBeam(cl.model_bolt2, true);
2046 CL_ParseBeam(cl.model_bolt3, false);
2051 // grappling hook beam
2052 CL_ParseBeam(cl.model_beam, false);
2056 // LordHavoc: for compatibility with the Nehahra movie...
2057 case TE_LIGHTNING4NEH:
2058 CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false);
2062 MSG_ReadVector(pos, cls.protocol);
2067 MSG_ReadVector(pos, cls.protocol);
2068 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2069 CL_AllocDlight(NULL, &tempmatrix, 200, 1.0f, 1.0f, 1.0f, 600, 99.0f, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2070 CL_TeleportSplash(pos);
2074 // color mapped explosion
2075 MSG_ReadVector(pos, cls.protocol);
2076 CL_FindNonSolidLocation(pos, pos, 10);
2077 colorStart = MSG_ReadByte();
2078 colorLength = MSG_ReadByte();
2079 CL_ParticleExplosion2(pos, colorStart, colorLength);
2080 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
2081 color[0] = tempcolor[0] * (2.0f / 255.0f);
2082 color[1] = tempcolor[1] * (2.0f / 255.0f);
2083 color[2] = tempcolor[2] * (2.0f / 255.0f);
2084 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2085 CL_AllocDlight(NULL, &tempmatrix, 350, color[0], color[1], color[2], 700, 0.5, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2086 if (gamemode != GAME_NEXUIZ)
2087 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2091 MSG_ReadVector(pos, cls.protocol);
2092 MSG_ReadVector(pos2, cls.protocol);
2093 MSG_ReadVector(dir, cls.protocol);
2094 CL_BeamParticle(pos, pos2, 8, 1, 1, 1, 1, 1);
2098 MSG_ReadVector(pos, cls.protocol);
2099 MSG_ReadVector(dir, cls.protocol);
2100 count = MSG_ReadByte();
2101 CL_FindNonSolidLocation(pos, pos, 4);
2102 CL_Tei_Smoke(pos, dir, count);
2105 case TE_TEI_BIGEXPLOSION:
2106 MSG_ReadVector(pos, cls.protocol);
2107 CL_FindNonSolidLocation(pos, pos, 10);
2108 CL_ParticleExplosion(pos);
2109 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2110 CL_AllocDlight(NULL, &tempmatrix, 500, 2.5f, 2.0f, 1.0f, 500, 9999, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2111 if (gamemode != GAME_NEXUIZ)
2112 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2115 case TE_TEI_PLASMAHIT:
2116 MSG_ReadVector(pos, cls.protocol);
2117 MSG_ReadVector(dir, cls.protocol);
2118 count = MSG_ReadByte();
2119 CL_FindNonSolidLocation(pos, pos, 5);
2120 CL_Tei_PlasmaHit(pos, dir, count);
2121 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2122 CL_AllocDlight(NULL, &tempmatrix, 500, 0.6, 1.2, 2.0f, 2000, 9999, 0, -1, true, 1, 0.25, 0.25, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2126 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
2131 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
2134 void CL_VM_Init (void);
2135 qboolean CL_VM_Parse_TempEntity (void);
2136 void CL_VM_Parse_StuffCmd (const char *msg);
2137 void CL_VM_Parse_CenterPrint (const char *msg);
2138 void CSQC_AddPrintText (const char *msg);
2139 void CSQC_ReadEntities (void);
2141 static unsigned char cgamenetbuffer[65536];
2144 =====================
2145 CL_ParseServerMessage
2146 =====================
2148 int parsingerror = false;
2149 void CL_ParseServerMessage(void)
2153 protocolversion_t protocol;
2154 unsigned char cmdlog[32];
2155 char *cmdlogname[32], *temp;
2156 int cmdindex, cmdcount = 0;
2158 if (cls.demorecording)
2159 CL_WriteDemoMessage ();
2161 cl.last_received_message = realtime;
2164 // if recording demos, copy the message out
2166 if (cl_shownet.integer == 1)
2167 Con_Printf("%f %i\n", realtime, net_message.cursize);
2168 else if (cl_shownet.integer == 2)
2169 Con_Print("------------------\n");
2171 cl.onground = false; // unless the server says otherwise
2173 // parse the message
2175 //MSG_BeginReading ();
2177 parsingerror = true;
2179 if (cls.protocol == PROTOCOL_QUAKEWORLD)
2181 cl.mtime[1] = cl.mtime[0];
2182 cl.mtime[0] = realtime; // qw has no clock
2187 Host_Error ("CL_ParseServerMessage: Bad QW server message");
2189 cmd = MSG_ReadByte ();
2193 SHOWNET("END OF MESSAGE");
2194 break; // end of message
2197 cmdindex = cmdcount & 31;
2199 cmdlog[cmdindex] = cmd;
2201 SHOWNET(qw_svc_strings[cmd]);
2202 cmdlogname[cmdindex] = qw_svc_strings[cmd];
2203 if (!cmdlogname[cmdindex])
2205 // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
2207 cmdlogname[cmdindex] = temp;
2215 char description[32*64], temp[64];
2217 strcpy(description, "packet dump: ");
2221 count = cmdcount - i;
2225 dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2226 strlcat(description, temp, sizeof(description));
2231 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2232 Con_Print(description);
2233 Host_Error("CL_ParseServerMessage: Illegible server message");
2238 //Con_Printf("qw_svc_nop\n");
2241 case qw_svc_disconnect:
2242 Con_Printf("Server disconnected\n");
2243 if (cls.demonum != -1)
2252 CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
2254 CSQC_AddPrintText(MSG_ReadString());
2257 case qw_svc_centerprint:
2258 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2261 case qw_svc_stufftext:
2262 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2266 // svc_damage protocol is identical to nq
2270 case qw_svc_serverdata:
2271 //Cbuf_Execute(); // make sure any stuffed commands are done
2272 CL_ParseServerInfo();
2273 CL_VM_Init(); //[515]: init csqc
2276 case qw_svc_setangle:
2277 for (i=0 ; i<3 ; i++)
2278 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2281 case qw_svc_lightstyle:
2282 i = MSG_ReadByte ();
2283 if (i >= cl_max_lightstyle)
2285 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2288 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2289 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2290 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2294 CL_ParseStartSoundPacket(false);
2297 case qw_svc_stopsound:
2298 i = (unsigned short) MSG_ReadShort();
2299 S_StopSound(i>>3, i&7);
2302 case qw_svc_updatefrags:
2304 if (i >= cl.maxclients)
2305 Host_Error("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2306 cl.scores[i].frags = (signed short) MSG_ReadShort();
2309 case qw_svc_updateping:
2311 if (i >= cl.maxclients)
2312 Host_Error("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
2313 cl.scores[i].qw_ping = MSG_ReadShort();
2316 case qw_svc_updatepl:
2318 if (i >= cl.maxclients)
2319 Host_Error("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
2320 cl.scores[i].qw_packetloss = MSG_ReadByte();
2323 case qw_svc_updateentertime:
2325 if (i >= cl.maxclients)
2326 Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
2328 cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
2331 case qw_svc_spawnbaseline:
2332 i = (unsigned short) MSG_ReadShort();
2333 if (i < 0 || i >= MAX_EDICTS)
2334 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2335 if (i >= cl_max_entities)
2336 CL_ExpandEntities(i);
2337 CL_ParseBaseline(cl_entities + i, false);
2339 case qw_svc_spawnstatic:
2340 CL_ParseStatic(false);
2342 case qw_svc_temp_entity:
2343 if(!CL_VM_Parse_TempEntity())
2344 CL_ParseTempEntity ();
2347 case qw_svc_killedmonster:
2348 cl.stats[STAT_MONSTERS]++;
2351 case qw_svc_foundsecret:
2352 cl.stats[STAT_SECRETS]++;
2355 case qw_svc_updatestat:
2356 i = MSG_ReadByte ();
2357 if (i < 0 || i >= MAX_CL_STATS)
2358 Host_Error ("svc_updatestat: %i is invalid", i);
2359 cl.stats[i] = MSG_ReadByte ();
2362 case qw_svc_updatestatlong:
2363 i = MSG_ReadByte ();
2364 if (i < 0 || i >= MAX_CL_STATS)
2365 Host_Error ("svc_updatestatlong: %i is invalid", i);
2366 cl.stats[i] = MSG_ReadLong ();
2369 case qw_svc_spawnstaticsound:
2370 CL_ParseStaticSound (false);
2373 case qw_svc_cdtrack:
2374 cl.cdtrack = MSG_ReadByte ();
2375 cl.looptrack = MSG_ReadByte ();
2376 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2377 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2379 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2382 case qw_svc_intermission:
2383 cl.intermission = 1;
2384 cl.completed_time = cl.time;
2385 MSG_ReadVector(cl.qw_intermission_origin, cls.protocol);
2386 for (i = 0;i < 3;i++)
2387 cl.qw_intermission_angles[i] = MSG_ReadAngle(cls.protocol);
2391 cl.intermission = 2;
2392 cl.completed_time = cl.time;
2393 SCR_CenterPrint(MSG_ReadString ());
2396 case qw_svc_sellscreen:
2397 Cmd_ExecuteString ("help", src_command);
2400 case qw_svc_smallkick:
2401 Con_Printf("TODO: qw_svc_smallkick\n");
2403 case qw_svc_bigkick:
2404 Con_Printf("TODO: qw_svc_bigkick\n");
2407 case qw_svc_muzzleflash:
2408 i = (unsigned short) MSG_ReadShort();
2409 // NOTE: in QW this only worked on clients
2410 if (i < 0 || i >= MAX_EDICTS)
2411 Host_Error("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2412 if (i >= cl_max_entities)
2413 CL_ExpandEntities(i);
2414 cl_entities[i].persistent.muzzleflash = 1.0f;
2417 case qw_svc_updateuserinfo:
2418 QW_CL_UpdateUserInfo();
2421 case qw_svc_setinfo:
2425 case qw_svc_serverinfo:
2429 case qw_svc_download:
2430 QW_CL_ParseDownload();
2433 case qw_svc_playerinfo:
2434 EntityStateQW_ReadPlayerUpdate();
2441 case qw_svc_chokecount:
2443 // FIXME: apply to netgraph
2444 //for (j = 0;j < i;j++)
2445 // cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK].receivedtime = -2;
2448 case qw_svc_modellist:
2449 QW_CL_ParseModelList();
2452 case qw_svc_soundlist:
2453 QW_CL_ParseSoundList();
2456 case qw_svc_packetentities:
2457 EntityFrameQW_CL_ReadFrame(false);
2458 // first update is the final signon stage
2459 if (cls.signon == SIGNONS - 1)
2460 cls.signon = SIGNONS;
2463 case qw_svc_deltapacketentities:
2464 EntityFrameQW_CL_ReadFrame(true);
2465 // first update is the final signon stage
2466 if (cls.signon == SIGNONS - 1)
2467 cls.signon = SIGNONS;
2470 case qw_svc_maxspeed:
2471 cl.qw_movevars_maxspeed = MSG_ReadFloat();
2474 case qw_svc_entgravity:
2475 cl.qw_movevars_entgravity = MSG_ReadFloat();
2478 case qw_svc_setpause:
2479 cl.paused = MSG_ReadByte ();
2484 S_PauseGameSounds (cl.paused);
2488 QW_CL_UpdateItemsAndWeapon();
2495 Host_Error ("CL_ParseServerMessage: Bad server message");
2497 cmd = MSG_ReadByte ();
2501 SHOWNET("END OF MESSAGE");
2502 break; // end of message
2505 cmdindex = cmdcount & 31;
2507 cmdlog[cmdindex] = cmd;
2509 // if the high bit of the command byte is set, it is a fast update
2512 // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
2514 cmdlogname[cmdindex] = temp;
2515 SHOWNET("fast update");
2516 if (cls.signon == SIGNONS - 1)
2518 // first update is the final signon stage
2519 cls.signon = SIGNONS;
2522 EntityFrameQuake_ReadEntity (cmd&127);
2526 SHOWNET(svc_strings[cmd]);
2527 cmdlogname[cmdindex] = svc_strings[cmd];
2528 if (!cmdlogname[cmdindex])
2530 // LordHavoc: fix for bizarre problem in MSVC that I do not understand (if I assign the string pointer directly it ends up storing a NULL pointer)
2532 cmdlogname[cmdindex] = temp;
2540 char description[32*64], temp[64];
2542 strcpy (description, "packet dump: ");
2546 count = cmdcount - i;
2550 dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2551 strlcat (description, temp, sizeof (description));
2556 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2557 Con_Print(description);
2558 Host_Error ("CL_ParseServerMessage: Illegible server message");
2563 if (cls.signon < SIGNONS)
2564 Con_Print("<-- server to client keepalive\n");
2568 cl.mtime[1] = cl.mtime[0];
2569 cl.mtime[0] = MSG_ReadFloat ();
2570 cl.movement_needupdate = true;
2573 case svc_clientdata:
2574 CL_ParseClientdata();
2578 i = MSG_ReadLong ();
2579 protocol = Protocol_EnumForNumber(i);
2580 if (protocol == PROTOCOL_UNKNOWN)
2581 Host_Error("CL_ParseServerMessage: Server is unrecognized protocol number (%i)", i);
2582 // hack for unmarked Nehahra movie demos which had a custom protocol
2583 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
2584 protocol = PROTOCOL_NEHAHRAMOVIE;
2585 cls.protocol = protocol;
2588 case svc_disconnect:
2589 Con_Printf ("Server disconnected\n");
2590 if (cls.demonum != -1)
2597 CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
2600 case svc_centerprint:
2601 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2605 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2612 case svc_serverinfo:
2613 CL_ParseServerInfo ();
2614 CL_VM_Init(); //[515]: init csqc
2618 for (i=0 ; i<3 ; i++)
2619 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2623 cl.viewentity = (unsigned short)MSG_ReadShort ();
2624 if (cl.viewentity >= MAX_EDICTS)
2625 Host_Error("svc_setview >= MAX_EDICTS");
2626 if (cl.viewentity >= cl_max_entities)
2627 CL_ExpandEntities(cl.viewentity);
2628 // LordHavoc: assume first setview recieved is the real player entity
2629 if (!cl.playerentity)
2630 cl.playerentity = cl.viewentity;
2633 case svc_lightstyle:
2634 i = MSG_ReadByte ();
2635 if (i >= cl_max_lightstyle)
2637 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2640 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2641 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2642 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2646 CL_ParseStartSoundPacket(false);
2650 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2652 // was svc_sound2 in protocols 1, 2, 3, removed in 4, 5, changed to svc_precache in 6
2653 CL_ParseStartSoundPacket(true);
2657 int i = (unsigned short)MSG_ReadShort();
2658 char *s = MSG_ReadString();
2661 if (i >= 1 && i < MAX_MODELS)
2663 model_t *model = Mod_ForName(s, false, false, i == 1);
2665 Con_Printf("svc_precache: Mod_ForName(\"%s\") failed\n", s);
2666 cl.model_precache[i] = model;
2669 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_MODELS);
2674 if (i >= 1 && i < MAX_SOUNDS)
2676 sfx_t *sfx = S_PrecacheSound (s, true, false);
2677 if (!sfx && snd_initialized.integer)
2678 Con_Printf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s);
2679 cl.sound_precache[i] = sfx;
2682 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_SOUNDS);
2688 i = (unsigned short) MSG_ReadShort();
2689 S_StopSound(i>>3, i&7);
2692 case svc_updatename:
2693 i = MSG_ReadByte ();
2694 if (i >= cl.maxclients)
2695 Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
2696 strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
2699 case svc_updatefrags:
2700 i = MSG_ReadByte ();
2701 if (i >= cl.maxclients)
2702 Host_Error ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2703 cl.scores[i].frags = (signed short) MSG_ReadShort ();
2706 case svc_updatecolors:
2707 i = MSG_ReadByte ();
2708 if (i >= cl.maxclients)
2709 Host_Error ("CL_ParseServerMessage: svc_updatecolors >= cl.maxclients");
2710 cl.scores[i].colors = MSG_ReadByte ();
2714 CL_ParseParticleEffect ();
2725 case svc_spawnbaseline:
2726 i = (unsigned short) MSG_ReadShort ();
2727 if (i < 0 || i >= MAX_EDICTS)
2728 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2729 if (i >= cl_max_entities)
2730 CL_ExpandEntities(i);
2731 CL_ParseBaseline (cl_entities + i, false);
2733 case svc_spawnbaseline2:
2734 i = (unsigned short) MSG_ReadShort ();
2735 if (i < 0 || i >= MAX_EDICTS)
2736 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline2: invalid entity number %i", i);
2737 if (i >= cl_max_entities)
2738 CL_ExpandEntities(i);
2739 CL_ParseBaseline (cl_entities + i, true);
2741 case svc_spawnstatic:
2742 CL_ParseStatic (false);
2744 case svc_spawnstatic2:
2745 CL_ParseStatic (true);
2747 case svc_temp_entity:
2748 if(!CL_VM_Parse_TempEntity())
2749 CL_ParseTempEntity ();
2753 cl.paused = MSG_ReadByte ();
2758 S_PauseGameSounds (cl.paused);
2762 i = MSG_ReadByte ();
2763 // LordHavoc: it's rude to kick off the client if they missed the
2764 // reconnect somehow, so allow signon 1 even if at signon 1
2765 if (i <= cls.signon && i != 1)
2766 Host_Error ("Received signon %i when at %i", i, cls.signon);
2771 case svc_killedmonster:
2772 cl.stats[STAT_MONSTERS]++;
2775 case svc_foundsecret:
2776 cl.stats[STAT_SECRETS]++;
2779 case svc_updatestat:
2780 i = MSG_ReadByte ();
2781 if (i < 0 || i >= MAX_CL_STATS)
2782 Host_Error ("svc_updatestat: %i is invalid", i);
2783 cl.stats[i] = MSG_ReadLong ();
2786 case svc_updatestatubyte:
2787 i = MSG_ReadByte ();
2788 if (i < 0 || i >= MAX_CL_STATS)
2789 Host_Error ("svc_updatestat: %i is invalid", i);
2790 cl.stats[i] = MSG_ReadByte ();
2793 case svc_spawnstaticsound:
2794 CL_ParseStaticSound (false);
2797 case svc_spawnstaticsound2:
2798 CL_ParseStaticSound (true);
2802 cl.cdtrack = MSG_ReadByte ();
2803 cl.looptrack = MSG_ReadByte ();
2804 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2805 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2807 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2810 case svc_intermission:
2811 cl.intermission = 1;
2812 cl.completed_time = cl.time;
2816 cl.intermission = 2;
2817 cl.completed_time = cl.time;
2818 SCR_CenterPrint(MSG_ReadString ());
2822 cl.intermission = 3;
2823 cl.completed_time = cl.time;
2824 SCR_CenterPrint(MSG_ReadString ());
2827 case svc_sellscreen:
2828 Cmd_ExecuteString ("help", src_command);
2831 if (gamemode == GAME_TENEBRAE)
2833 // repeating particle effect
2834 MSG_ReadCoord(cls.protocol);
2835 MSG_ReadCoord(cls.protocol);
2836 MSG_ReadCoord(cls.protocol);
2837 MSG_ReadCoord(cls.protocol);
2838 MSG_ReadCoord(cls.protocol);
2839 MSG_ReadCoord(cls.protocol);
2846 SHOWLMP_decodehide();
2849 if (gamemode == GAME_TENEBRAE)
2852 MSG_ReadCoord(cls.protocol);
2853 MSG_ReadCoord(cls.protocol);
2854 MSG_ReadCoord(cls.protocol);
2859 SHOWLMP_decodeshow();
2862 R_SetSkyBox(MSG_ReadString());
2867 length = (int) ((unsigned short) MSG_ReadShort());
2868 for (i = 0;i < length;i++)
2869 cgamenetbuffer[i] = MSG_ReadByte();
2871 CL_CGVM_ParseNetwork(cgamenetbuffer, length);
2875 if (cls.signon == SIGNONS - 1)
2877 // first update is the final signon stage
2878 cls.signon = SIGNONS;
2881 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2882 EntityFrame_CL_ReadFrame();
2883 else if (cls.protocol == PROTOCOL_DARKPLACES4)
2884 EntityFrame4_CL_ReadFrame();
2886 EntityFrame5_CL_ReadFrame();
2888 case svc_csqcentities:
2889 CSQC_ReadEntities();
2895 EntityFrameQuake_ISeeDeadEntities();
2897 parsingerror = false;
2900 void CL_Parse_DumpPacket(void)
2904 Con_Print("Packet dump:\n");
2905 SZ_HexDumpToConsole(&net_message);
2906 parsingerror = false;
2909 void CL_Parse_ErrorCleanUp(void)
2911 if (cls.qw_downloadmemory)
2913 Mem_Free(cls.qw_downloadmemory);
2914 cls.qw_downloadmemory = NULL;
2916 cls.qw_downloadpercent = 0;
2920 void CL_Parse_Init(void)
2922 // LordHavoc: added demo_nehahra cvar
2923 Cvar_RegisterVariable (&demo_nehahra);
2924 if (gamemode == GAME_NEHAHRA)
2925 Cvar_SetValue("demo_nehahra", 1);
2926 Cvar_RegisterVariable(&developer_networkentities);
2928 Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
2929 Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
2932 void CL_Parse_Shutdown(void)