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_ProcessUserInfo(int slot);
392 static void QW_CL_RequestNextDownload(void)
396 // clear name of file that just finished
397 cls.qw_downloadname[0] = 0;
399 switch (cls.qw_downloadtype)
404 if (cls.qw_downloadnumber == 0)
405 Con_Printf("Checking skins...\n");
406 for (;cls.qw_downloadnumber < cl.maxclients;cls.qw_downloadnumber++)
408 if (!cl.scores[cls.qw_downloadnumber].name[0])
410 // check if we need to download the file, and return if so
411 if (!QW_CL_CheckOrDownloadFile(va("skins/%s.pcx", cl.scores[cls.qw_downloadnumber].qw_skin)))
415 cls.qw_downloadtype = dl_none;
417 // load any newly downloaded skins
418 for (i = 0;i < cl.maxclients;i++)
419 QW_CL_ProcessUserInfo(i);
421 // if we're still in signon stages, request the next one
422 if (cls.signon != SIGNONS)
424 cls.signon = SIGNONS-1;
425 // we'll go to SIGNONS when the first entity update is received
426 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
427 MSG_WriteString(&cls.netcon->message, va("begin %i", cl.qw_servercount));
431 if (cls.qw_downloadnumber == 0)
433 Con_Printf("Checking models...\n");
434 cls.qw_downloadnumber = 1;
437 for (;cls.qw_downloadnumber < MAX_MODELS && cl.model_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
440 if (cl.model_name[cls.qw_downloadnumber][0] == '*')
442 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/spike.mdl"))
443 cl.qw_modelindex_spike = cls.qw_downloadnumber;
444 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/player.mdl"))
445 cl.qw_modelindex_player = cls.qw_downloadnumber;
446 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/flag.mdl"))
447 cl.qw_modelindex_flag = cls.qw_downloadnumber;
448 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/s_explod.spr"))
449 cl.qw_modelindex_s_explod = cls.qw_downloadnumber;
450 // check if we need to download the file, and return if so
451 if (!QW_CL_CheckOrDownloadFile(cl.model_name[cls.qw_downloadnumber]))
455 cls.qw_downloadtype = dl_none;
457 // touch all of the precached models that are still loaded so we can free
458 // anything that isn't needed
460 for (i = 1;i < MAX_MODELS && cl.model_name[i][0];i++)
461 Mod_FindName(cl.model_name[i]);
462 // precache any models used by the client (this also marks them used)
463 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
464 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
465 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
466 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
469 // now we try to load everything that is new
472 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
473 if (cl.model_precache[1]->Draw == NULL)
474 Con_Printf("Map %s could not be found or downloaded\n", cl.model_name[1]);
477 for (i = 2;i < MAX_MODELS && cl.model_name[i][0];i++)
478 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
479 Con_Printf("Model %s could not be found or downloaded\n", cl.model_name[i]);
481 // check memory integrity
482 Mem_CheckSentinelsGlobal();
484 // now that we have a world model, set up the world entity, renderer
486 cl_entities[0].render.model = cl.worldmodel = cl.model_precache[1];
487 CL_BoundingBoxForEntity(&cl_entities[0].render);
492 // done checking sounds and models, send a prespawn command now
493 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
494 MSG_WriteString(&cls.netcon->message, va("prespawn %i 0 %i", cl.qw_servercount, cl.model_precache[1]->brush.qw_md4sum2));
496 if (cls.qw_downloadmemory)
498 Mem_Free(cls.qw_downloadmemory);
499 cls.qw_downloadmemory = NULL;
503 if (cls.qw_downloadnumber == 0)
505 Con_Printf("Checking sounds...\n");
506 cls.qw_downloadnumber = 1;
509 for (;cl.sound_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
511 // check if we need to download the file, and return if so
512 if (!QW_CL_CheckOrDownloadFile(va("sound/%s", cl.sound_name[cls.qw_downloadnumber])))
516 cls.qw_downloadtype = dl_none;
518 // load new sounds and unload old ones
519 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
520 S_ServerSounds(cl.sound_name, cls.qw_downloadnumber);
522 // precache any sounds used by the client
523 cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
524 cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
525 cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
526 cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
527 cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
528 cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
529 cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
532 for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++)
534 // Don't lock the sfx here, S_ServerSounds already did that
535 cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, false);
538 // check memory integrity
539 Mem_CheckSentinelsGlobal();
541 // done with sound downloads, next we check models
542 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
543 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, 0));
547 Con_Printf("Unknown download type.\n");
551 static void QW_CL_ParseDownload(void)
553 int size = (signed short)MSG_ReadShort();
554 int percent = MSG_ReadByte();
556 //Con_Printf("download %i %i%% (%i/%i)\n", size, percent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize);
558 // skip the download fragment if playing a demo
562 msg_readcount += size;
568 Con_Printf("File not found.\n");
569 QW_CL_RequestNextDownload();
573 if (msg_readcount + (unsigned short)size > net_message.cursize)
574 Host_Error("corrupt download message\n");
576 // make sure the buffer is big enough to include this new fragment
577 if (!cls.qw_downloadmemory || cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
580 while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
581 cls.qw_downloadmemorymaxsize *= 2;
582 old = cls.qw_downloadmemory;
583 cls.qw_downloadmemory = Mem_Alloc(cl_mempool, cls.qw_downloadmemorymaxsize);
586 memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize);
591 // read the fragment out of the packet
592 MSG_ReadBytes(size, cls.qw_downloadmemory + cls.qw_downloadmemorycursize);
593 cls.qw_downloadmemorycursize += size;
595 cls.qw_downloadpercent = percent;
599 // request next fragment
600 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
601 MSG_WriteString(&cls.netcon->message, "nextdl");
606 Con_Printf("Downloaded \"%s\"\n", cls.qw_downloadname);
608 FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
610 cls.qw_downloadpercent = 0;
612 // start downloading the next file (or join the game)
613 QW_CL_RequestNextDownload();
617 static void QW_CL_ParseModelList(void)
620 int nummodels = MSG_ReadByte();
623 // parse model precache list
626 str = MSG_ReadString();
630 if (nummodels==MAX_MODELS)
631 Host_Error("Server sent too many model precaches");
632 if (strlen(str) >= MAX_QPATH)
633 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
634 strlcpy(cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
640 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
641 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, n));
646 cls.qw_downloadnumber = 0;
647 cls.qw_downloadtype = dl_model;
648 QW_CL_RequestNextDownload();
651 static void QW_CL_ParseSoundList(void)
654 int numsounds = MSG_ReadByte();
657 // parse sound precache list
660 str = MSG_ReadString();
664 if (numsounds==MAX_SOUNDS)
665 Host_Error("Server sent too many sound precaches");
666 if (strlen(str) >= MAX_QPATH)
667 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
668 strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
675 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
676 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, n));
681 cls.qw_downloadnumber = 0;
682 cls.qw_downloadtype = dl_sound;
683 QW_CL_RequestNextDownload();
686 static void QW_CL_Skins_f(void)
688 cls.qw_downloadnumber = 0;
689 cls.qw_downloadtype = dl_skin;
690 QW_CL_RequestNextDownload();
693 static void QW_CL_Changing_f(void)
695 if (cls.qw_downloadmemory) // don't change when downloading
700 cls.signon = 1; // not active anymore, but not disconnected
701 Con_Printf("\nChanging map...\n");
704 void QW_CL_NextUpload(void)
706 int r, percent, size;
708 if (!cls.qw_uploaddata)
711 r = cls.qw_uploadsize - cls.qw_uploadpos;
714 size = min(1, cls.qw_uploadsize);
715 percent = (cls.qw_uploadpos+r)*100/size;
717 MSG_WriteByte(&cls.netcon->message, qw_clc_upload);
718 MSG_WriteShort(&cls.netcon->message, r);
719 MSG_WriteByte(&cls.netcon->message, percent);
720 SZ_Write(&cls.netcon->message, cls.qw_uploaddata + cls.qw_uploadpos, r);
722 Con_DPrintf("UPLOAD: %6d: %d written\n", cls.qw_uploadpos, r);
724 cls.qw_uploadpos += r;
726 if (cls.qw_uploadpos < cls.qw_uploadsize)
729 Con_Printf("Upload completed\n");
734 void QW_CL_StartUpload(unsigned char *data, int size)
736 // do nothing in demos or if not connected
740 // abort existing upload if in progress
743 Con_DPrintf("Starting upload of %d bytes...\n", size);
745 cls.qw_uploaddata = Mem_Alloc(cl_mempool, size);
746 memcpy(cls.qw_uploaddata, data, size);
747 cls.qw_uploadsize = size;
748 cls.qw_uploadpos = 0;
754 qboolean QW_CL_IsUploading(void)
756 return cls.qw_uploaddata != NULL;
760 void QW_CL_StopUpload(void)
762 if (cls.qw_uploaddata)
763 Mem_Free(cls.qw_uploaddata);
764 cls.qw_uploaddata = NULL;
765 cls.qw_uploadsize = 0;
766 cls.qw_uploadpos = 0;
769 static void QW_CL_ProcessUserInfo(int slot)
771 int topcolor, bottomcolor;
773 InfoString_GetValue(cl.scores[slot].qw_userinfo, "name", cl.scores[slot].name, sizeof(cl.scores[slot].name));
774 InfoString_GetValue(cl.scores[slot].qw_userinfo, "topcolor", temp, sizeof(temp));topcolor = atoi(temp);
775 InfoString_GetValue(cl.scores[slot].qw_userinfo, "bottomcolor", temp, sizeof(temp));bottomcolor = atoi(temp);
776 cl.scores[slot].colors = topcolor * 16 + bottomcolor;
777 InfoString_GetValue(cl.scores[slot].qw_userinfo, "*spectator", temp, sizeof(temp));
778 cl.scores[slot].qw_spectator = temp[0] != 0;
779 InfoString_GetValue(cl.scores[slot].qw_userinfo, "team", cl.scores[slot].qw_team, sizeof(cl.scores[slot].qw_team));
780 InfoString_GetValue(cl.scores[slot].qw_userinfo, "skin", cl.scores[slot].qw_skin, sizeof(cl.scores[slot].qw_skin));
781 if (!cl.scores[slot].qw_skin[0])
782 strlcpy(cl.scores[slot].qw_skin, "base", sizeof(cl.scores[slot].qw_skin));
786 static void QW_CL_UpdateUserInfo(void)
789 slot = MSG_ReadByte();
790 if (slot >= cl.maxclients)
792 Con_Printf("svc_updateuserinfo >= cl.maxclients\n");
797 cl.scores[slot].qw_userid = MSG_ReadLong();
798 strlcpy(cl.scores[slot].qw_userinfo, MSG_ReadString(), sizeof(cl.scores[slot].qw_userinfo));
800 QW_CL_ProcessUserInfo(slot);
803 static void QW_CL_SetInfo(void)
808 slot = MSG_ReadByte();
809 strlcpy(key, MSG_ReadString(), sizeof(key));
810 strlcpy(value, MSG_ReadString(), sizeof(value));
811 if (slot >= cl.maxclients)
813 Con_Printf("svc_setinfo >= cl.maxclients\n");
816 InfoString_SetValue(cl.scores[slot].qw_userinfo, sizeof(cl.scores[slot].qw_userinfo), key, value);
818 QW_CL_ProcessUserInfo(slot);
821 static void QW_CL_ServerInfo(void)
826 strlcpy(key, MSG_ReadString(), sizeof(key));
827 strlcpy(value, MSG_ReadString(), sizeof(value));
828 Con_DPrintf("SERVERINFO: %s=%s\n", key, value);
829 InfoString_SetValue(cl.qw_serverinfo, sizeof(cl.qw_serverinfo), key, value);
830 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
831 cl.qw_teamplay = atoi(temp);
834 static void QW_CL_ParseNails(void)
837 int numnails = MSG_ReadByte();
839 unsigned char bits[6];
840 for (i = 0;i < numnails;i++)
842 for (j = 0;j < 6;j++)
843 bits[j] = MSG_ReadByte();
844 if (cl.qw_num_nails > 255)
846 v = cl.qw_nails[cl.qw_num_nails++];
847 v[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096;
848 v[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096;
849 v[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096;
850 v[3] = -360*(bits[4]>>4)/16;
851 v[4] = 360*bits[5]/256;
856 static void QW_CL_UpdateItemsAndWeapon(void)
859 // check for important changes
862 if (cl.olditems != cl.stats[STAT_ITEMS])
863 for (j = 0;j < 32;j++)
864 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
865 cl.item_gettime[j] = cl.time;
866 cl.olditems = cl.stats[STAT_ITEMS];
868 // GAME_NEXUIZ hud needs weapon change time
869 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
870 cl.weapontime = cl.time;
871 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
875 =====================
878 An svc_signonnum has been received, perform a client side setup
879 =====================
881 static void CL_SignonReply (void)
883 Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
890 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
891 MSG_WriteString (&cls.netcon->message, "prespawn");
898 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
899 MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
901 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
902 MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
904 if (cl_pmodel.integer)
906 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
907 MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
909 if (*cl_playermodel.string)
911 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
912 MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
914 if (*cl_playerskin.string)
916 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
917 MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
920 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
921 MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
923 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
924 MSG_WriteString (&cls.netcon->message, "spawn");
931 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
932 MSG_WriteString (&cls.netcon->message, "begin");
947 void CL_ParseServerInfo (void)
951 protocolversion_t protocol;
952 int nummodels, numsounds;
955 Con_DPrint("Serverinfo packet received.\n");
957 // if server is active, we already began a loading plaque
959 SCR_BeginLoadingPlaque();
961 // check memory integrity
962 Mem_CheckSentinelsGlobal();
965 // wipe the client_state_t struct
969 // parse protocol version number
971 protocol = Protocol_EnumForNumber(i);
972 if (protocol == PROTOCOL_UNKNOWN)
974 Host_Error("CL_ParseServerInfo: Server is unrecognized protocol number (%i)", i);
977 // hack for unmarked Nehahra movie demos which had a custom protocol
978 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
979 protocol = PROTOCOL_NEHAHRAMOVIE;
980 cls.protocol = protocol;
981 Con_DPrintf("Server protocol is %s\n", Protocol_NameForEnum(cls.protocol));
985 if (protocol == PROTOCOL_QUAKEWORLD)
987 cl.qw_servercount = MSG_ReadLong();
989 str = MSG_ReadString();
990 Con_Printf("server gamedir is %s\n", str);
992 // FIXME: change gamedir if needed!
993 if (strcasecmp(gamedirfile, str))
999 Com_Gamedir(str); // change gamedir
1003 // exec the new config stuff
1007 cl.gametype = GAME_DEATHMATCH;
1010 // parse player number
1012 cl.qw_spectator = (i & 128) != 0;
1013 cl.playerentity = cl.viewentity = (i & 127) + 1;
1014 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
1016 // get the full level name
1017 str = MSG_ReadString ();
1018 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1021 cl.qw_movevars_gravity = MSG_ReadFloat();
1022 cl.qw_movevars_stopspeed = MSG_ReadFloat();
1023 cl.qw_movevars_maxspeed = MSG_ReadFloat();
1024 cl.qw_movevars_spectatormaxspeed = MSG_ReadFloat();
1025 cl.qw_movevars_accelerate = MSG_ReadFloat();
1026 cl.qw_movevars_airaccelerate = MSG_ReadFloat();
1027 cl.qw_movevars_wateraccelerate = MSG_ReadFloat();
1028 cl.qw_movevars_friction = MSG_ReadFloat();
1029 cl.qw_movevars_waterfriction = MSG_ReadFloat();
1030 cl.qw_movevars_entgravity = MSG_ReadFloat();
1032 // seperate the printfs so the server message can have a color
1033 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);
1035 // check memory integrity
1036 Mem_CheckSentinelsGlobal();
1038 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
1039 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, 0));
1041 cls.state = ca_connected;
1044 // note: on QW protocol we can't set up the gameworld until after
1045 // downloads finish...
1046 // (we don't even know the name of the map yet)
1051 cl.maxclients = MSG_ReadByte ();
1052 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
1054 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
1057 cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores));
1060 cl.gametype = MSG_ReadByte ();
1062 // parse signon message
1063 str = MSG_ReadString ();
1064 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1066 // seperate the printfs so the server message can have a color
1067 if (cls.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
1068 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);
1070 // check memory integrity
1071 Mem_CheckSentinelsGlobal();
1073 // parse model precache list
1074 for (nummodels=1 ; ; nummodels++)
1076 str = MSG_ReadString();
1079 if (nummodels==MAX_MODELS)
1080 Host_Error ("Server sent too many model precaches");
1081 if (strlen(str) >= MAX_QPATH)
1082 Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1083 strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
1085 // parse sound precache list
1086 for (numsounds=1 ; ; numsounds++)
1088 str = MSG_ReadString();
1091 if (numsounds==MAX_SOUNDS)
1092 Host_Error("Server sent too many sound precaches");
1093 if (strlen(str) >= MAX_QPATH)
1094 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1095 strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
1098 // touch all of the precached models that are still loaded so we can free
1099 // anything that isn't needed
1101 for (i = 1;i < nummodels;i++)
1102 Mod_FindName(cl.model_name[i]);
1103 // precache any models used by the client (this also marks them used)
1104 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
1105 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
1106 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
1107 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
1110 // do the same for sounds
1111 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
1112 S_ServerSounds (cl.sound_name, numsounds);
1114 // precache any sounds used by the client
1115 cl.sfx_wizhit = S_PrecacheSound("sound/wizard/hit.wav", false, true);
1116 cl.sfx_knighthit = S_PrecacheSound("sound/hknight/hit.wav", false, true);
1117 cl.sfx_tink1 = S_PrecacheSound("sound/weapons/tink1.wav", false, true);
1118 cl.sfx_ric1 = S_PrecacheSound("sound/weapons/ric1.wav", false, true);
1119 cl.sfx_ric2 = S_PrecacheSound("sound/weapons/ric2.wav", false, true);
1120 cl.sfx_ric3 = S_PrecacheSound("sound/weapons/ric3.wav", false, true);
1121 cl.sfx_r_exp3 = S_PrecacheSound("sound/weapons/r_exp3.wav", false, true);
1123 // now we try to load everything that is new
1126 CL_KeepaliveMessage ();
1127 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
1128 if (cl.model_precache[1]->Draw == NULL)
1129 Con_Printf("Map %s not found\n", cl.model_name[1]);
1132 for (i=2 ; i<nummodels ; i++)
1134 CL_KeepaliveMessage();
1135 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
1136 Con_Printf("Model %s not found\n", cl.model_name[i]);
1140 for (i=1 ; i<numsounds ; i++)
1142 CL_KeepaliveMessage();
1143 // Don't lock the sfx here, S_ServerSounds already did that
1144 cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i], true, false);
1147 // we now have the worldmodel so we can set up the game world
1148 ent->render.model = cl.worldmodel = cl.model_precache[1];
1149 CL_BoundingBoxForEntity(&ent->render);
1154 // check memory integrity
1155 Mem_CheckSentinelsGlobal();
1158 void CL_ValidateState(entity_state_t *s)
1165 if (s->modelindex >= MAX_MODELS && (65536-s->modelindex) >= MAX_MODELS)
1166 Host_Error("CL_ValidateState: modelindex (%i) >= MAX_MODELS (%i)\n", s->modelindex, MAX_MODELS);
1168 // colormap is client index + 1
1169 if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
1171 Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
1175 model = cl.model_precache[s->modelindex];
1176 if (model && model->type && s->frame >= model->numframes)
1178 Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
1181 if (model && model->type && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
1183 Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\" (which has %i skins)\n", s->skin, model->name, model->numskins);
1188 void CL_MoveLerpEntityStates(entity_t *ent)
1190 float odelta[3], adelta[3];
1191 CL_ValidateState(&ent->state_current);
1192 VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
1193 VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
1194 if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
1196 // reset all persistent stuff if this is a new entity
1197 ent->persistent.lerpdeltatime = 0;
1198 ent->persistent.lerpstarttime = cl.mtime[1];
1199 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1200 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1201 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1202 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1203 // reset animation interpolation as well
1204 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
1205 ent->render.frame1time = ent->render.frame2time = cl.time;
1206 ent->render.framelerp = 1;
1207 // reset various persistent stuff
1208 ent->persistent.muzzleflash = 0;
1209 VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
1211 else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000)
1213 // don't interpolate the move
1214 ent->persistent.lerpdeltatime = 0;
1215 ent->persistent.lerpstarttime = cl.mtime[1];
1216 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1217 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1218 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1219 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1221 else if (ent->state_current.flags & RENDER_STEP)
1223 // monster interpolation
1224 if (DotProduct(odelta, odelta) + DotProduct(adelta, adelta) > 0.01)
1226 ent->persistent.lerpdeltatime = bound(0, cl.mtime[1] - ent->persistent.lerpstarttime, 0.1);
1227 ent->persistent.lerpstarttime = cl.mtime[1];
1228 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1229 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1230 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1231 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1237 ent->persistent.lerpstarttime = ent->state_previous.time;
1238 // no lerp if it's singleplayer
1239 if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
1240 ent->persistent.lerpdeltatime = 0;
1242 ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
1243 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1244 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1245 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1246 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1255 void CL_ParseBaseline (entity_t *ent, int large)
1259 ent->state_baseline = defaultstate;
1260 // FIXME: set ent->state_baseline.number?
1261 ent->state_baseline.active = true;
1264 ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
1265 ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
1269 ent->state_baseline.modelindex = MSG_ReadByte ();
1270 ent->state_baseline.frame = MSG_ReadByte ();
1272 ent->state_baseline.colormap = MSG_ReadByte();
1273 ent->state_baseline.skin = MSG_ReadByte();
1274 for (i = 0;i < 3;i++)
1276 ent->state_baseline.origin[i] = MSG_ReadCoord(cls.protocol);
1277 ent->state_baseline.angles[i] = MSG_ReadAngle(cls.protocol);
1279 CL_ValidateState(&ent->state_baseline);
1280 ent->state_previous = ent->state_current = ent->state_baseline;
1288 Server information pertaining to this client only
1291 void CL_ParseClientdata (void)
1295 VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
1296 VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
1297 VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
1298 cl.mviewzoom[1] = cl.mviewzoom[0];
1300 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)
1302 cl.stats[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
1303 cl.stats[STAT_ITEMS] = 0;
1304 cl.stats[STAT_VIEWZOOM] = 255;
1307 cl.mpunchangle[0][0] = 0;
1308 cl.mpunchangle[0][1] = 0;
1309 cl.mpunchangle[0][2] = 0;
1310 cl.mpunchvector[0][0] = 0;
1311 cl.mpunchvector[0][1] = 0;
1312 cl.mpunchvector[0][2] = 0;
1313 cl.mvelocity[0][0] = 0;
1314 cl.mvelocity[0][1] = 0;
1315 cl.mvelocity[0][2] = 0;
1316 cl.mviewzoom[0] = 1;
1318 bits = (unsigned short) MSG_ReadShort ();
1319 if (bits & SU_EXTEND1)
1320 bits |= (MSG_ReadByte() << 16);
1321 if (bits & SU_EXTEND2)
1322 bits |= (MSG_ReadByte() << 24);
1324 if (bits & SU_VIEWHEIGHT)
1325 cl.stats[STAT_VIEWHEIGHT] = MSG_ReadChar ();
1327 if (bits & SU_IDEALPITCH)
1328 cl.idealpitch = MSG_ReadChar ();
1330 for (i = 0;i < 3;i++)
1332 if (bits & (SU_PUNCH1<<i) )
1334 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
1335 cl.mpunchangle[0][i] = MSG_ReadChar();
1337 cl.mpunchangle[0][i] = MSG_ReadAngle16i();
1339 if (bits & (SU_PUNCHVEC1<<i))
1341 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1342 cl.mpunchvector[0][i] = MSG_ReadCoord16i();
1344 cl.mpunchvector[0][i] = MSG_ReadCoord32f();
1346 if (bits & (SU_VELOCITY1<<i) )
1348 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)
1349 cl.mvelocity[0][i] = MSG_ReadChar()*16;
1351 cl.mvelocity[0][i] = MSG_ReadCoord32f();
1355 // LordHavoc: hipnotic demos don't have this bit set but should
1356 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)
1357 cl.stats[STAT_ITEMS] = MSG_ReadLong ();
1359 cl.onground = (bits & SU_ONGROUND) != 0;
1360 csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
1361 cl.inwater = (bits & SU_INWATER) != 0;
1363 if (cls.protocol == PROTOCOL_DARKPLACES5)
1365 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadShort() : 0;
1366 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadShort() : 0;
1367 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadShort() : 0;
1368 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1369 cl.stats[STAT_AMMO] = MSG_ReadShort();
1370 cl.stats[STAT_SHELLS] = MSG_ReadShort();
1371 cl.stats[STAT_NAILS] = MSG_ReadShort();
1372 cl.stats[STAT_ROCKETS] = MSG_ReadShort();
1373 cl.stats[STAT_CELLS] = MSG_ReadShort();
1374 cl.stats[STAT_ACTIVEWEAPON] = (unsigned short) MSG_ReadShort ();
1376 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)
1378 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadByte() : 0;
1379 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadByte() : 0;
1380 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadByte() : 0;
1381 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1382 cl.stats[STAT_AMMO] = MSG_ReadByte();
1383 cl.stats[STAT_SHELLS] = MSG_ReadByte();
1384 cl.stats[STAT_NAILS] = MSG_ReadByte();
1385 cl.stats[STAT_ROCKETS] = MSG_ReadByte();
1386 cl.stats[STAT_CELLS] = MSG_ReadByte();
1387 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
1388 cl.stats[STAT_ACTIVEWEAPON] = (1<<MSG_ReadByte ());
1390 cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte ();
1393 if (bits & SU_VIEWZOOM)
1395 if (cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1396 cl.stats[STAT_VIEWZOOM] = MSG_ReadByte();
1398 cl.stats[STAT_VIEWZOOM] = (unsigned short) MSG_ReadShort();
1401 // check for important changes
1404 if (cl.olditems != cl.stats[STAT_ITEMS])
1405 for (j = 0;j < 32;j++)
1406 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
1407 cl.item_gettime[j] = cl.time;
1408 cl.olditems = cl.stats[STAT_ITEMS];
1410 // GAME_NEXUIZ hud needs weapon change time
1411 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
1412 cl.weapontime = cl.time;
1413 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
1415 // viewzoom interpolation
1416 cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
1420 =====================
1422 =====================
1424 void CL_ParseStatic (int large)
1428 if (cl_num_static_entities >= cl_max_static_entities)
1429 Host_Error ("Too many static entities");
1430 ent = &cl_static_entities[cl_num_static_entities++];
1431 CL_ParseBaseline (ent, large);
1433 // copy it to the current state
1434 ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
1435 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_baseline.frame;
1436 ent->render.framelerp = 0;
1437 // make torchs play out of sync
1438 ent->render.frame1time = ent->render.frame2time = lhrandom(-10, -1);
1439 ent->render.colormap = -1; // no special coloring
1440 ent->render.skinnum = ent->state_baseline.skin;
1441 ent->render.effects = ent->state_baseline.effects;
1442 ent->render.alpha = 1;
1443 //ent->render.scale = 1;
1445 //VectorCopy (ent->state_baseline.origin, ent->render.origin);
1446 //VectorCopy (ent->state_baseline.angles, ent->render.angles);
1448 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);
1449 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1450 CL_BoundingBoxForEntity(&ent->render);
1452 // This is definitely cheating...
1453 if (ent->render.model == NULL)
1454 cl_num_static_entities--;
1462 void CL_ParseStaticSound (int large)
1465 int sound_num, vol, atten;
1467 MSG_ReadVector(org, cls.protocol);
1469 sound_num = (unsigned short) MSG_ReadShort ();
1471 sound_num = MSG_ReadByte ();
1472 vol = MSG_ReadByte ();
1473 atten = MSG_ReadByte ();
1475 S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
1478 void CL_ParseEffect (void)
1481 int modelindex, startframe, framecount, framerate;
1483 MSG_ReadVector(org, cls.protocol);
1484 modelindex = MSG_ReadByte ();
1485 startframe = MSG_ReadByte ();
1486 framecount = MSG_ReadByte ();
1487 framerate = MSG_ReadByte ();
1489 CL_Effect(org, modelindex, startframe, framecount, framerate);
1492 void CL_ParseEffect2 (void)
1495 int modelindex, startframe, framecount, framerate;
1497 MSG_ReadVector(org, cls.protocol);
1498 modelindex = (unsigned short) MSG_ReadShort ();
1499 startframe = (unsigned short) MSG_ReadShort ();
1500 framecount = MSG_ReadByte ();
1501 framerate = MSG_ReadByte ();
1503 CL_Effect(org, modelindex, startframe, framecount, framerate);
1506 void CL_ParseBeam (model_t *m, int lightning)
1512 ent = (unsigned short) MSG_ReadShort ();
1513 MSG_ReadVector(start, cls.protocol);
1514 MSG_ReadVector(end, cls.protocol);
1516 if (ent >= MAX_EDICTS)
1518 Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
1522 if (ent >= cl_max_entities)
1523 CL_ExpandEntities(ent);
1525 // override any beam with the same entity
1528 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1529 if (b->entity == ent)
1531 // if the entity was not found then just replace an unused beam
1532 if (i == cl_max_beams)
1533 for (i = 0, b = cl_beams;i < cl_max_beams;i++, b++)
1534 if (!b->model || b->endtime < cl.time)
1536 if (i < cl_max_beams)
1539 b->lightning = lightning;
1541 b->endtime = cl.time + 0.2;
1542 VectorCopy (start, b->start);
1543 VectorCopy (end, b->end);
1544 b->relativestartvalid = 0;
1545 if (ent && cl_entities[ent].state_current.active)
1548 matrix4x4_t matrix, imatrix;
1549 if (ent == cl.viewentity && cl.movement)
1550 p = &cl_entities[b->entity].state_previous;
1552 p = &cl_entities[b->entity].state_current;
1553 // not really valid yet, we need to get the orientation now
1554 // (ParseBeam flagged this because it is received before
1555 // entities are received, by now they have been received)
1556 // note: because players create lightning in their think
1557 // function (which occurs before movement), they actually
1558 // have some lag in it's location, so compare to the
1559 // previous player state, not the latest
1560 Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
1561 Matrix4x4_Invert_Simple(&imatrix, &matrix);
1562 Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
1563 Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
1564 b->relativestartvalid = 1;
1568 Con_Print("beam list overflow!\n");
1571 void CL_ParseTempEntity(void)
1579 int colorStart, colorLength, count;
1580 float velspeed, radius;
1581 unsigned char *tempcolor;
1582 matrix4x4_t tempmatrix;
1584 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1586 type = MSG_ReadByte();
1589 case QW_TE_WIZSPIKE:
1590 // spike hitting wall
1591 MSG_ReadVector(pos, cls.protocol);
1592 CL_FindNonSolidLocation(pos, pos, 4);
1593 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1594 //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);
1595 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1596 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1599 case QW_TE_KNIGHTSPIKE:
1600 // spike hitting wall
1601 MSG_ReadVector(pos, cls.protocol);
1602 CL_FindNonSolidLocation(pos, pos, 4);
1603 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1604 //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);
1605 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1606 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1610 // spike hitting wall
1611 MSG_ReadVector(pos, cls.protocol);
1612 CL_FindNonSolidLocation(pos, pos, 4);
1613 if (cl_particles_quake.integer)
1614 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1615 else if (cl_particles_bulletimpacts.integer)
1617 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1618 CL_Smoke(pos, vec3_origin, 15, 0);
1622 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1627 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1629 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1631 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1634 case QW_TE_SUPERSPIKE:
1635 // super spike hitting wall
1636 MSG_ReadVector(pos, cls.protocol);
1637 CL_FindNonSolidLocation(pos, pos, 4);
1638 if (cl_particles_quake.integer)
1639 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1640 else if (cl_particles_bulletimpacts.integer)
1642 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1643 CL_Smoke(pos, vec3_origin, 30, 0);
1647 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1652 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1654 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1656 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1660 case QW_TE_EXPLOSION:
1662 MSG_ReadVector(pos, cls.protocol);
1663 CL_FindNonSolidLocation(pos, pos, 10);
1664 CL_ParticleExplosion(pos);
1665 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1666 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1667 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);
1668 if (gamemode != GAME_NEXUIZ)
1669 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1670 CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
1673 case QW_TE_TAREXPLOSION:
1674 // tarbaby explosion
1675 MSG_ReadVector(pos, cls.protocol);
1676 CL_FindNonSolidLocation(pos, pos, 10);
1677 CL_BlobExplosion(pos);
1679 if (gamemode != GAME_NEXUIZ)
1680 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1681 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1682 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);
1685 case QW_TE_LIGHTNING1:
1687 CL_ParseBeam(cl.model_bolt, true);
1690 case QW_TE_LIGHTNING2:
1692 CL_ParseBeam(cl.model_bolt2, true);
1695 case QW_TE_LIGHTNING3:
1697 CL_ParseBeam(cl.model_bolt3, false);
1700 case QW_TE_LAVASPLASH:
1701 MSG_ReadVector(pos, cls.protocol);
1705 case QW_TE_TELEPORT:
1706 MSG_ReadVector(pos, cls.protocol);
1707 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1708 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);
1709 CL_TeleportSplash(pos);
1713 // bullet hitting wall
1714 radius = MSG_ReadByte();
1715 MSG_ReadVector(pos, cls.protocol);
1716 CL_FindNonSolidLocation(pos, pos, 4);
1717 if (cl_particles_quake.integer)
1718 CL_RunParticleEffect(pos, vec3_origin, 0, 20*radius);
1721 CL_SparkShower(pos, vec3_origin, 15*radius, 1, radius);
1722 CL_Smoke(pos, vec3_origin, 15*radius, radius);
1724 // TODO: scatter bullet marks throughout the sphere?
1729 count = MSG_ReadByte();
1730 MSG_ReadVector(pos, cls.protocol);
1731 CL_FindNonSolidLocation(pos, pos, 4);
1732 CL_BloodPuff(pos, vec3_origin, 20*count);
1735 case QW_TE_LIGHTNINGBLOOD:
1736 MSG_ReadVector(pos, cls.protocol);
1737 CL_FindNonSolidLocation(pos, pos, 4);
1738 CL_BloodPuff(pos, vec3_origin, 50);
1742 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
1747 type = MSG_ReadByte();
1751 // spike hitting wall
1752 MSG_ReadVector(pos, cls.protocol);
1753 CL_FindNonSolidLocation(pos, pos, 4);
1754 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1755 //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);
1756 CL_RunParticleEffect(pos, vec3_origin, 20, 30);
1757 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1760 case TE_KNIGHTSPIKE:
1761 // spike hitting wall
1762 MSG_ReadVector(pos, cls.protocol);
1763 CL_FindNonSolidLocation(pos, pos, 4);
1764 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1765 //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);
1766 CL_RunParticleEffect(pos, vec3_origin, 226, 20);
1767 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1771 // spike hitting wall
1772 MSG_ReadVector(pos, cls.protocol);
1773 CL_FindNonSolidLocation(pos, pos, 4);
1774 if (cl_particles_quake.integer)
1775 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1776 else if (cl_particles_bulletimpacts.integer)
1778 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1779 CL_Smoke(pos, vec3_origin, 15, 0);
1783 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1788 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1790 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1792 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1796 // quad spike hitting wall
1797 MSG_ReadVector(pos, cls.protocol);
1798 CL_FindNonSolidLocation(pos, pos, 4);
1799 if (cl_particles_quake.integer)
1800 CL_RunParticleEffect(pos, vec3_origin, 0, 10);
1801 else if (cl_particles_bulletimpacts.integer)
1803 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1804 CL_Smoke(pos, vec3_origin, 15, 0);
1807 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1808 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);
1810 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1815 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1817 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1819 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1823 // super spike hitting wall
1824 MSG_ReadVector(pos, cls.protocol);
1825 CL_FindNonSolidLocation(pos, pos, 4);
1826 if (cl_particles_quake.integer)
1827 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1828 else if (cl_particles_bulletimpacts.integer)
1830 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1831 CL_Smoke(pos, vec3_origin, 30, 0);
1835 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1840 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1842 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1844 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1847 case TE_SUPERSPIKEQUAD:
1848 // quad super spike hitting wall
1849 MSG_ReadVector(pos, cls.protocol);
1850 CL_FindNonSolidLocation(pos, pos, 4);
1851 if (cl_particles_quake.integer)
1852 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1853 else if (cl_particles_bulletimpacts.integer)
1855 CL_SparkShower(pos, vec3_origin, 30, 1, 0);
1856 CL_Smoke(pos, vec3_origin, 30, 0);
1859 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1860 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);
1862 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1867 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1869 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1871 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1874 // LordHavoc: added for improved blood splatters
1877 MSG_ReadVector(pos, cls.protocol);
1878 CL_FindNonSolidLocation(pos, pos, 4);
1879 dir[0] = MSG_ReadChar();
1880 dir[1] = MSG_ReadChar();
1881 dir[2] = MSG_ReadChar();
1882 count = MSG_ReadByte();
1883 CL_BloodPuff(pos, dir, count);
1887 MSG_ReadVector(pos, cls.protocol);
1888 CL_FindNonSolidLocation(pos, pos, 4);
1889 dir[0] = MSG_ReadChar();
1890 dir[1] = MSG_ReadChar();
1891 dir[2] = MSG_ReadChar();
1892 count = MSG_ReadByte();
1893 CL_SparkShower(pos, dir, count, 1, 0);
1896 MSG_ReadVector(pos, cls.protocol);
1897 CL_FindNonSolidLocation(pos, pos, 4);
1898 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1899 CL_AllocDlight(NULL, &tempmatrix, 200, 1, 1, 1, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
1902 // LordHavoc: added for improved gore
1903 case TE_BLOODSHOWER:
1905 MSG_ReadVector(pos, cls.protocol); // mins
1906 MSG_ReadVector(pos2, cls.protocol); // maxs
1907 velspeed = MSG_ReadCoord(cls.protocol); // speed
1908 count = (unsigned short) MSG_ReadShort(); // number of particles
1909 CL_BloodShower(pos, pos2, velspeed, count);
1911 case TE_PARTICLECUBE:
1912 // general purpose particle effect
1913 MSG_ReadVector(pos, cls.protocol); // mins
1914 MSG_ReadVector(pos2, cls.protocol); // maxs
1915 MSG_ReadVector(dir, cls.protocol); // dir
1916 count = (unsigned short) MSG_ReadShort(); // number of particles
1917 colorStart = MSG_ReadByte(); // color
1918 colorLength = MSG_ReadByte(); // gravity (1 or 0)
1919 velspeed = MSG_ReadCoord(cls.protocol); // randomvel
1920 CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength, velspeed);
1923 case TE_PARTICLERAIN:
1924 // general purpose particle effect
1925 MSG_ReadVector(pos, cls.protocol); // mins
1926 MSG_ReadVector(pos2, cls.protocol); // maxs
1927 MSG_ReadVector(dir, cls.protocol); // dir
1928 count = (unsigned short) MSG_ReadShort(); // number of particles
1929 colorStart = MSG_ReadByte(); // color
1930 CL_ParticleRain(pos, pos2, dir, count, colorStart, 0);
1933 case TE_PARTICLESNOW:
1934 // general purpose particle effect
1935 MSG_ReadVector(pos, cls.protocol); // mins
1936 MSG_ReadVector(pos2, cls.protocol); // maxs
1937 MSG_ReadVector(dir, cls.protocol); // dir
1938 count = (unsigned short) MSG_ReadShort(); // number of particles
1939 colorStart = MSG_ReadByte(); // color
1940 CL_ParticleRain(pos, pos2, dir, count, colorStart, 1);
1944 // bullet hitting wall
1945 MSG_ReadVector(pos, cls.protocol);
1946 CL_FindNonSolidLocation(pos, pos, 4);
1947 if (cl_particles_quake.integer)
1948 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1951 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1952 CL_Smoke(pos, vec3_origin, 15, 0);
1957 case TE_GUNSHOTQUAD:
1958 // quad bullet hitting wall
1959 MSG_ReadVector(pos, cls.protocol);
1960 CL_FindNonSolidLocation(pos, pos, 4);
1961 if (cl_particles_quake.integer)
1962 CL_RunParticleEffect(pos, vec3_origin, 0, 20);
1965 CL_SparkShower(pos, vec3_origin, 15, 1, 0);
1966 CL_Smoke(pos, vec3_origin, 15, 0);
1969 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1970 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);
1975 MSG_ReadVector(pos, cls.protocol);
1976 CL_FindNonSolidLocation(pos, pos, 10);
1977 CL_ParticleExplosion(pos);
1978 // LordHavoc: boosted color from 1.0, 0.8, 0.4 to 1.25, 1.0, 0.5
1979 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1980 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);
1981 if (gamemode != GAME_NEXUIZ)
1982 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1985 case TE_EXPLOSIONQUAD:
1986 // quad rocket explosion
1987 MSG_ReadVector(pos, cls.protocol);
1988 CL_FindNonSolidLocation(pos, pos, 10);
1989 CL_ParticleExplosion(pos);
1990 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1991 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);
1992 if (gamemode != GAME_NEXUIZ)
1993 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1997 // Nehahra movie colored lighting explosion
1998 MSG_ReadVector(pos, cls.protocol);
1999 CL_FindNonSolidLocation(pos, pos, 10);
2000 CL_ParticleExplosion(pos);
2001 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2002 color[0] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
2003 color[1] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
2004 color[2] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
2005 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);
2006 if (gamemode != GAME_NEXUIZ)
2007 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2010 case TE_EXPLOSIONRGB:
2011 // colored lighting explosion
2012 MSG_ReadVector(pos, cls.protocol);
2013 CL_FindNonSolidLocation(pos, pos, 10);
2014 CL_ParticleExplosion(pos);
2015 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
2016 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
2017 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
2018 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2019 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);
2020 if (gamemode != GAME_NEXUIZ)
2021 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2024 case TE_TAREXPLOSION:
2025 // tarbaby explosion
2026 MSG_ReadVector(pos, cls.protocol);
2027 CL_FindNonSolidLocation(pos, pos, 10);
2028 CL_BlobExplosion(pos);
2030 if (gamemode != GAME_NEXUIZ)
2031 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2032 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2033 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);
2037 MSG_ReadVector(pos, cls.protocol);
2038 CL_FindNonSolidLocation(pos, pos, 10);
2039 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2040 CL_AllocDlight(NULL, &tempmatrix, 200, 2, 2, 2, 1000, 0.2, 0, -1, true, 1, 0.25, 1, 0, 0, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
2043 case TE_CUSTOMFLASH:
2044 MSG_ReadVector(pos, cls.protocol);
2045 CL_FindNonSolidLocation(pos, pos, 4);
2046 radius = (MSG_ReadByte() + 1) * 8;
2047 velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0);
2048 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
2049 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
2050 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
2051 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2052 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);
2056 MSG_ReadVector(pos, cls.protocol);
2057 MSG_ReadVector(dir, cls.protocol);
2058 count = MSG_ReadByte();
2059 CL_Flames(pos, dir, count);
2064 CL_ParseBeam(cl.model_bolt, true);
2069 CL_ParseBeam(cl.model_bolt2, true);
2074 CL_ParseBeam(cl.model_bolt3, false);
2079 // grappling hook beam
2080 CL_ParseBeam(cl.model_beam, false);
2084 // LordHavoc: for compatibility with the Nehahra movie...
2085 case TE_LIGHTNING4NEH:
2086 CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false);
2090 MSG_ReadVector(pos, cls.protocol);
2095 MSG_ReadVector(pos, cls.protocol);
2096 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2097 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);
2098 CL_TeleportSplash(pos);
2102 // color mapped explosion
2103 MSG_ReadVector(pos, cls.protocol);
2104 CL_FindNonSolidLocation(pos, pos, 10);
2105 colorStart = MSG_ReadByte();
2106 colorLength = MSG_ReadByte();
2107 CL_ParticleExplosion2(pos, colorStart, colorLength);
2108 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
2109 color[0] = tempcolor[0] * (2.0f / 255.0f);
2110 color[1] = tempcolor[1] * (2.0f / 255.0f);
2111 color[2] = tempcolor[2] * (2.0f / 255.0f);
2112 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2113 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);
2114 if (gamemode != GAME_NEXUIZ)
2115 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2119 MSG_ReadVector(pos, cls.protocol);
2120 MSG_ReadVector(pos2, cls.protocol);
2121 MSG_ReadVector(dir, cls.protocol);
2122 CL_BeamParticle(pos, pos2, 8, 1, 1, 1, 1, 1);
2126 MSG_ReadVector(pos, cls.protocol);
2127 MSG_ReadVector(dir, cls.protocol);
2128 count = MSG_ReadByte();
2129 CL_FindNonSolidLocation(pos, pos, 4);
2130 CL_Tei_Smoke(pos, dir, count);
2133 case TE_TEI_BIGEXPLOSION:
2134 MSG_ReadVector(pos, cls.protocol);
2135 CL_FindNonSolidLocation(pos, pos, 10);
2136 CL_ParticleExplosion(pos);
2137 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2138 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);
2139 if (gamemode != GAME_NEXUIZ)
2140 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2143 case TE_TEI_PLASMAHIT:
2144 MSG_ReadVector(pos, cls.protocol);
2145 MSG_ReadVector(dir, cls.protocol);
2146 count = MSG_ReadByte();
2147 CL_FindNonSolidLocation(pos, pos, 5);
2148 CL_Tei_PlasmaHit(pos, dir, count);
2149 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2150 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);
2154 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
2159 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
2162 void CL_VM_Init (void);
2163 qboolean CL_VM_Parse_TempEntity (void);
2164 void CL_VM_Parse_StuffCmd (const char *msg);
2165 void CL_VM_Parse_CenterPrint (const char *msg);
2166 void CSQC_AddPrintText (const char *msg);
2167 void CSQC_ReadEntities (void);
2169 static unsigned char cgamenetbuffer[65536];
2172 =====================
2173 CL_ParseServerMessage
2174 =====================
2176 int parsingerror = false;
2177 void CL_ParseServerMessage(void)
2181 protocolversion_t protocol;
2182 unsigned char cmdlog[32];
2183 char *cmdlogname[32], *temp;
2184 int cmdindex, cmdcount = 0;
2186 if (cls.demorecording)
2187 CL_WriteDemoMessage ();
2189 cl.last_received_message = realtime;
2192 // if recording demos, copy the message out
2194 if (cl_shownet.integer == 1)
2195 Con_Printf("%f %i\n", realtime, net_message.cursize);
2196 else if (cl_shownet.integer == 2)
2197 Con_Print("------------------\n");
2199 cl.onground = false; // unless the server says otherwise
2201 // parse the message
2203 //MSG_BeginReading ();
2205 parsingerror = true;
2207 if (cls.protocol == PROTOCOL_QUAKEWORLD)
2209 cl.mtime[1] = cl.mtime[0];
2210 cl.mtime[0] = realtime; // qw has no clock
2211 cl.movement_needupdate = true;
2213 // slightly kill qw player entities each frame
2214 for (i = 1;i < cl.maxclients;i++)
2215 cl_entities_active[i] = false;
2217 // kill all qw nails
2218 cl.qw_num_nails = 0;
2220 // fade weapon view kick
2221 cl.qw_weaponkick = min(cl.qw_weaponkick + 10 * cl.frametime, 0);
2226 Host_Error ("CL_ParseServerMessage: Bad QW server message");
2228 cmd = MSG_ReadByte ();
2232 SHOWNET("END OF MESSAGE");
2233 break; // end of message
2236 cmdindex = cmdcount & 31;
2238 cmdlog[cmdindex] = cmd;
2240 SHOWNET(qw_svc_strings[cmd]);
2241 cmdlogname[cmdindex] = qw_svc_strings[cmd];
2242 if (!cmdlogname[cmdindex])
2244 // 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)
2246 cmdlogname[cmdindex] = temp;
2254 char description[32*64], temp[64];
2256 strcpy(description, "packet dump: ");
2260 count = cmdcount - i;
2264 dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2265 strlcat(description, temp, sizeof(description));
2270 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2271 Con_Print(description);
2272 Host_Error("CL_ParseServerMessage: Illegible server message");
2277 //Con_Printf("qw_svc_nop\n");
2280 case qw_svc_disconnect:
2281 Con_Printf("Server disconnected\n");
2282 if (cls.demonum != -1)
2291 CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
2293 CSQC_AddPrintText(MSG_ReadString());
2296 case qw_svc_centerprint:
2297 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2300 case qw_svc_stufftext:
2301 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2305 // svc_damage protocol is identical to nq
2309 case qw_svc_serverdata:
2310 //Cbuf_Execute(); // make sure any stuffed commands are done
2311 CL_ParseServerInfo();
2312 CL_VM_Init(); //[515]: init csqc
2315 case qw_svc_setangle:
2316 for (i=0 ; i<3 ; i++)
2317 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2320 case qw_svc_lightstyle:
2321 i = MSG_ReadByte ();
2322 if (i >= cl_max_lightstyle)
2324 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2327 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2328 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2329 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2333 CL_ParseStartSoundPacket(false);
2336 case qw_svc_stopsound:
2337 i = (unsigned short) MSG_ReadShort();
2338 S_StopSound(i>>3, i&7);
2341 case qw_svc_updatefrags:
2343 if (i >= cl.maxclients)
2344 Host_Error("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2345 cl.scores[i].frags = (signed short) MSG_ReadShort();
2348 case qw_svc_updateping:
2350 if (i >= cl.maxclients)
2351 Host_Error("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
2352 cl.scores[i].qw_ping = MSG_ReadShort();
2355 case qw_svc_updatepl:
2357 if (i >= cl.maxclients)
2358 Host_Error("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
2359 cl.scores[i].qw_packetloss = MSG_ReadByte();
2362 case qw_svc_updateentertime:
2364 if (i >= cl.maxclients)
2365 Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
2367 cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
2370 case qw_svc_spawnbaseline:
2371 i = (unsigned short) MSG_ReadShort();
2372 if (i < 0 || i >= MAX_EDICTS)
2373 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2374 if (i >= cl_max_entities)
2375 CL_ExpandEntities(i);
2376 CL_ParseBaseline(cl_entities + i, false);
2378 case qw_svc_spawnstatic:
2379 CL_ParseStatic(false);
2381 case qw_svc_temp_entity:
2382 if(!CL_VM_Parse_TempEntity())
2383 CL_ParseTempEntity ();
2386 case qw_svc_killedmonster:
2387 cl.stats[STAT_MONSTERS]++;
2390 case qw_svc_foundsecret:
2391 cl.stats[STAT_SECRETS]++;
2394 case qw_svc_updatestat:
2395 i = MSG_ReadByte ();
2396 if (i < 0 || i >= MAX_CL_STATS)
2397 Host_Error ("svc_updatestat: %i is invalid", i);
2398 cl.stats[i] = MSG_ReadByte ();
2401 case qw_svc_updatestatlong:
2402 i = MSG_ReadByte ();
2403 if (i < 0 || i >= MAX_CL_STATS)
2404 Host_Error ("svc_updatestatlong: %i is invalid", i);
2405 cl.stats[i] = MSG_ReadLong ();
2408 case qw_svc_spawnstaticsound:
2409 CL_ParseStaticSound (false);
2412 case qw_svc_cdtrack:
2413 cl.cdtrack = cl.looptrack = MSG_ReadByte ();
2414 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2415 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2417 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2420 case qw_svc_intermission:
2421 cl.intermission = 1;
2422 cl.completed_time = cl.time;
2423 MSG_ReadVector(cl.qw_intermission_origin, cls.protocol);
2424 for (i = 0;i < 3;i++)
2425 cl.qw_intermission_angles[i] = MSG_ReadAngle(cls.protocol);
2429 cl.intermission = 2;
2430 cl.completed_time = cl.time;
2431 SCR_CenterPrint(MSG_ReadString ());
2434 case qw_svc_sellscreen:
2435 Cmd_ExecuteString ("help", src_command);
2438 case qw_svc_smallkick:
2439 cl.qw_weaponkick = -2;
2441 case qw_svc_bigkick:
2442 cl.qw_weaponkick = -4;
2445 case qw_svc_muzzleflash:
2446 i = (unsigned short) MSG_ReadShort();
2447 // NOTE: in QW this only worked on clients
2448 if (i < 0 || i >= MAX_EDICTS)
2449 Host_Error("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2450 if (i >= cl_max_entities)
2451 CL_ExpandEntities(i);
2452 cl_entities[i].persistent.muzzleflash = 1.0f;
2455 case qw_svc_updateuserinfo:
2456 QW_CL_UpdateUserInfo();
2459 case qw_svc_setinfo:
2463 case qw_svc_serverinfo:
2467 case qw_svc_download:
2468 QW_CL_ParseDownload();
2471 case qw_svc_playerinfo:
2472 EntityStateQW_ReadPlayerUpdate();
2479 case qw_svc_chokecount:
2481 // FIXME: apply to netgraph
2482 //for (j = 0;j < i;j++)
2483 // cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK].receivedtime = -2;
2486 case qw_svc_modellist:
2487 QW_CL_ParseModelList();
2490 case qw_svc_soundlist:
2491 QW_CL_ParseSoundList();
2494 case qw_svc_packetentities:
2495 EntityFrameQW_CL_ReadFrame(false);
2496 // first update is the final signon stage
2497 if (cls.signon == SIGNONS - 1)
2498 cls.signon = SIGNONS;
2501 case qw_svc_deltapacketentities:
2502 EntityFrameQW_CL_ReadFrame(true);
2503 // first update is the final signon stage
2504 if (cls.signon == SIGNONS - 1)
2505 cls.signon = SIGNONS;
2508 case qw_svc_maxspeed:
2509 cl.qw_movevars_maxspeed = MSG_ReadFloat();
2512 case qw_svc_entgravity:
2513 cl.qw_movevars_entgravity = MSG_ReadFloat();
2516 case qw_svc_setpause:
2517 cl.paused = MSG_ReadByte ();
2522 S_PauseGameSounds (cl.paused);
2527 // fully kill the still slightly dead qw player entities each frame
2528 for (i = 1;i < cl.maxclients;i++)
2529 if (!cl_entities_active[i])
2530 cl_entities[i].state_current.active = false;
2532 QW_CL_UpdateItemsAndWeapon();
2539 Host_Error ("CL_ParseServerMessage: Bad server message");
2541 cmd = MSG_ReadByte ();
2545 SHOWNET("END OF MESSAGE");
2546 break; // end of message
2549 cmdindex = cmdcount & 31;
2551 cmdlog[cmdindex] = cmd;
2553 // if the high bit of the command byte is set, it is a fast update
2556 // 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)
2558 cmdlogname[cmdindex] = temp;
2559 SHOWNET("fast update");
2560 if (cls.signon == SIGNONS - 1)
2562 // first update is the final signon stage
2563 cls.signon = SIGNONS;
2566 EntityFrameQuake_ReadEntity (cmd&127);
2570 SHOWNET(svc_strings[cmd]);
2571 cmdlogname[cmdindex] = svc_strings[cmd];
2572 if (!cmdlogname[cmdindex])
2574 // 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)
2576 cmdlogname[cmdindex] = temp;
2584 char description[32*64], temp[64];
2586 strcpy (description, "packet dump: ");
2590 count = cmdcount - i;
2594 dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2595 strlcat (description, temp, sizeof (description));
2600 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2601 Con_Print(description);
2602 Host_Error ("CL_ParseServerMessage: Illegible server message");
2607 if (cls.signon < SIGNONS)
2608 Con_Print("<-- server to client keepalive\n");
2612 cl.mtime[1] = cl.mtime[0];
2613 cl.mtime[0] = MSG_ReadFloat ();
2614 cl.movement_needupdate = true;
2617 case svc_clientdata:
2618 CL_ParseClientdata();
2622 i = MSG_ReadLong ();
2623 protocol = Protocol_EnumForNumber(i);
2624 if (protocol == PROTOCOL_UNKNOWN)
2625 Host_Error("CL_ParseServerMessage: Server is unrecognized protocol number (%i)", i);
2626 // hack for unmarked Nehahra movie demos which had a custom protocol
2627 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
2628 protocol = PROTOCOL_NEHAHRAMOVIE;
2629 cls.protocol = protocol;
2632 case svc_disconnect:
2633 Con_Printf ("Server disconnected\n");
2634 if (cls.demonum != -1)
2641 CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
2644 case svc_centerprint:
2645 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2649 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2656 case svc_serverinfo:
2657 CL_ParseServerInfo ();
2658 CL_VM_Init(); //[515]: init csqc
2662 for (i=0 ; i<3 ; i++)
2663 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2667 cl.viewentity = (unsigned short)MSG_ReadShort ();
2668 if (cl.viewentity >= MAX_EDICTS)
2669 Host_Error("svc_setview >= MAX_EDICTS");
2670 if (cl.viewentity >= cl_max_entities)
2671 CL_ExpandEntities(cl.viewentity);
2672 // LordHavoc: assume first setview recieved is the real player entity
2673 if (!cl.playerentity)
2674 cl.playerentity = cl.viewentity;
2677 case svc_lightstyle:
2678 i = MSG_ReadByte ();
2679 if (i >= cl_max_lightstyle)
2681 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2684 strlcpy (cl_lightstyle[i].map, MSG_ReadString(), sizeof (cl_lightstyle[i].map));
2685 cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2686 cl_lightstyle[i].length = (int)strlen(cl_lightstyle[i].map);
2690 CL_ParseStartSoundPacket(false);
2694 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2696 // was svc_sound2 in protocols 1, 2, 3, removed in 4, 5, changed to svc_precache in 6
2697 CL_ParseStartSoundPacket(true);
2701 int i = (unsigned short)MSG_ReadShort();
2702 char *s = MSG_ReadString();
2705 if (i >= 1 && i < MAX_MODELS)
2707 model_t *model = Mod_ForName(s, false, false, i == 1);
2709 Con_Printf("svc_precache: Mod_ForName(\"%s\") failed\n", s);
2710 cl.model_precache[i] = model;
2713 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_MODELS);
2718 if (i >= 1 && i < MAX_SOUNDS)
2720 sfx_t *sfx = S_PrecacheSound (s, true, false);
2721 if (!sfx && snd_initialized.integer)
2722 Con_Printf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s);
2723 cl.sound_precache[i] = sfx;
2726 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_SOUNDS);
2732 i = (unsigned short) MSG_ReadShort();
2733 S_StopSound(i>>3, i&7);
2736 case svc_updatename:
2737 i = MSG_ReadByte ();
2738 if (i >= cl.maxclients)
2739 Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
2740 strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
2743 case svc_updatefrags:
2744 i = MSG_ReadByte ();
2745 if (i >= cl.maxclients)
2746 Host_Error ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2747 cl.scores[i].frags = (signed short) MSG_ReadShort ();
2750 case svc_updatecolors:
2751 i = MSG_ReadByte ();
2752 if (i >= cl.maxclients)
2753 Host_Error ("CL_ParseServerMessage: svc_updatecolors >= cl.maxclients");
2754 cl.scores[i].colors = MSG_ReadByte ();
2758 CL_ParseParticleEffect ();
2769 case svc_spawnbaseline:
2770 i = (unsigned short) MSG_ReadShort ();
2771 if (i < 0 || i >= MAX_EDICTS)
2772 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2773 if (i >= cl_max_entities)
2774 CL_ExpandEntities(i);
2775 CL_ParseBaseline (cl_entities + i, false);
2777 case svc_spawnbaseline2:
2778 i = (unsigned short) MSG_ReadShort ();
2779 if (i < 0 || i >= MAX_EDICTS)
2780 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline2: invalid entity number %i", i);
2781 if (i >= cl_max_entities)
2782 CL_ExpandEntities(i);
2783 CL_ParseBaseline (cl_entities + i, true);
2785 case svc_spawnstatic:
2786 CL_ParseStatic (false);
2788 case svc_spawnstatic2:
2789 CL_ParseStatic (true);
2791 case svc_temp_entity:
2792 if(!CL_VM_Parse_TempEntity())
2793 CL_ParseTempEntity ();
2797 cl.paused = MSG_ReadByte ();
2802 S_PauseGameSounds (cl.paused);
2806 i = MSG_ReadByte ();
2807 // LordHavoc: it's rude to kick off the client if they missed the
2808 // reconnect somehow, so allow signon 1 even if at signon 1
2809 if (i <= cls.signon && i != 1)
2810 Host_Error ("Received signon %i when at %i", i, cls.signon);
2815 case svc_killedmonster:
2816 cl.stats[STAT_MONSTERS]++;
2819 case svc_foundsecret:
2820 cl.stats[STAT_SECRETS]++;
2823 case svc_updatestat:
2824 i = MSG_ReadByte ();
2825 if (i < 0 || i >= MAX_CL_STATS)
2826 Host_Error ("svc_updatestat: %i is invalid", i);
2827 cl.stats[i] = MSG_ReadLong ();
2830 case svc_updatestatubyte:
2831 i = MSG_ReadByte ();
2832 if (i < 0 || i >= MAX_CL_STATS)
2833 Host_Error ("svc_updatestat: %i is invalid", i);
2834 cl.stats[i] = MSG_ReadByte ();
2837 case svc_spawnstaticsound:
2838 CL_ParseStaticSound (false);
2841 case svc_spawnstaticsound2:
2842 CL_ParseStaticSound (true);
2846 cl.cdtrack = MSG_ReadByte ();
2847 cl.looptrack = MSG_ReadByte ();
2848 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2849 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2851 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2854 case svc_intermission:
2855 cl.intermission = 1;
2856 cl.completed_time = cl.time;
2860 cl.intermission = 2;
2861 cl.completed_time = cl.time;
2862 SCR_CenterPrint(MSG_ReadString ());
2866 cl.intermission = 3;
2867 cl.completed_time = cl.time;
2868 SCR_CenterPrint(MSG_ReadString ());
2871 case svc_sellscreen:
2872 Cmd_ExecuteString ("help", src_command);
2875 if (gamemode == GAME_TENEBRAE)
2877 // repeating particle effect
2878 MSG_ReadCoord(cls.protocol);
2879 MSG_ReadCoord(cls.protocol);
2880 MSG_ReadCoord(cls.protocol);
2881 MSG_ReadCoord(cls.protocol);
2882 MSG_ReadCoord(cls.protocol);
2883 MSG_ReadCoord(cls.protocol);
2890 SHOWLMP_decodehide();
2893 if (gamemode == GAME_TENEBRAE)
2896 MSG_ReadCoord(cls.protocol);
2897 MSG_ReadCoord(cls.protocol);
2898 MSG_ReadCoord(cls.protocol);
2903 SHOWLMP_decodeshow();
2906 R_SetSkyBox(MSG_ReadString());
2911 length = (int) ((unsigned short) MSG_ReadShort());
2912 for (i = 0;i < length;i++)
2913 cgamenetbuffer[i] = MSG_ReadByte();
2915 CL_CGVM_ParseNetwork(cgamenetbuffer, length);
2919 if (cls.signon == SIGNONS - 1)
2921 // first update is the final signon stage
2922 cls.signon = SIGNONS;
2925 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2926 EntityFrame_CL_ReadFrame();
2927 else if (cls.protocol == PROTOCOL_DARKPLACES4)
2928 EntityFrame4_CL_ReadFrame();
2930 EntityFrame5_CL_ReadFrame();
2932 case svc_csqcentities:
2933 CSQC_ReadEntities();
2939 EntityFrameQuake_ISeeDeadEntities();
2941 parsingerror = false;
2944 void CL_Parse_DumpPacket(void)
2948 Con_Print("Packet dump:\n");
2949 SZ_HexDumpToConsole(&net_message);
2950 parsingerror = false;
2953 void CL_Parse_ErrorCleanUp(void)
2955 if (cls.qw_downloadmemory)
2957 Mem_Free(cls.qw_downloadmemory);
2958 cls.qw_downloadmemory = NULL;
2960 cls.qw_downloadpercent = 0;
2964 void CL_Parse_Init(void)
2966 // LordHavoc: added demo_nehahra cvar
2967 Cvar_RegisterVariable (&demo_nehahra);
2968 if (gamemode == GAME_NEHAHRA)
2969 Cvar_SetValue("demo_nehahra", 1);
2970 Cvar_RegisterVariable(&developer_networkentities);
2972 Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
2973 Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
2974 Cmd_AddCommand("skins", QW_CL_Skins_f, "downloads missing qw skins from server");
2975 Cmd_AddCommand("changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change");
2978 void CL_Parse_Shutdown(void)