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("prespawn %i 0 %i", cl.qw_servercount, cl.worldmodel->checksum2));
459 MSG_WriteString(&cls.netcon->message, va("prespawn %i 0 %i", 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(va("sound/%s", 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("modellist %i %i", 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]));
602 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
603 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, n));
607 cls.qw_downloadnumber = 0;
608 cls.qw_downloadtype = dl_model;
609 QW_CL_RequestNextDownload();
612 static void QW_CL_ParseSoundList(void)
615 int numsounds = MSG_ReadByte();
618 // parse sound precache list
621 str = MSG_ReadString();
625 if (numsounds==MAX_SOUNDS)
626 Host_Error("Server sent too many sound precaches");
627 if (strlen(str) >= MAX_QPATH)
628 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
629 strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
636 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
637 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, n));
641 cls.qw_downloadnumber = 0;
642 cls.qw_downloadtype = dl_sound;
643 QW_CL_RequestNextDownload();
646 void QW_CL_NextUpload(void)
648 int r, percent, size;
650 if (!cls.qw_uploaddata)
653 r = cls.qw_uploadsize - cls.qw_uploadpos;
656 size = min(1, cls.qw_uploadsize);
657 percent = (cls.qw_uploadpos+r)*100/size;
659 MSG_WriteByte(&cls.netcon->message, qw_clc_upload);
660 MSG_WriteShort(&cls.netcon->message, r);
661 MSG_WriteByte(&cls.netcon->message, percent);
662 SZ_Write(&cls.netcon->message, cls.qw_uploaddata + cls.qw_uploadpos, r);
664 Con_DPrintf("UPLOAD: %6d: %d written\n", cls.qw_uploadpos, r);
666 cls.qw_uploadpos += r;
668 if (cls.qw_uploadpos < cls.qw_uploadsize)
671 Con_Printf("Upload completed\n");
676 void QW_CL_StartUpload(unsigned char *data, int size)
678 // do nothing in demos or if not connected
682 // abort existing upload if in progress
685 Con_DPrintf("Starting upload of %d bytes...\n", size);
687 cls.qw_uploaddata = Mem_Alloc(cl_mempool, size);
688 memcpy(cls.qw_uploaddata, data, size);
689 cls.qw_uploadsize = size;
690 cls.qw_uploadpos = 0;
696 qboolean QW_CL_IsUploading(void)
698 return cls.qw_uploaddata != NULL;
702 void QW_CL_StopUpload(void)
704 if (cls.qw_uploaddata)
705 Mem_Free(cls.qw_uploaddata);
706 cls.qw_uploaddata = NULL;
707 cls.qw_uploadsize = 0;
708 cls.qw_uploadpos = 0;
711 static void QW_CL_ProcessUserInfo(int slot)
713 int topcolor, bottomcolor;
715 InfoString_GetValue(cl.scores[slot].qw_userinfo, "name", cl.scores[slot].name, sizeof(cl.scores[slot].name));
716 InfoString_GetValue(cl.scores[slot].qw_userinfo, "topcolor", temp, sizeof(temp));topcolor = atoi(temp);
717 InfoString_GetValue(cl.scores[slot].qw_userinfo, "bottomcolor", temp, sizeof(temp));bottomcolor = atoi(temp);
718 cl.scores[slot].colors = topcolor * 16 + bottomcolor;
719 InfoString_GetValue(cl.scores[slot].qw_userinfo, "*spectator", temp, sizeof(temp));
720 cl.scores[slot].qw_spectator = temp[0] != 0;
721 InfoString_GetValue(cl.scores[slot].qw_userinfo, "skin", cl.scores[slot].qw_skin, sizeof(cl.scores[slot].qw_skin));
722 // LordHavoc: abusing Draw_CachePic for caching skins...
723 cl.scores[slot].qw_skin_cachepic = Draw_CachePic(cl.scores[slot].qw_skin, true);
726 static void QW_CL_UpdateUserInfo(void)
729 slot = MSG_ReadByte();
730 if (slot >= cl.maxclients)
732 Con_Printf("svc_updateuserinfo >= cl.maxclients\n");
737 cl.scores[slot].qw_userid = MSG_ReadLong();
738 strlcpy(cl.scores[slot].qw_userinfo, MSG_ReadString(), sizeof(cl.scores[slot].qw_userinfo));
740 QW_CL_ProcessUserInfo(slot);
743 static void QW_CL_SetInfo(void)
748 slot = MSG_ReadByte();
749 strlcpy(key, MSG_ReadString(), sizeof(key));
750 strlcpy(value, MSG_ReadString(), sizeof(value));
751 if (slot >= cl.maxclients)
753 Con_Printf("svc_setinfo >= cl.maxclients\n");
756 InfoString_SetValue(cl.scores[slot].qw_userinfo, sizeof(cl.scores[slot].qw_userinfo), key, value);
758 QW_CL_ProcessUserInfo(slot);
761 static void QW_CL_ServerInfo(void)
765 strlcpy(key, MSG_ReadString(), sizeof(key));
766 strlcpy(value, MSG_ReadString(), sizeof(value));
767 Con_DPrintf("SERVERINFO: %s=%s\n", key, value);
768 InfoString_SetValue(cl.qw_serverinfo, sizeof(cl.qw_serverinfo), key, value);
771 static void QW_CL_ParseNails(void)
774 int numnails = MSG_ReadByte();
776 unsigned char bits[6];
778 for (i = 0;i < numnails;i++)
780 v = cl.qw_nails[cl.qw_num_nails++];
781 for (j = 0;j < 6;j++)
782 bits[j] = MSG_ReadByte();
783 v[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096;
784 v[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096;
785 v[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096;
786 v[3] = 360*(bits[4]>>4)/16;
787 v[4] = 360*bits[5]/256;
792 static void QW_CL_UpdateItemsAndWeapon(void)
795 // check for important changes
798 if (cl.olditems != cl.stats[STAT_ITEMS])
799 for (j = 0;j < 32;j++)
800 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
801 cl.item_gettime[j] = cl.time;
802 cl.olditems = cl.stats[STAT_ITEMS];
804 // GAME_NEXUIZ hud needs weapon change time
805 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
806 cl.weapontime = cl.time;
807 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
811 =====================
814 An svc_signonnum has been received, perform a client side setup
815 =====================
817 static void CL_SignonReply (void)
819 Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
826 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
827 MSG_WriteString (&cls.netcon->message, "prespawn");
834 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
835 MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
837 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
838 MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
840 if (cl_pmodel.integer)
842 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
843 MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
845 if (*cl_playermodel.string)
847 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
848 MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
850 if (*cl_playerskin.string)
852 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
853 MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
856 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
857 MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
859 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
860 MSG_WriteString (&cls.netcon->message, "spawn");
867 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
868 MSG_WriteString (&cls.netcon->message, "begin");
883 void CL_ParseServerInfo (void)
887 protocolversion_t protocol;
888 int nummodels, numsounds;
891 Con_DPrint("Serverinfo packet received.\n");
893 // check memory integrity
894 Mem_CheckSentinelsGlobal();
897 // wipe the client_state_t struct
901 // parse protocol version number
903 protocol = Protocol_EnumForNumber(i);
904 if (protocol == PROTOCOL_UNKNOWN)
906 Host_Error("CL_ParseServerInfo: Server is unrecognized protocol number (%i)", i);
909 // hack for unmarked Nehahra movie demos which had a custom protocol
910 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
911 protocol = PROTOCOL_NEHAHRAMOVIE;
912 cls.protocol = protocol;
913 Con_DPrintf("Server protocol is %s\n", Protocol_NameForEnum(cls.protocol));
915 if (protocol == PROTOCOL_QUAKEWORLD)
917 cl.qw_servercount = MSG_ReadLong();
919 str = MSG_ReadString();
920 Con_Printf("server gamedir is %s\n", str);
922 // FIXME: change gamedir if needed!
923 if (strcasecmp(gamedirfile, str))
929 Com_Gamedir(str); // change gamedir
933 // exec the new config stuff
937 cl.gametype = GAME_DEATHMATCH;
940 // parse player number
942 cl.qw_spectator = (i & 128) != 0;
943 cl.playerentity = cl.viewentity = (i & 127) + 1;
944 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
946 // get the full level name
947 str = MSG_ReadString ();
948 strlcpy (cl.levelname, str, sizeof(cl.levelname));
951 cl.qw_movevars_gravity = MSG_ReadFloat();
952 cl.qw_movevars_stopspeed = MSG_ReadFloat();
953 cl.qw_movevars_maxspeed = MSG_ReadFloat();
954 cl.qw_movevars_spectatormaxspeed = MSG_ReadFloat();
955 cl.qw_movevars_accelerate = MSG_ReadFloat();
956 cl.qw_movevars_airaccelerate = MSG_ReadFloat();
957 cl.qw_movevars_wateraccelerate = MSG_ReadFloat();
958 cl.qw_movevars_friction = MSG_ReadFloat();
959 cl.qw_movevars_waterfriction = MSG_ReadFloat();
960 cl.qw_movevars_entgravity = MSG_ReadFloat();
962 // seperate the printfs so the server message can have a color
963 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);
965 // check memory integrity
966 Mem_CheckSentinelsGlobal();
969 // if server is active, we already began a loading plaque
971 SCR_BeginLoadingPlaque();
973 // disable until we get textures for it
976 memset(cl.csqc_model_precache, 0, sizeof(cl.csqc_model_precache)); //[515]: csqc
977 memset(cl.model_precache, 0, sizeof(cl.model_precache));
978 memset(cl.sound_precache, 0, sizeof(cl.sound_precache));
980 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
981 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, 0));
983 cls.state = ca_connected;
989 cl.maxclients = MSG_ReadByte ();
990 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
992 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
995 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
998 cl.gametype = MSG_ReadByte ();
1000 // parse signon message
1001 str = MSG_ReadString ();
1002 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1004 // seperate the printfs so the server message can have a color
1005 if (cls.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
1006 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);
1008 // check memory integrity
1009 Mem_CheckSentinelsGlobal();
1012 // if server is active, we already began a loading plaque
1014 SCR_BeginLoadingPlaque();
1016 // disable until we get textures for it
1019 memset(cl.csqc_model_precache, 0, sizeof(cl.csqc_model_precache)); //[515]: csqc
1020 memset(cl.model_precache, 0, sizeof(cl.model_precache));
1021 memset(cl.sound_precache, 0, sizeof(cl.sound_precache));
1023 // parse model precache list
1024 for (nummodels=1 ; ; nummodels++)
1026 str = MSG_ReadString();
1029 if (nummodels==MAX_MODELS)
1030 Host_Error ("Server sent too many model precaches");
1031 if (strlen(str) >= MAX_QPATH)
1032 Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1033 strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
1035 // parse sound precache list
1036 for (numsounds=1 ; ; numsounds++)
1038 str = MSG_ReadString();
1041 if (numsounds==MAX_SOUNDS)
1042 Host_Error("Server sent too many sound precaches");
1043 if (strlen(str) >= MAX_QPATH)
1044 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1045 strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
1048 // touch all of the precached models that are still loaded so we can free
1049 // anything that isn't needed
1051 for (i = 1;i < nummodels;i++)
1052 Mod_FindName(cl.model_name[i]);
1053 // precache any models used by the client (this also marks them used)
1054 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
1055 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
1056 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
1057 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
1060 // do the same for sounds
1061 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
1062 S_ServerSounds (cl.sound_name, numsounds);
1064 // precache any sounds used by the client
1065 cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
1066 cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
1067 cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
1068 cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
1069 cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
1070 cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
1071 cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
1073 // now we try to load everything that is new
1076 CL_KeepaliveMessage ();
1077 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
1078 if (cl.model_precache[1]->Draw == NULL)
1079 Con_Printf("Map %s not found\n", cl.model_name[1]);
1082 for (i=2 ; i<nummodels ; i++)
1084 CL_KeepaliveMessage();
1085 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
1086 Con_Printf("Model %s not found\n", cl.model_name[i]);
1090 for (i=1 ; i<numsounds ; i++)
1092 CL_KeepaliveMessage();
1094 // Don't lock the sfx here, S_ServerSounds already did that
1095 cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i], true, false);
1100 ent = &cl_entities[0];
1101 // entire entity array was cleared, so just fill in a few fields
1102 ent->state_current.active = true;
1103 ent->render.model = cl.worldmodel = cl.model_precache[1];
1104 ent->render.scale = 1; // some of the renderer still relies on scale
1105 ent->render.alpha = 1;
1106 ent->render.colormap = -1; // no special coloring
1107 ent->render.flags = RENDER_SHADOW | RENDER_LIGHT;
1108 Matrix4x4_CreateFromQuakeEntity(&ent->render.matrix, 0, 0, 0, 0, 0, 0, 1);
1109 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1110 CL_BoundingBoxForEntity(&ent->render);
1112 cl_num_entities = 1;
1117 // noclip is turned off at start
1118 noclip_anglehack = false;
1120 // check memory integrity
1121 Mem_CheckSentinelsGlobal();
1124 void CL_ValidateState(entity_state_t *s)
1131 if (s->modelindex >= MAX_MODELS && (65536-s->modelindex) >= MAX_MODELS)
1132 Host_Error("CL_ValidateState: modelindex (%i) >= MAX_MODELS (%i)\n", s->modelindex, MAX_MODELS);
1134 // colormap is client index + 1
1135 if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
1137 Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
1141 model = cl.model_precache[s->modelindex];
1142 if (model && model->type && s->frame >= model->numframes)
1144 Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
1147 if (model && model->type && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
1149 Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\" (which has %i skins)\n", s->skin, model->name, model->numskins);
1154 void CL_MoveLerpEntityStates(entity_t *ent)
1156 float odelta[3], adelta[3];
1157 CL_ValidateState(&ent->state_current);
1158 VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
1159 VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
1160 if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
1162 // reset all persistent stuff if this is a new entity
1163 ent->persistent.lerpdeltatime = 0;
1164 ent->persistent.lerpstarttime = cl.mtime[1];
1165 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1166 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1167 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1168 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1169 // reset animation interpolation as well
1170 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
1171 ent->render.frame1time = ent->render.frame2time = cl.time;
1172 ent->render.framelerp = 1;
1173 // reset various persistent stuff
1174 ent->persistent.muzzleflash = 0;
1175 VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
1177 else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000)
1179 // don't interpolate the move
1180 ent->persistent.lerpdeltatime = 0;
1181 ent->persistent.lerpstarttime = cl.mtime[1];
1182 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1183 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1184 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1185 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1187 else if (ent->state_current.flags & RENDER_STEP)
1189 // monster interpolation
1190 if (DotProduct(odelta, odelta) + DotProduct(adelta, adelta) > 0.01)
1192 ent->persistent.lerpdeltatime = bound(0, cl.mtime[1] - ent->persistent.lerpstarttime, 0.1);
1193 ent->persistent.lerpstarttime = cl.mtime[1];
1194 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1195 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1196 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1197 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1203 ent->persistent.lerpstarttime = ent->state_previous.time;
1204 // no lerp if it's singleplayer
1205 if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
1206 ent->persistent.lerpdeltatime = 0;
1208 ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
1209 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1210 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1211 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1212 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1221 void CL_ParseBaseline (entity_t *ent, int large)
1225 ent->state_baseline = defaultstate;
1226 // FIXME: set ent->state_baseline.number?
1227 ent->state_baseline.active = true;
1230 ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
1231 ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
1235 ent->state_baseline.modelindex = MSG_ReadByte ();
1236 ent->state_baseline.frame = MSG_ReadByte ();
1238 ent->state_baseline.colormap = MSG_ReadByte();
1239 ent->state_baseline.skin = MSG_ReadByte();
1240 for (i = 0;i < 3;i++)
1242 ent->state_baseline.origin[i] = MSG_ReadCoord(cls.protocol);
1243 ent->state_baseline.angles[i] = MSG_ReadAngle(cls.protocol);
1245 CL_ValidateState(&ent->state_baseline);
1246 ent->state_previous = ent->state_current = ent->state_baseline;
1254 Server information pertaining to this client only
1257 void CL_ParseClientdata (void)
1261 VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
1262 VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
1263 VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
1264 cl.mviewzoom[1] = cl.mviewzoom[0];
1266 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)
1268 cl.stats[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
1269 cl.stats[STAT_ITEMS] = 0;
1270 cl.stats[STAT_VIEWZOOM] = 255;
1273 cl.mpunchangle[0][0] = 0;
1274 cl.mpunchangle[0][1] = 0;
1275 cl.mpunchangle[0][2] = 0;
1276 cl.mpunchvector[0][0] = 0;
1277 cl.mpunchvector[0][1] = 0;
1278 cl.mpunchvector[0][2] = 0;
1279 cl.mvelocity[0][0] = 0;
1280 cl.mvelocity[0][1] = 0;
1281 cl.mvelocity[0][2] = 0;
1282 cl.mviewzoom[0] = 1;
1284 bits = (unsigned short) MSG_ReadShort ();
1285 if (bits & SU_EXTEND1)
1286 bits |= (MSG_ReadByte() << 16);
1287 if (bits & SU_EXTEND2)
1288 bits |= (MSG_ReadByte() << 24);
1290 if (bits & SU_VIEWHEIGHT)
1291 cl.stats[STAT_VIEWHEIGHT] = MSG_ReadChar ();
1293 if (bits & SU_IDEALPITCH)
1294 cl.idealpitch = MSG_ReadChar ();
1296 for (i = 0;i < 3;i++)
1298 if (bits & (SU_PUNCH1<<i) )
1300 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
1301 cl.mpunchangle[0][i] = MSG_ReadChar();
1303 cl.mpunchangle[0][i] = MSG_ReadAngle16i();
1305 if (bits & (SU_PUNCHVEC1<<i))
1307 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1308 cl.mpunchvector[0][i] = MSG_ReadCoord16i();
1310 cl.mpunchvector[0][i] = MSG_ReadCoord32f();
1312 if (bits & (SU_VELOCITY1<<i) )
1314 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)
1315 cl.mvelocity[0][i] = MSG_ReadChar()*16;
1317 cl.mvelocity[0][i] = MSG_ReadCoord32f();
1321 // LordHavoc: hipnotic demos don't have this bit set but should
1322 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)
1323 cl.stats[STAT_ITEMS] = MSG_ReadLong ();
1325 cl.onground = (bits & SU_ONGROUND) != 0;
1326 csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
1327 cl.inwater = (bits & SU_INWATER) != 0;
1329 if (cls.protocol == PROTOCOL_DARKPLACES5)
1331 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadShort() : 0;
1332 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadShort() : 0;
1333 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadShort() : 0;
1334 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1335 cl.stats[STAT_AMMO] = MSG_ReadShort();
1336 cl.stats[STAT_SHELLS] = MSG_ReadShort();
1337 cl.stats[STAT_NAILS] = MSG_ReadShort();
1338 cl.stats[STAT_ROCKETS] = MSG_ReadShort();
1339 cl.stats[STAT_CELLS] = MSG_ReadShort();
1340 cl.stats[STAT_ACTIVEWEAPON] = (unsigned short) MSG_ReadShort ();
1342 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)
1344 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadByte() : 0;
1345 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadByte() : 0;
1346 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadByte() : 0;
1347 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1348 cl.stats[STAT_AMMO] = MSG_ReadByte();
1349 cl.stats[STAT_SHELLS] = MSG_ReadByte();
1350 cl.stats[STAT_NAILS] = MSG_ReadByte();
1351 cl.stats[STAT_ROCKETS] = MSG_ReadByte();
1352 cl.stats[STAT_CELLS] = MSG_ReadByte();
1353 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
1354 cl.stats[STAT_ACTIVEWEAPON] = (1<<MSG_ReadByte ());
1356 cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte ();
1359 if (bits & SU_VIEWZOOM)
1361 if (cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1362 cl.stats[STAT_VIEWZOOM] = MSG_ReadByte();
1364 cl.stats[STAT_VIEWZOOM] = (unsigned short) MSG_ReadShort();
1367 // check for important changes
1370 if (cl.olditems != cl.stats[STAT_ITEMS])
1371 for (j = 0;j < 32;j++)
1372 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
1373 cl.item_gettime[j] = cl.time;
1374 cl.olditems = cl.stats[STAT_ITEMS];
1376 // GAME_NEXUIZ hud needs weapon change time
1377 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
1378 cl.weapontime = cl.time;
1379 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
1381 // viewzoom interpolation
1382 cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
1386 =====================
1388 =====================
1390 void CL_ParseStatic (int large)
1394 if (cl_num_static_entities >= cl_max_static_entities)
1395 Host_Error ("Too many static entities");
1396 ent = &cl_static_entities[cl_num_static_entities++];
1397 CL_ParseBaseline (ent, large);
1399 // copy it to the current state
1400 ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
1401 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_baseline.frame;
1402 ent->render.framelerp = 0;
1403 // make torchs play out of sync
1404 ent->render.frame1time = ent->render.frame2time = lhrandom(-10, -1);
1405 ent->render.colormap = -1; // no special coloring
1406 ent->render.skinnum = ent->state_baseline.skin;
1407 ent->render.effects = ent->state_baseline.effects;
1408 ent->render.alpha = 1;
1409 //ent->render.scale = 1;
1411 //VectorCopy (ent->state_baseline.origin, ent->render.origin);
1412 //VectorCopy (ent->state_baseline.angles, ent->render.angles);
1414 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);
1415 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1416 CL_BoundingBoxForEntity(&ent->render);
1418 // This is definitely cheating...
1419 if (ent->render.model == NULL)
1420 cl_num_static_entities--;
1428 void CL_ParseStaticSound (int large)
1431 int sound_num, vol, atten;
1433 MSG_ReadVector(org, cls.protocol);
1435 sound_num = (unsigned short) MSG_ReadShort ();
1437 sound_num = MSG_ReadByte ();
1438 vol = MSG_ReadByte ();
1439 atten = MSG_ReadByte ();
1441 S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
1444 void CL_ParseEffect (void)
1447 int modelindex, startframe, framecount, framerate;
1449 MSG_ReadVector(org, cls.protocol);
1450 modelindex = MSG_ReadByte ();
1451 startframe = MSG_ReadByte ();
1452 framecount = MSG_ReadByte ();
1453 framerate = MSG_ReadByte ();
1455 CL_Effect(org, modelindex, startframe, framecount, framerate);
1458 void CL_ParseEffect2 (void)
1461 int modelindex, startframe, framecount, framerate;
1463 MSG_ReadVector(org, cls.protocol);
1464 modelindex = (unsigned short) MSG_ReadShort ();
1465 startframe = (unsigned short) MSG_ReadShort ();
1466 framecount = MSG_ReadByte ();
1467 framerate = MSG_ReadByte ();
1469 CL_Effect(org, modelindex, startframe, framecount, framerate);
1472 void CL_ParseBeam (model_t *m, int lightning)
1478 ent = (unsigned short) MSG_ReadShort ();
1479 MSG_ReadVector(start, cls.protocol);
1480 MSG_ReadVector(end, cls.protocol);
1482 if (ent >= MAX_EDICTS)
1484 Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
1488 if (ent >= cl_max_entities)
1489 CL_ExpandEntities(ent);
1491 // override any beam with the same entity
1494 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1495 if (b->entity == ent)
1497 // if the entity was not found then just replace an unused beam
1498 if (i == cl_max_beams)
1499 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1500 if (!b->model || b->endtime < cl.time)
1502 if (i < cl_max_beams)
1505 b->lightning = lightning;
1507 b->endtime = cl.time + 0.2;
1508 VectorCopy (start, b->start);
1509 VectorCopy (end, b->end);
1510 b->relativestartvalid = 0;
1511 if (ent && cl_entities[ent].state_current.active)
1514 matrix4x4_t matrix, imatrix;
1515 if (ent == cl.viewentity && cl.movement)
1516 p = &cl_entities[b->entity].state_previous;
1518 p = &cl_entities[b->entity].state_current;
1519 // not really valid yet, we need to get the orientation now
1520 // (ParseBeam flagged this because it is received before
1521 // entities are received, by now they have been received)
1522 // note: because players create lightning in their think
1523 // function (which occurs before movement), they actually
1524 // have some lag in it's location, so compare to the
1525 // previous player state, not the latest
1526 Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
1527 Matrix4x4_Invert_Simple(&imatrix, &matrix);
1528 Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
1529 Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
1530 b->relativestartvalid = 1;
1534 Con_Print("beam list overflow!\n");
1537 void CL_ParseTempEntity(void)
1545 int colorStart, colorLength, count;
1546 float velspeed, radius;
1547 unsigned char *tempcolor;
1548 matrix4x4_t tempmatrix;
1550 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1552 type = MSG_ReadByte();
1555 case QW_TE_WIZSPIKE:
1556 // spike hitting wall
1557 MSG_ReadVector(pos, cls.protocol);
1558 CL_FindNonSolidLocation(pos, pos, 4);
1559 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1560 //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);
1561 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1562 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1565 case QW_TE_KNIGHTSPIKE:
1566 // spike hitting wall
1567 MSG_ReadVector(pos, cls.protocol);
1568 CL_FindNonSolidLocation(pos, pos, 4);
1569 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1570 //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);
1571 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1572 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1576 // spike hitting wall
1577 MSG_ReadVector(pos, cls.protocol);
1578 CL_FindNonSolidLocation(pos, pos, 4);
1579 if (cl_particles_quake.integer)
1580 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1581 else if (cl_particles_bulletimpacts.integer)
1583 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1584 CL_Smoke(pos, vec3_origin, 15, 0);
1588 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1593 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1595 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1597 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1600 case QW_TE_SUPERSPIKE:
1601 // super spike hitting wall
1602 MSG_ReadVector(pos, cls.protocol);
1603 CL_FindNonSolidLocation(pos, pos, 4);
1604 if (cl_particles_quake.integer)
1605 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1606 else if (cl_particles_bulletimpacts.integer)
1608 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1609 CL_Smoke(pos, vec3_origin, 30, 0);
1613 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1618 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1620 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1622 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1626 case QW_TE_EXPLOSION:
1628 MSG_ReadVector(pos, cls.protocol);
1629 CL_FindNonSolidLocation(pos, pos, 10);
1630 CL_ParticleExplosion(pos);
1631 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1632 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1633 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);
1634 if (gamemode != GAME_NEXUIZ)
1635 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1636 CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
1639 case QW_TE_TAREXPLOSION:
1640 // tarbaby explosion
1641 MSG_ReadVector(pos, cls.protocol);
1642 CL_FindNonSolidLocation(pos, pos, 10);
1643 CL_BlobExplosion(pos);
1645 if (gamemode != GAME_NEXUIZ)
1646 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1647 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1648 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);
1651 case QW_TE_LIGHTNING1:
1653 CL_ParseBeam(cl.model_bolt, true);
1656 case QW_TE_LIGHTNING2:
1658 CL_ParseBeam(cl.model_bolt2, true);
1661 case QW_TE_LIGHTNING3:
1663 CL_ParseBeam(cl.model_bolt3, false);
1666 case QW_TE_LAVASPLASH:
1667 MSG_ReadVector(pos, cls.protocol);
1671 case QW_TE_TELEPORT:
1672 MSG_ReadVector(pos, cls.protocol);
1673 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1674 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);
1675 CL_TeleportSplash(pos);
1679 // bullet hitting wall
1680 radius = MSG_ReadByte();
1681 MSG_ReadVector(pos, cls.protocol);
1682 CL_FindNonSolidLocation(pos, pos, 4);
1683 if (cl_particles_quake.integer)
1684 CL_RunParticleEffect(pos, vec3_origin, 0, 20*radius);
1687 CL_SparkShower(pos, vec3_origin, 15*radius, 1, radius);
1688 CL_Smoke(pos, vec3_origin, 15*radius, radius);
1690 // TODO: scatter bullet marks throughout the sphere?
1695 count = MSG_ReadByte();
1696 MSG_ReadVector(pos, cls.protocol);
1697 CL_FindNonSolidLocation(pos, pos, 4);
1698 CL_BloodPuff(pos, vec3_origin, 20*count);
1701 case QW_TE_LIGHTNINGBLOOD:
1702 MSG_ReadVector(pos, cls.protocol);
1703 CL_FindNonSolidLocation(pos, pos, 4);
1704 CL_BloodPuff(pos, vec3_origin, 50);
1708 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
1713 type = MSG_ReadByte();
1717 // spike hitting wall
1718 MSG_ReadVector(pos, cls.protocol);
1719 CL_FindNonSolidLocation(pos, pos, 4);
1720 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1721 //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);
1722 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1723 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1726 case TE_KNIGHTSPIKE:
1727 // spike hitting wall
1728 MSG_ReadVector(pos, cls.protocol);
1729 CL_FindNonSolidLocation(pos, pos, 4);
1730 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1731 //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);
1732 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1733 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1737 // spike hitting wall
1738 MSG_ReadVector(pos, cls.protocol);
1739 CL_FindNonSolidLocation(pos, pos, 4);
1740 if (cl_particles_quake.integer)
1741 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1742 else if (cl_particles_bulletimpacts.integer)
1744 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1745 CL_Smoke(pos, vec3_origin, 15, 0);
1749 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1754 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1756 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1758 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1762 // quad spike hitting wall
1763 MSG_ReadVector(pos, cls.protocol);
1764 CL_FindNonSolidLocation(pos, pos, 4);
1765 if (cl_particles_quake.integer)
1766 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1767 else if (cl_particles_bulletimpacts.integer)
1769 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1770 CL_Smoke(pos, vec3_origin, 15, 0);
1773 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1774 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);
1776 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1781 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1783 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1785 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1789 // super spike hitting wall
1790 MSG_ReadVector(pos, cls.protocol);
1791 CL_FindNonSolidLocation(pos, pos, 4);
1792 if (cl_particles_quake.integer)
1793 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1794 else if (cl_particles_bulletimpacts.integer)
1796 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1797 CL_Smoke(pos, vec3_origin, 30, 0);
1801 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1806 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1808 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1810 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1813 case TE_SUPERSPIKEQUAD:
1814 // quad super spike hitting wall
1815 MSG_ReadVector(pos, cls.protocol);
1816 CL_FindNonSolidLocation(pos, pos, 4);
1817 if (cl_particles_quake.integer)
1818 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1819 else if (cl_particles_bulletimpacts.integer)
1821 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1822 CL_Smoke(pos, vec3_origin, 30, 0);
1825 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1826 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);
1828 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1833 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1835 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1837 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1840 // LordHavoc: added for improved blood splatters
1843 MSG_ReadVector(pos, cls.protocol);
1844 CL_FindNonSolidLocation(pos, pos, 4);
1845 dir[0] = MSG_ReadChar();
1846 dir[1] = MSG_ReadChar();
1847 dir[2] = MSG_ReadChar();
1848 count = MSG_ReadByte();
1849 CL_BloodPuff(pos, dir, count);
1853 MSG_ReadVector(pos, cls.protocol);
1854 CL_FindNonSolidLocation(pos, pos, 4);
1855 dir[0] = MSG_ReadChar();
1856 dir[1] = MSG_ReadChar();
1857 dir[2] = MSG_ReadChar();
1858 count = MSG_ReadByte();
1859 CL_SparkShower(pos, dir, count, 1, 0);
1862 MSG_ReadVector(pos, cls.protocol);
1863 CL_FindNonSolidLocation(pos, pos, 4);
1864 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1865 CL_AllocDlight(NULL, &tempmatrix, 200, 1, 1, 1, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1868 // LordHavoc: added for improved gore
1869 case TE_BLOODSHOWER:
1871 MSG_ReadVector(pos, cls.protocol); // mins
1872 MSG_ReadVector(pos2, cls.protocol); // maxs
1873 velspeed = MSG_ReadCoord(cls.protocol); // speed
1874 count = (unsigned short) MSG_ReadShort(); // number of particles
1875 CL_BloodShower(pos, pos2, velspeed, count);
1877 case TE_PARTICLECUBE:
1878 // general purpose particle effect
1879 MSG_ReadVector(pos, cls.protocol); // mins
1880 MSG_ReadVector(pos2, cls.protocol); // maxs
1881 MSG_ReadVector(dir, cls.protocol); // dir
1882 count = (unsigned short) MSG_ReadShort(); // number of particles
1883 colorStart = MSG_ReadByte(); // color
1884 colorLength = MSG_ReadByte(); // gravity (1 or 0)
1885 velspeed = MSG_ReadCoord(cls.protocol); // randomvel
1886 CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength, velspeed);
1889 case TE_PARTICLERAIN:
1890 // general purpose particle effect
1891 MSG_ReadVector(pos, cls.protocol); // mins
1892 MSG_ReadVector(pos2, cls.protocol); // maxs
1893 MSG_ReadVector(dir, cls.protocol); // dir
1894 count = (unsigned short) MSG_ReadShort(); // number of particles
1895 colorStart = MSG_ReadByte(); // color
1896 CL_ParticleRain(pos, pos2, dir, count, colorStart, 0);
1899 case TE_PARTICLESNOW:
1900 // general purpose particle effect
1901 MSG_ReadVector(pos, cls.protocol); // mins
1902 MSG_ReadVector(pos2, cls.protocol); // maxs
1903 MSG_ReadVector(dir, cls.protocol); // dir
1904 count = (unsigned short) MSG_ReadShort(); // number of particles
1905 colorStart = MSG_ReadByte(); // color
1906 CL_ParticleRain(pos, pos2, dir, count, colorStart, 1);
1910 // bullet hitting wall
1911 MSG_ReadVector(pos, cls.protocol);
1912 CL_FindNonSolidLocation(pos, pos, 4);
1913 if (cl_particles_quake.integer)
1914 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1917 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1918 CL_Smoke(pos, vec3_origin, 15, 0);
1923 case TE_GUNSHOTQUAD:
1924 // quad bullet hitting wall
1925 MSG_ReadVector(pos, cls.protocol);
1926 CL_FindNonSolidLocation(pos, pos, 4);
1927 if (cl_particles_quake.integer)
1928 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1931 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1932 CL_Smoke(pos, vec3_origin, 15, 0);
1935 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1936 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);
1941 MSG_ReadVector(pos, cls.protocol);
1942 CL_FindNonSolidLocation(pos, pos, 10);
1943 CL_ParticleExplosion(pos);
1944 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1945 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1946 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);
1947 if (gamemode != GAME_NEXUIZ)
1948 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1951 case TE_EXPLOSIONQUAD:
1952 // quad rocket explosion
1953 MSG_ReadVector(pos, cls.protocol);
1954 CL_FindNonSolidLocation(pos, pos, 10);
1955 CL_ParticleExplosion(pos);
1956 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1957 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);
1958 if (gamemode != GAME_NEXUIZ)
1959 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1963 // Nehahra movie colored lighting explosion
1964 MSG_ReadVector(pos, cls.protocol);
1965 CL_FindNonSolidLocation(pos, pos, 10);
1966 CL_ParticleExplosion(pos);
1967 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1968 color[0] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1969 color[1] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1970 color[2] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1971 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);
1972 if (gamemode != GAME_NEXUIZ)
1973 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1976 case TE_EXPLOSIONRGB:
1977 // colored lighting explosion
1978 MSG_ReadVector(pos, cls.protocol);
1979 CL_FindNonSolidLocation(pos, pos, 10);
1980 CL_ParticleExplosion(pos);
1981 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1982 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1983 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1984 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1985 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);
1986 if (gamemode != GAME_NEXUIZ)
1987 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1990 case TE_TAREXPLOSION:
1991 // tarbaby explosion
1992 MSG_ReadVector(pos, cls.protocol);
1993 CL_FindNonSolidLocation(pos, pos, 10);
1994 CL_BlobExplosion(pos);
1996 if (gamemode != GAME_NEXUIZ)
1997 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1998 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1999 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);
2003 MSG_ReadVector(pos, cls.protocol);
2004 CL_FindNonSolidLocation(pos, pos, 10);
2005 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2006 CL_AllocDlight(NULL, &tempmatrix, 200, 2, 2, 2, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2009 case TE_CUSTOMFLASH:
2010 MSG_ReadVector(pos, cls.protocol);
2011 CL_FindNonSolidLocation(pos, pos, 4);
2012 radius = (MSG_ReadByte() + 1) * 8;
2013 velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0);
2014 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
2015 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
2016 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
2017 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2018 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);
2022 MSG_ReadVector(pos, cls.protocol);
2023 MSG_ReadVector(dir, cls.protocol);
2024 count = MSG_ReadByte();
2025 CL_Flames(pos, dir, count);
2030 CL_ParseBeam(cl.model_bolt, true);
2035 CL_ParseBeam(cl.model_bolt2, true);
2040 CL_ParseBeam(cl.model_bolt3, false);
2045 // grappling hook beam
2046 CL_ParseBeam(cl.model_beam, false);
2050 // LordHavoc: for compatibility with the Nehahra movie...
2051 case TE_LIGHTNING4NEH:
2052 CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false);
2056 MSG_ReadVector(pos, cls.protocol);
2061 MSG_ReadVector(pos, cls.protocol);
2062 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2063 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);
2064 CL_TeleportSplash(pos);
2068 // color mapped explosion
2069 MSG_ReadVector(pos, cls.protocol);
2070 CL_FindNonSolidLocation(pos, pos, 10);
2071 colorStart = MSG_ReadByte();
2072 colorLength = MSG_ReadByte();
2073 CL_ParticleExplosion2(pos, colorStart, colorLength);
2074 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
2075 color[0] = tempcolor[0] * (2.0f / 255.0f);
2076 color[1] = tempcolor[1] * (2.0f / 255.0f);
2077 color[2] = tempcolor[2] * (2.0f / 255.0f);
2078 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2079 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);
2080 if (gamemode != GAME_NEXUIZ)
2081 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2085 MSG_ReadVector(pos, cls.protocol);
2086 MSG_ReadVector(pos2, cls.protocol);
2087 MSG_ReadVector(dir, cls.protocol);
2088 CL_BeamParticle(pos, pos2, 8, 1, 1, 1, 1, 1);
2092 MSG_ReadVector(pos, cls.protocol);
2093 MSG_ReadVector(dir, cls.protocol);
2094 count = MSG_ReadByte();
2095 CL_FindNonSolidLocation(pos, pos, 4);
2096 CL_Tei_Smoke(pos, dir, count);
2099 case TE_TEI_BIGEXPLOSION:
2100 MSG_ReadVector(pos, cls.protocol);
2101 CL_FindNonSolidLocation(pos, pos, 10);
2102 CL_ParticleExplosion(pos);
2103 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2104 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);
2105 if (gamemode != GAME_NEXUIZ)
2106 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2109 case TE_TEI_PLASMAHIT:
2110 MSG_ReadVector(pos, cls.protocol);
2111 MSG_ReadVector(dir, cls.protocol);
2112 count = MSG_ReadByte();
2113 CL_FindNonSolidLocation(pos, pos, 5);
2114 CL_Tei_PlasmaHit(pos, dir, count);
2115 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2116 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);
2120 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
2125 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
2128 void CL_VM_Init (void);
2129 qboolean CL_VM_Parse_TempEntity (void);
2130 void CL_VM_Parse_StuffCmd (const char *msg);
2131 void CL_VM_Parse_CenterPrint (const char *msg);
2132 void CSQC_AddPrintText (const char *msg);
2133 void CSQC_ReadEntities (void);
2135 static unsigned char cgamenetbuffer[65536];
2138 =====================
2139 CL_ParseServerMessage
2140 =====================
2142 int parsingerror = false;
2143 void CL_ParseServerMessage(void)
2147 protocolversion_t protocol;
2148 unsigned char cmdlog[32];
2149 char *cmdlogname[32], *temp;
2150 int cmdindex, cmdcount = 0;
2152 if (cls.demorecording)
2153 CL_WriteDemoMessage ();
2155 cl.last_received_message = realtime;
2158 // if recording demos, copy the message out
2160 if (cl_shownet.integer == 1)
2161 Con_Printf("%f %i\n", realtime, net_message.cursize);
2162 else if (cl_shownet.integer == 2)
2163 Con_Print("------------------\n");
2165 cl.onground = false; // unless the server says otherwise
2167 // parse the message
2169 //MSG_BeginReading ();
2171 parsingerror = true;
2173 if (cls.protocol == PROTOCOL_QUAKEWORLD)
2175 cl.mtime[1] = cl.mtime[0];
2176 cl.mtime[0] = realtime; // qw has no clock
2181 Host_Error ("CL_ParseServerMessage: Bad QW server message");
2183 cmd = MSG_ReadByte ();
2187 SHOWNET("END OF MESSAGE");
2188 break; // end of message
2191 cmdindex = cmdcount & 31;
2193 cmdlog[cmdindex] = cmd;
2195 SHOWNET(qw_svc_strings[cmd]);
2196 cmdlogname[cmdindex] = qw_svc_strings[cmd];
2197 if (!cmdlogname[cmdindex])
2199 // 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)
2201 cmdlogname[cmdindex] = temp;
2209 char description[32*64], temp[64];
2211 strcpy(description, "packet dump: ");
2215 count = cmdcount - i;
2219 dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2220 strlcat(description, temp, sizeof(description));
2225 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2226 Con_Print(description);
2227 Host_Error("CL_ParseServerMessage: Illegible server message");
2232 //Con_Printf("qw_svc_nop\n");
2235 case qw_svc_disconnect:
2236 Con_Printf("Server disconnected\n");
2237 if (cls.demonum != -1)
2246 CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
2248 CSQC_AddPrintText(MSG_ReadString());
2251 case qw_svc_centerprint:
2252 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2255 case qw_svc_stufftext:
2256 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2260 // svc_damage protocol is identical to nq
2264 case qw_svc_serverdata:
2265 //Cbuf_Execute(); // make sure any stuffed commands are done
2266 CL_ParseServerInfo();
2267 CL_VM_Init(); //[515]: init csqc
2270 case qw_svc_setangle:
2271 for (i=0 ; i<3 ; i++)
2272 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2275 case qw_svc_lightstyle:
2276 i = MSG_ReadByte ();
2277 if (i >= cl_max_lightstyle)
2279 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2282 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2283 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2284 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2288 CL_ParseStartSoundPacket(false);
2291 case qw_svc_stopsound:
2292 i = (unsigned short) MSG_ReadShort();
2293 S_StopSound(i>>3, i&7);
2296 case qw_svc_updatefrags:
2298 if (i >= cl.maxclients)
2299 Host_Error("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2300 cl.scores[i].frags = (signed short) MSG_ReadShort();
2303 case qw_svc_updateping:
2305 if (i >= cl.maxclients)
2306 Host_Error("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
2307 cl.scores[i].qw_ping = MSG_ReadShort();
2310 case qw_svc_updatepl:
2312 if (i >= cl.maxclients)
2313 Host_Error("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
2314 cl.scores[i].qw_packetloss = MSG_ReadByte();
2317 case qw_svc_updateentertime:
2319 if (i >= cl.maxclients)
2320 Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
2322 cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
2325 case qw_svc_spawnbaseline:
2326 i = (unsigned short) MSG_ReadShort();
2327 if (i < 0 || i >= MAX_EDICTS)
2328 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2329 if (i >= cl_max_entities)
2330 CL_ExpandEntities(i);
2331 CL_ParseBaseline(cl_entities + i, false);
2333 case qw_svc_spawnstatic:
2334 CL_ParseStatic(false);
2336 case qw_svc_temp_entity:
2337 if(!CL_VM_Parse_TempEntity())
2338 CL_ParseTempEntity ();
2341 case qw_svc_killedmonster:
2342 cl.stats[STAT_MONSTERS]++;
2345 case qw_svc_foundsecret:
2346 cl.stats[STAT_SECRETS]++;
2349 case qw_svc_updatestat:
2350 i = MSG_ReadByte ();
2351 if (i < 0 || i >= MAX_CL_STATS)
2352 Host_Error ("svc_updatestat: %i is invalid", i);
2353 cl.stats[i] = MSG_ReadByte ();
2356 case qw_svc_updatestatlong:
2357 i = MSG_ReadByte ();
2358 if (i < 0 || i >= MAX_CL_STATS)
2359 Host_Error ("svc_updatestatlong: %i is invalid", i);
2360 cl.stats[i] = MSG_ReadLong ();
2363 case qw_svc_spawnstaticsound:
2364 CL_ParseStaticSound (false);
2367 case qw_svc_cdtrack:
2368 cl.cdtrack = cl.looptrack = MSG_ReadByte ();
2369 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2370 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2372 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2375 case qw_svc_intermission:
2376 cl.intermission = 1;
2377 cl.completed_time = cl.time;
2378 MSG_ReadVector(cl.qw_intermission_origin, cls.protocol);
2379 for (i = 0;i < 3;i++)
2380 cl.qw_intermission_angles[i] = MSG_ReadAngle(cls.protocol);
2384 cl.intermission = 2;
2385 cl.completed_time = cl.time;
2386 SCR_CenterPrint(MSG_ReadString ());
2389 case qw_svc_sellscreen:
2390 Cmd_ExecuteString ("help", src_command);
2393 case qw_svc_smallkick:
2394 Con_Printf("TODO: qw_svc_smallkick\n");
2396 case qw_svc_bigkick:
2397 Con_Printf("TODO: qw_svc_bigkick\n");
2400 case qw_svc_muzzleflash:
2401 i = (unsigned short) MSG_ReadShort();
2402 // NOTE: in QW this only worked on clients
2403 if (i < 0 || i >= MAX_EDICTS)
2404 Host_Error("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2405 if (i >= cl_max_entities)
2406 CL_ExpandEntities(i);
2407 cl_entities[i].persistent.muzzleflash = 1.0f;
2410 case qw_svc_updateuserinfo:
2411 QW_CL_UpdateUserInfo();
2414 case qw_svc_setinfo:
2418 case qw_svc_serverinfo:
2422 case qw_svc_download:
2423 QW_CL_ParseDownload();
2426 case qw_svc_playerinfo:
2427 EntityStateQW_ReadPlayerUpdate();
2434 case qw_svc_chokecount:
2436 // FIXME: apply to netgraph
2437 //for (j = 0;j < i;j++)
2438 // cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK].receivedtime = -2;
2441 case qw_svc_modellist:
2442 QW_CL_ParseModelList();
2445 case qw_svc_soundlist:
2446 QW_CL_ParseSoundList();
2449 case qw_svc_packetentities:
2450 EntityFrameQW_CL_ReadFrame(false);
2451 // first update is the final signon stage
2452 if (cls.signon == SIGNONS - 1)
2453 cls.signon = SIGNONS;
2456 case qw_svc_deltapacketentities:
2457 EntityFrameQW_CL_ReadFrame(true);
2458 // first update is the final signon stage
2459 if (cls.signon == SIGNONS - 1)
2460 cls.signon = SIGNONS;
2463 case qw_svc_maxspeed:
2464 cl.qw_movevars_maxspeed = MSG_ReadFloat();
2467 case qw_svc_entgravity:
2468 cl.qw_movevars_entgravity = MSG_ReadFloat();
2471 case qw_svc_setpause:
2472 cl.paused = MSG_ReadByte ();
2477 S_PauseGameSounds (cl.paused);
2481 QW_CL_UpdateItemsAndWeapon();
2488 Host_Error ("CL_ParseServerMessage: Bad server message");
2490 cmd = MSG_ReadByte ();
2494 SHOWNET("END OF MESSAGE");
2495 break; // end of message
2498 cmdindex = cmdcount & 31;
2500 cmdlog[cmdindex] = cmd;
2502 // if the high bit of the command byte is set, it is a fast update
2505 // 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)
2507 cmdlogname[cmdindex] = temp;
2508 SHOWNET("fast update");
2509 if (cls.signon == SIGNONS - 1)
2511 // first update is the final signon stage
2512 cls.signon = SIGNONS;
2515 EntityFrameQuake_ReadEntity (cmd&127);
2519 SHOWNET(svc_strings[cmd]);
2520 cmdlogname[cmdindex] = svc_strings[cmd];
2521 if (!cmdlogname[cmdindex])
2523 // 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)
2525 cmdlogname[cmdindex] = temp;
2533 char description[32*64], temp[64];
2535 strcpy (description, "packet dump: ");
2539 count = cmdcount - i;
2543 dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2544 strlcat (description, temp, sizeof (description));
2549 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2550 Con_Print(description);
2551 Host_Error ("CL_ParseServerMessage: Illegible server message");
2556 if (cls.signon < SIGNONS)
2557 Con_Print("<-- server to client keepalive\n");
2561 cl.mtime[1] = cl.mtime[0];
2562 cl.mtime[0] = MSG_ReadFloat ();
2563 cl.movement_needupdate = true;
2566 case svc_clientdata:
2567 CL_ParseClientdata();
2571 i = MSG_ReadLong ();
2572 protocol = Protocol_EnumForNumber(i);
2573 if (protocol == PROTOCOL_UNKNOWN)
2574 Host_Error("CL_ParseServerMessage: Server is unrecognized protocol number (%i)", i);
2575 // hack for unmarked Nehahra movie demos which had a custom protocol
2576 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
2577 protocol = PROTOCOL_NEHAHRAMOVIE;
2578 cls.protocol = protocol;
2581 case svc_disconnect:
2582 Con_Printf ("Server disconnected\n");
2583 if (cls.demonum != -1)
2590 CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
2593 case svc_centerprint:
2594 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2598 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2605 case svc_serverinfo:
2606 CL_ParseServerInfo ();
2607 CL_VM_Init(); //[515]: init csqc
2611 for (i=0 ; i<3 ; i++)
2612 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2616 cl.viewentity = (unsigned short)MSG_ReadShort ();
2617 if (cl.viewentity >= MAX_EDICTS)
2618 Host_Error("svc_setview >= MAX_EDICTS");
2619 if (cl.viewentity >= cl_max_entities)
2620 CL_ExpandEntities(cl.viewentity);
2621 // LordHavoc: assume first setview recieved is the real player entity
2622 if (!cl.playerentity)
2623 cl.playerentity = cl.viewentity;
2626 case svc_lightstyle:
2627 i = MSG_ReadByte ();
2628 if (i >= cl_max_lightstyle)
2630 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2633 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2634 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2635 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2639 CL_ParseStartSoundPacket(false);
2643 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2645 // was svc_sound2 in protocols 1, 2, 3, removed in 4, 5, changed to svc_precache in 6
2646 CL_ParseStartSoundPacket(true);
2650 int i = (unsigned short)MSG_ReadShort();
2651 char *s = MSG_ReadString();
2654 if (i >= 1 && i < MAX_MODELS)
2656 model_t *model = Mod_ForName(s, false, false, i == 1);
2658 Con_Printf("svc_precache: Mod_ForName(\"%s\") failed\n", s);
2659 cl.model_precache[i] = model;
2662 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_MODELS);
2667 if (i >= 1 && i < MAX_SOUNDS)
2669 sfx_t *sfx = S_PrecacheSound (s, true, false);
2670 if (!sfx && snd_initialized.integer)
2671 Con_Printf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s);
2672 cl.sound_precache[i] = sfx;
2675 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_SOUNDS);
2681 i = (unsigned short) MSG_ReadShort();
2682 S_StopSound(i>>3, i&7);
2685 case svc_updatename:
2686 i = MSG_ReadByte ();
2687 if (i >= cl.maxclients)
2688 Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
2689 strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
2692 case svc_updatefrags:
2693 i = MSG_ReadByte ();
2694 if (i >= cl.maxclients)
2695 Host_Error ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2696 cl.scores[i].frags = (signed short) MSG_ReadShort ();
2699 case svc_updatecolors:
2700 i = MSG_ReadByte ();
2701 if (i >= cl.maxclients)
2702 Host_Error ("CL_ParseServerMessage: svc_updatecolors >= cl.maxclients");
2703 cl.scores[i].colors = MSG_ReadByte ();
2707 CL_ParseParticleEffect ();
2718 case svc_spawnbaseline:
2719 i = (unsigned short) MSG_ReadShort ();
2720 if (i < 0 || i >= MAX_EDICTS)
2721 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2722 if (i >= cl_max_entities)
2723 CL_ExpandEntities(i);
2724 CL_ParseBaseline (cl_entities + i, false);
2726 case svc_spawnbaseline2:
2727 i = (unsigned short) MSG_ReadShort ();
2728 if (i < 0 || i >= MAX_EDICTS)
2729 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline2: invalid entity number %i", i);
2730 if (i >= cl_max_entities)
2731 CL_ExpandEntities(i);
2732 CL_ParseBaseline (cl_entities + i, true);
2734 case svc_spawnstatic:
2735 CL_ParseStatic (false);
2737 case svc_spawnstatic2:
2738 CL_ParseStatic (true);
2740 case svc_temp_entity:
2741 if(!CL_VM_Parse_TempEntity())
2742 CL_ParseTempEntity ();
2746 cl.paused = MSG_ReadByte ();
2751 S_PauseGameSounds (cl.paused);
2755 i = MSG_ReadByte ();
2756 // LordHavoc: it's rude to kick off the client if they missed the
2757 // reconnect somehow, so allow signon 1 even if at signon 1
2758 if (i <= cls.signon && i != 1)
2759 Host_Error ("Received signon %i when at %i", i, cls.signon);
2764 case svc_killedmonster:
2765 cl.stats[STAT_MONSTERS]++;
2768 case svc_foundsecret:
2769 cl.stats[STAT_SECRETS]++;
2772 case svc_updatestat:
2773 i = MSG_ReadByte ();
2774 if (i < 0 || i >= MAX_CL_STATS)
2775 Host_Error ("svc_updatestat: %i is invalid", i);
2776 cl.stats[i] = MSG_ReadLong ();
2779 case svc_updatestatubyte:
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_ReadByte ();
2786 case svc_spawnstaticsound:
2787 CL_ParseStaticSound (false);
2790 case svc_spawnstaticsound2:
2791 CL_ParseStaticSound (true);
2795 cl.cdtrack = MSG_ReadByte ();
2796 cl.looptrack = MSG_ReadByte ();
2797 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2798 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2800 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2803 case svc_intermission:
2804 cl.intermission = 1;
2805 cl.completed_time = cl.time;
2809 cl.intermission = 2;
2810 cl.completed_time = cl.time;
2811 SCR_CenterPrint(MSG_ReadString ());
2815 cl.intermission = 3;
2816 cl.completed_time = cl.time;
2817 SCR_CenterPrint(MSG_ReadString ());
2820 case svc_sellscreen:
2821 Cmd_ExecuteString ("help", src_command);
2824 if (gamemode == GAME_TENEBRAE)
2826 // repeating particle effect
2827 MSG_ReadCoord(cls.protocol);
2828 MSG_ReadCoord(cls.protocol);
2829 MSG_ReadCoord(cls.protocol);
2830 MSG_ReadCoord(cls.protocol);
2831 MSG_ReadCoord(cls.protocol);
2832 MSG_ReadCoord(cls.protocol);
2839 SHOWLMP_decodehide();
2842 if (gamemode == GAME_TENEBRAE)
2845 MSG_ReadCoord(cls.protocol);
2846 MSG_ReadCoord(cls.protocol);
2847 MSG_ReadCoord(cls.protocol);
2852 SHOWLMP_decodeshow();
2855 R_SetSkyBox(MSG_ReadString());
2860 length = (int) ((unsigned short) MSG_ReadShort());
2861 for (i = 0;i < length;i++)
2862 cgamenetbuffer[i] = MSG_ReadByte();
2864 CL_CGVM_ParseNetwork(cgamenetbuffer, length);
2868 if (cls.signon == SIGNONS - 1)
2870 // first update is the final signon stage
2871 cls.signon = SIGNONS;
2874 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2875 EntityFrame_CL_ReadFrame();
2876 else if (cls.protocol == PROTOCOL_DARKPLACES4)
2877 EntityFrame4_CL_ReadFrame();
2879 EntityFrame5_CL_ReadFrame();
2881 case svc_csqcentities:
2882 CSQC_ReadEntities();
2888 EntityFrameQuake_ISeeDeadEntities();
2890 parsingerror = false;
2893 void CL_Parse_DumpPacket(void)
2897 Con_Print("Packet dump:\n");
2898 SZ_HexDumpToConsole(&net_message);
2899 parsingerror = false;
2902 void CL_Parse_ErrorCleanUp(void)
2904 if (cls.qw_downloadmemory)
2906 Mem_Free(cls.qw_downloadmemory);
2907 cls.qw_downloadmemory = NULL;
2909 cls.qw_downloadpercent = 0;
2913 void CL_Parse_Init(void)
2915 // LordHavoc: added demo_nehahra cvar
2916 Cvar_RegisterVariable (&demo_nehahra);
2917 if (gamemode == GAME_NEHAHRA)
2918 Cvar_SetValue("demo_nehahra", 1);
2919 Cvar_RegisterVariable(&developer_networkentities);
2921 Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
2922 Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
2925 void CL_Parse_Shutdown(void)