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_unusedlh1", // 50 //
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)"};
160 cvar_t cl_sound_wizardhit = {0, "cl_sound_wizardhit", "wizard/hit.wav", "sound to play during TE_WIZSPIKE (empty cvar disables sound)"};
161 cvar_t cl_sound_hknighthit = {0, "cl_sound_hknighthit", "hknight/hit.wav", "sound to play during TE_KNIGHTSPIKE (empty cvar disables sound)"};
162 cvar_t cl_sound_tink1 = {0, "cl_sound_tink1", "weapons/tink1.wav", "sound to play with 80% chance during TE_SPIKE/TE_SUPERSPIKE (empty cvar disables sound)"};
163 cvar_t cl_sound_ric1 = {0, "cl_sound_ric1", "weapons/ric1.wav", "sound to play with 5% chance during TE_SPIKE/TE_SUPERSPIKE (empty cvar disables sound)"};
164 cvar_t cl_sound_ric2 = {0, "cl_sound_ric2", "weapons/ric2.wav", "sound to play with 5% chance during TE_SPIKE/TE_SUPERSPIKE (empty cvar disables sound)"};
165 cvar_t cl_sound_ric3 = {0, "cl_sound_ric3", "weapons/ric3.wav", "sound to play with 10% chance during TE_SPIKE/TE_SUPERSPIKE (empty cvar disables sound)"};
166 cvar_t cl_sound_r_exp3 = {0, "cl_sound_r_exp3", "weapons/r_exp3.wav", "sound to play during TE_EXPLOSION and related effects (empty cvar disables sound)"};
168 static qboolean QW_CL_CheckOrDownloadFile(const char *filename);
169 static void QW_CL_RequestNextDownload(void);
170 static void QW_CL_NextUpload(void);
171 void QW_CL_StartUpload(unsigned char *data, int size);
172 //static qboolean QW_CL_IsUploading(void);
173 static void QW_CL_StopUpload(void);
177 CL_ParseStartSoundPacket
180 void CL_ParseStartSoundPacket(int largesoundindex)
189 if (cls.protocol == PROTOCOL_QUAKEWORLD)
191 channel = MSG_ReadShort();
193 if (channel & (1<<15))
194 volume = MSG_ReadByte ();
196 volume = DEFAULT_SOUND_PACKET_VOLUME;
198 if (channel & (1<<14))
199 attenuation = MSG_ReadByte () / 64.0;
201 attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
203 ent = (channel>>3)&1023;
206 sound_num = MSG_ReadByte ();
210 field_mask = MSG_ReadByte();
212 if (field_mask & SND_VOLUME)
213 volume = MSG_ReadByte ();
215 volume = DEFAULT_SOUND_PACKET_VOLUME;
217 if (field_mask & SND_ATTENUATION)
218 attenuation = MSG_ReadByte () / 64.0;
220 attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
222 if (field_mask & SND_LARGEENTITY)
224 ent = (unsigned short) MSG_ReadShort ();
225 channel = MSG_ReadByte ();
229 channel = (unsigned short) MSG_ReadShort ();
234 if (largesoundindex || field_mask & SND_LARGESOUND)
235 sound_num = (unsigned short) MSG_ReadShort ();
237 sound_num = MSG_ReadByte ();
240 MSG_ReadVector(pos, cls.protocol);
242 if (sound_num >= MAX_SOUNDS)
244 Con_Printf("CL_ParseStartSoundPacket: sound_num (%i) >= MAX_SOUNDS (%i)\n", sound_num, MAX_SOUNDS);
248 if (ent >= MAX_EDICTS)
250 Con_Printf("CL_ParseStartSoundPacket: ent = %i", ent);
254 S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation);
261 When the client is taking a long time to load stuff, send keepalive messages
262 so the server doesn't disconnect.
266 static unsigned char olddata[NET_MAXMESSAGE];
267 void CL_KeepaliveMessage (void)
270 static double nextmsg = -1;
275 // no need if server is local and definitely not if this is a demo
276 if (sv.active || !cls.netcon || cls.protocol == PROTOCOL_QUAKEWORLD)
279 // read messages from server, should just be nops
280 oldreadcount = msg_readcount;
281 oldbadread = msg_badread;
283 memcpy(olddata, net_message.data, net_message.cursize);
285 NetConn_ClientFrame();
287 msg_readcount = oldreadcount;
288 msg_badread = oldbadread;
290 memcpy(net_message.data, olddata, net_message.cursize);
292 if (cls.netcon && (time = Sys_DoubleTime()) >= nextmsg)
295 unsigned char buf[4];
298 // LordHavoc: must use unreliable because reliable could kill the sigon message!
299 Con_Print("--> client to server keepalive\n");
300 memset(&msg, 0, sizeof(msg));
302 msg.maxsize = sizeof(buf);
303 MSG_WriteChar(&msg, svc_nop);
304 NetConn_SendUnreliableMessage(cls.netcon, &msg, cls.protocol);
308 void CL_ParseEntityLump(char *entdata)
311 char key[128], value[MAX_INPUTLINE];
312 FOG_clear(); // LordHavoc: no fog until set
313 // LordHavoc: default to the map's sky (q3 shader parsing sets this)
314 R_SetSkyBox(cl.worldmodel->brush.skybox);
318 if (!COM_ParseToken(&data, false))
320 if (com_token[0] != '{')
324 if (!COM_ParseToken(&data, false))
326 if (com_token[0] == '}')
327 break; // end of worldspawn
328 if (com_token[0] == '_')
329 strlcpy (key, com_token + 1, sizeof (key));
331 strlcpy (key, com_token, sizeof (key));
332 while (key[strlen(key)-1] == ' ') // remove trailing spaces
333 key[strlen(key)-1] = 0;
334 if (!COM_ParseToken(&data, false))
336 strlcpy (value, com_token, sizeof (value));
337 if (!strcmp("sky", key))
339 else if (!strcmp("skyname", key)) // non-standard, introduced by QuakeForge... sigh.
341 else if (!strcmp("qlsky", key)) // non-standard, introduced by QuakeLives (EEK)
343 else if (!strcmp("fog", key))
344 sscanf(value, "%f %f %f %f", &fog_density, &fog_red, &fog_green, &fog_blue);
345 else if (!strcmp("fog_density", key))
346 fog_density = atof(value);
347 else if (!strcmp("fog_red", key))
348 fog_red = atof(value);
349 else if (!strcmp("fog_green", key))
350 fog_green = atof(value);
351 else if (!strcmp("fog_blue", key))
352 fog_blue = atof(value);
356 static qboolean QW_CL_CheckOrDownloadFile(const char *filename)
360 // see if the file already exists
361 file = FS_Open(filename, "rb", true, false);
368 // download messages in a demo would be bad
369 if (cls.demorecording)
371 Con_Printf("Unable to download \"%s\" when recording.\n", filename);
375 // don't try to download when playing a demo
379 strlcpy(cls.qw_downloadname, filename, sizeof(cls.qw_downloadname));
380 Con_Printf("Downloading %s\n", filename);
382 if (!cls.qw_downloadmemory)
384 cls.qw_downloadmemory = NULL;
385 cls.qw_downloadmemorycursize = 0;
386 cls.qw_downloadmemorymaxsize = 1024*1024; // start out with a 1MB buffer
389 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
390 MSG_WriteString(&cls.netcon->message, va("download %s", filename));
392 cls.qw_downloadnumber++;
393 cls.qw_downloadpercent = 0;
398 static void QW_CL_ProcessUserInfo(int slot);
399 static void QW_CL_RequestNextDownload(void)
403 // clear name of file that just finished
404 cls.qw_downloadname[0] = 0;
406 switch (cls.qw_downloadtype)
411 if (cls.qw_downloadnumber == 0)
412 Con_Printf("Checking skins...\n");
413 for (;cls.qw_downloadnumber < cl.maxclients;cls.qw_downloadnumber++)
415 if (!cl.scores[cls.qw_downloadnumber].name[0])
417 // check if we need to download the file, and return if so
418 if (!QW_CL_CheckOrDownloadFile(va("skins/%s.pcx", cl.scores[cls.qw_downloadnumber].qw_skin)))
422 cls.qw_downloadtype = dl_none;
424 // load any newly downloaded skins
425 for (i = 0;i < cl.maxclients;i++)
426 QW_CL_ProcessUserInfo(i);
428 // if we're still in signon stages, request the next one
429 if (cls.signon != SIGNONS)
431 cls.signon = SIGNONS-1;
432 // we'll go to SIGNONS when the first entity update is received
433 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
434 MSG_WriteString(&cls.netcon->message, va("begin %i", cl.qw_servercount));
438 if (cls.qw_downloadnumber == 0)
440 Con_Printf("Checking models...\n");
441 cls.qw_downloadnumber = 1;
444 for (;cls.qw_downloadnumber < MAX_MODELS && cl.model_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
447 if (cl.model_name[cls.qw_downloadnumber][0] == '*')
449 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/spike.mdl"))
450 cl.qw_modelindex_spike = cls.qw_downloadnumber;
451 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/player.mdl"))
452 cl.qw_modelindex_player = cls.qw_downloadnumber;
453 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/flag.mdl"))
454 cl.qw_modelindex_flag = cls.qw_downloadnumber;
455 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/s_explod.spr"))
456 cl.qw_modelindex_s_explod = cls.qw_downloadnumber;
457 // check if we need to download the file, and return if so
458 if (!QW_CL_CheckOrDownloadFile(cl.model_name[cls.qw_downloadnumber]))
462 cls.qw_downloadtype = dl_none;
464 // touch all of the precached models that are still loaded so we can free
465 // anything that isn't needed
467 for (i = 1;i < MAX_MODELS && cl.model_name[i][0];i++)
468 Mod_FindName(cl.model_name[i]);
469 // precache any models used by the client (this also marks them used)
470 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
471 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
472 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
473 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
476 // now we try to load everything that is new
479 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
480 if (cl.model_precache[1]->Draw == NULL)
481 Con_Printf("Map %s could not be found or downloaded\n", cl.model_name[1]);
484 for (i = 2;i < MAX_MODELS && cl.model_name[i][0];i++)
485 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
486 Con_Printf("Model %s could not be found or downloaded\n", cl.model_name[i]);
488 // check memory integrity
489 Mem_CheckSentinelsGlobal();
491 // now that we have a world model, set up the world entity, renderer
493 cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1];
494 CL_BoundingBoxForEntity(&cl.entities[0].render);
498 // done checking sounds and models, send a prespawn command now
499 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
500 MSG_WriteString(&cls.netcon->message, va("prespawn %i 0 %i", cl.qw_servercount, cl.model_precache[1]->brush.qw_md4sum2));
502 if (cls.qw_downloadmemory)
504 Mem_Free(cls.qw_downloadmemory);
505 cls.qw_downloadmemory = NULL;
509 if (cls.qw_downloadnumber == 0)
511 Con_Printf("Checking sounds...\n");
512 cls.qw_downloadnumber = 1;
515 for (;cl.sound_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
517 // check if we need to download the file, and return if so
518 if (!QW_CL_CheckOrDownloadFile(va("sound/%s", cl.sound_name[cls.qw_downloadnumber])))
522 cls.qw_downloadtype = dl_none;
524 // load new sounds and unload old ones
525 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
526 S_ServerSounds(cl.sound_name, cls.qw_downloadnumber);
528 // precache any sounds used by the client
529 cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true);
530 cl.sfx_knighthit = S_PrecacheSound(cl_sound_hknighthit.string, false, true);
531 cl.sfx_tink1 = S_PrecacheSound(cl_sound_tink1.string, false, true);
532 cl.sfx_ric1 = S_PrecacheSound(cl_sound_ric1.string, false, true);
533 cl.sfx_ric2 = S_PrecacheSound(cl_sound_ric2.string, false, true);
534 cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true);
535 cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true);
538 for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++)
540 // Don't lock the sfx here, S_ServerSounds already did that
541 cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, false);
544 // check memory integrity
545 Mem_CheckSentinelsGlobal();
547 // done with sound downloads, next we check models
548 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
549 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, 0));
553 Con_Printf("Unknown download type.\n");
557 static void QW_CL_ParseDownload(void)
559 int size = (signed short)MSG_ReadShort();
560 int percent = MSG_ReadByte();
562 //Con_Printf("download %i %i%% (%i/%i)\n", size, percent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize);
564 // skip the download fragment if playing a demo
568 msg_readcount += size;
574 Con_Printf("File not found.\n");
575 QW_CL_RequestNextDownload();
579 if (msg_readcount + (unsigned short)size > net_message.cursize)
580 Host_Error("corrupt download message\n");
582 // make sure the buffer is big enough to include this new fragment
583 if (!cls.qw_downloadmemory || cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
586 while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
587 cls.qw_downloadmemorymaxsize *= 2;
588 old = cls.qw_downloadmemory;
589 cls.qw_downloadmemory = (unsigned char *)Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
592 memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize);
597 // read the fragment out of the packet
598 MSG_ReadBytes(size, cls.qw_downloadmemory + cls.qw_downloadmemorycursize);
599 cls.qw_downloadmemorycursize += size;
601 cls.qw_downloadpercent = percent;
605 // request next fragment
606 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
607 MSG_WriteString(&cls.netcon->message, "nextdl");
612 Con_Printf("Downloaded \"%s\"\n", cls.qw_downloadname);
614 FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
616 cls.qw_downloadpercent = 0;
618 // start downloading the next file (or join the game)
619 QW_CL_RequestNextDownload();
623 static void QW_CL_ParseModelList(void)
626 int nummodels = MSG_ReadByte();
629 // parse model precache list
632 str = MSG_ReadString();
636 if (nummodels==MAX_MODELS)
637 Host_Error("Server sent too many model precaches");
638 if (strlen(str) >= MAX_QPATH)
639 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
640 strlcpy(cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
646 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
647 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, n));
652 cls.qw_downloadnumber = 0;
653 cls.qw_downloadtype = dl_model;
654 QW_CL_RequestNextDownload();
657 static void QW_CL_ParseSoundList(void)
660 int numsounds = MSG_ReadByte();
663 // parse sound precache list
666 str = MSG_ReadString();
670 if (numsounds==MAX_SOUNDS)
671 Host_Error("Server sent too many sound precaches");
672 if (strlen(str) >= MAX_QPATH)
673 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
674 strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
681 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
682 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, n));
687 cls.qw_downloadnumber = 0;
688 cls.qw_downloadtype = dl_sound;
689 QW_CL_RequestNextDownload();
692 static void QW_CL_Skins_f(void)
694 cls.qw_downloadnumber = 0;
695 cls.qw_downloadtype = dl_skin;
696 QW_CL_RequestNextDownload();
699 static void QW_CL_Changing_f(void)
701 if (cls.qw_downloadmemory) // don't change when downloading
706 cls.signon = 1; // not active anymore, but not disconnected
707 Con_Printf("\nChanging map...\n");
710 void QW_CL_NextUpload(void)
712 int r, percent, size;
714 if (!cls.qw_uploaddata)
717 r = cls.qw_uploadsize - cls.qw_uploadpos;
720 size = min(1, cls.qw_uploadsize);
721 percent = (cls.qw_uploadpos+r)*100/size;
723 MSG_WriteByte(&cls.netcon->message, qw_clc_upload);
724 MSG_WriteShort(&cls.netcon->message, r);
725 MSG_WriteByte(&cls.netcon->message, percent);
726 SZ_Write(&cls.netcon->message, cls.qw_uploaddata + cls.qw_uploadpos, r);
728 Con_DPrintf("UPLOAD: %6d: %d written\n", cls.qw_uploadpos, r);
730 cls.qw_uploadpos += r;
732 if (cls.qw_uploadpos < cls.qw_uploadsize)
735 Con_Printf("Upload completed\n");
740 void QW_CL_StartUpload(unsigned char *data, int size)
742 // do nothing in demos or if not connected
746 // abort existing upload if in progress
749 Con_DPrintf("Starting upload of %d bytes...\n", size);
751 cls.qw_uploaddata = (unsigned char *)Mem_Alloc(cls.permanentmempool, size);
752 memcpy(cls.qw_uploaddata, data, size);
753 cls.qw_uploadsize = size;
754 cls.qw_uploadpos = 0;
760 qboolean QW_CL_IsUploading(void)
762 return cls.qw_uploaddata != NULL;
766 void QW_CL_StopUpload(void)
768 if (cls.qw_uploaddata)
769 Mem_Free(cls.qw_uploaddata);
770 cls.qw_uploaddata = NULL;
771 cls.qw_uploadsize = 0;
772 cls.qw_uploadpos = 0;
775 static void QW_CL_ProcessUserInfo(int slot)
777 int topcolor, bottomcolor;
779 InfoString_GetValue(cl.scores[slot].qw_userinfo, "name", cl.scores[slot].name, sizeof(cl.scores[slot].name));
780 InfoString_GetValue(cl.scores[slot].qw_userinfo, "topcolor", temp, sizeof(temp));topcolor = atoi(temp);
781 InfoString_GetValue(cl.scores[slot].qw_userinfo, "bottomcolor", temp, sizeof(temp));bottomcolor = atoi(temp);
782 cl.scores[slot].colors = topcolor * 16 + bottomcolor;
783 InfoString_GetValue(cl.scores[slot].qw_userinfo, "*spectator", temp, sizeof(temp));
784 cl.scores[slot].qw_spectator = temp[0] != 0;
785 InfoString_GetValue(cl.scores[slot].qw_userinfo, "team", cl.scores[slot].qw_team, sizeof(cl.scores[slot].qw_team));
786 InfoString_GetValue(cl.scores[slot].qw_userinfo, "skin", cl.scores[slot].qw_skin, sizeof(cl.scores[slot].qw_skin));
787 if (!cl.scores[slot].qw_skin[0])
788 strlcpy(cl.scores[slot].qw_skin, "base", sizeof(cl.scores[slot].qw_skin));
792 static void QW_CL_UpdateUserInfo(void)
795 slot = MSG_ReadByte();
796 if (slot >= cl.maxclients)
798 Con_Printf("svc_updateuserinfo >= cl.maxclients\n");
803 cl.scores[slot].qw_userid = MSG_ReadLong();
804 strlcpy(cl.scores[slot].qw_userinfo, MSG_ReadString(), sizeof(cl.scores[slot].qw_userinfo));
806 QW_CL_ProcessUserInfo(slot);
809 static void QW_CL_SetInfo(void)
814 slot = MSG_ReadByte();
815 strlcpy(key, MSG_ReadString(), sizeof(key));
816 strlcpy(value, MSG_ReadString(), sizeof(value));
817 if (slot >= cl.maxclients)
819 Con_Printf("svc_setinfo >= cl.maxclients\n");
822 InfoString_SetValue(cl.scores[slot].qw_userinfo, sizeof(cl.scores[slot].qw_userinfo), key, value);
824 QW_CL_ProcessUserInfo(slot);
827 static void QW_CL_ServerInfo(void)
832 strlcpy(key, MSG_ReadString(), sizeof(key));
833 strlcpy(value, MSG_ReadString(), sizeof(value));
834 Con_DPrintf("SERVERINFO: %s=%s\n", key, value);
835 InfoString_SetValue(cl.qw_serverinfo, sizeof(cl.qw_serverinfo), key, value);
836 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
837 cl.qw_teamplay = atoi(temp);
840 static void QW_CL_ParseNails(void)
843 int numnails = MSG_ReadByte();
845 unsigned char bits[6];
846 for (i = 0;i < numnails;i++)
848 for (j = 0;j < 6;j++)
849 bits[j] = MSG_ReadByte();
850 if (cl.qw_num_nails > 255)
852 v = cl.qw_nails[cl.qw_num_nails++];
853 v[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096;
854 v[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096;
855 v[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096;
856 v[3] = -360*(bits[4]>>4)/16;
857 v[4] = 360*bits[5]/256;
862 static void CL_UpdateItemsAndWeapon(void)
865 // check for important changes
868 if (cl.olditems != cl.stats[STAT_ITEMS])
869 for (j = 0;j < 32;j++)
870 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
871 cl.item_gettime[j] = cl.time;
872 cl.olditems = cl.stats[STAT_ITEMS];
874 // GAME_NEXUIZ hud needs weapon change time
875 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
876 cl.weapontime = cl.time;
877 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
881 =====================
884 An svc_signonnum has been received, perform a client side setup
885 =====================
887 static void CL_SignonReply (void)
889 Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
896 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
897 MSG_WriteString (&cls.netcon->message, "prespawn");
904 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
905 MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
907 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
908 MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
910 if (cl_pmodel.integer)
912 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
913 MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
915 if (*cl_playermodel.string)
917 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
918 MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
920 if (*cl_playerskin.string)
922 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
923 MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
926 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
927 MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
929 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
930 MSG_WriteString (&cls.netcon->message, "spawn");
937 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
938 MSG_WriteString (&cls.netcon->message, "begin");
953 void CL_ParseServerInfo (void)
957 protocolversion_t protocol;
958 int nummodels, numsounds;
960 Con_DPrint("Serverinfo packet received.\n");
962 // if server is active, we already began a loading plaque
964 SCR_BeginLoadingPlaque();
966 // check memory integrity
967 Mem_CheckSentinelsGlobal();
970 // wipe the client_state_t struct
974 // parse protocol version number
976 protocol = Protocol_EnumForNumber(i);
977 if (protocol == PROTOCOL_UNKNOWN)
979 Host_Error("CL_ParseServerInfo: Server is unrecognized protocol number (%i)", i);
982 // hack for unmarked Nehahra movie demos which had a custom protocol
983 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
984 protocol = PROTOCOL_NEHAHRAMOVIE;
985 cls.protocol = protocol;
986 Con_DPrintf("Server protocol is %s\n", Protocol_NameForEnum(cls.protocol));
990 if (protocol == PROTOCOL_QUAKEWORLD)
992 cl.qw_servercount = MSG_ReadLong();
994 str = MSG_ReadString();
995 Con_Printf("server gamedir is %s\n", str);
997 // FIXME: change gamedir if needed!
998 if (strcasecmp(gamedirfile, str))
1000 Host_SaveConfig_f();
1004 Com_Gamedir(str); // change gamedir
1008 // exec the new config stuff
1012 cl.gametype = GAME_DEATHMATCH;
1015 // parse player number
1017 cl.qw_spectator = (i & 128) != 0;
1018 cl.playerentity = cl.viewentity = (i & 127) + 1;
1019 cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
1021 // get the full level name
1022 str = MSG_ReadString ();
1023 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1026 cl.qw_movevars_gravity = MSG_ReadFloat();
1027 cl.qw_movevars_stopspeed = MSG_ReadFloat();
1028 cl.qw_movevars_maxspeed = MSG_ReadFloat();
1029 cl.qw_movevars_spectatormaxspeed = MSG_ReadFloat();
1030 cl.qw_movevars_accelerate = MSG_ReadFloat();
1031 cl.qw_movevars_airaccelerate = MSG_ReadFloat();
1032 cl.qw_movevars_wateraccelerate = MSG_ReadFloat();
1033 cl.qw_movevars_friction = MSG_ReadFloat();
1034 cl.qw_movevars_waterfriction = MSG_ReadFloat();
1035 cl.qw_movevars_entgravity = MSG_ReadFloat();
1037 // seperate the printfs so the server message can have a color
1038 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);
1040 // check memory integrity
1041 Mem_CheckSentinelsGlobal();
1043 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
1044 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, 0));
1046 cls.state = ca_connected;
1049 // note: on QW protocol we can't set up the gameworld until after
1050 // downloads finish...
1051 // (we don't even know the name of the map yet)
1056 cl.maxclients = MSG_ReadByte ();
1057 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
1059 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
1062 cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
1065 cl.gametype = MSG_ReadByte ();
1067 // parse signon message
1068 str = MSG_ReadString ();
1069 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1071 // seperate the printfs so the server message can have a color
1072 if (cls.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
1073 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);
1075 // check memory integrity
1076 Mem_CheckSentinelsGlobal();
1078 // parse model precache list
1079 for (nummodels=1 ; ; nummodels++)
1081 str = MSG_ReadString();
1084 if (nummodels==MAX_MODELS)
1085 Host_Error ("Server sent too many model precaches");
1086 if (strlen(str) >= MAX_QPATH)
1087 Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1088 strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
1090 // parse sound precache list
1091 for (numsounds=1 ; ; numsounds++)
1093 str = MSG_ReadString();
1096 if (numsounds==MAX_SOUNDS)
1097 Host_Error("Server sent too many sound precaches");
1098 if (strlen(str) >= MAX_QPATH)
1099 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1100 strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
1103 // touch all of the precached models that are still loaded so we can free
1104 // anything that isn't needed
1106 for (i = 1;i < nummodels;i++)
1107 Mod_FindName(cl.model_name[i]);
1108 // precache any models used by the client (this also marks them used)
1109 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
1110 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
1111 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
1112 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
1115 // do the same for sounds
1116 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
1117 S_ServerSounds (cl.sound_name, numsounds);
1119 // precache any sounds used by the client
1120 cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true);
1121 cl.sfx_knighthit = S_PrecacheSound(cl_sound_hknighthit.string, false, true);
1122 cl.sfx_tink1 = S_PrecacheSound(cl_sound_tink1.string, false, true);
1123 cl.sfx_ric1 = S_PrecacheSound(cl_sound_ric1.string, false, true);
1124 cl.sfx_ric2 = S_PrecacheSound(cl_sound_ric2.string, false, true);
1125 cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true);
1126 cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true);
1128 // now we try to load everything that is new
1131 CL_KeepaliveMessage ();
1132 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
1133 if (cl.model_precache[1]->Draw == NULL)
1134 Con_Printf("Map %s not found\n", cl.model_name[1]);
1137 for (i=2 ; i<nummodels ; i++)
1139 CL_KeepaliveMessage();
1140 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
1141 Con_Printf("Model %s not found\n", cl.model_name[i]);
1145 for (i=1 ; i<numsounds ; i++)
1147 CL_KeepaliveMessage();
1148 // Don't lock the sfx here, S_ServerSounds already did that
1149 cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i], true, false);
1152 // we now have the worldmodel so we can set up the game world
1153 cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1];
1154 CL_BoundingBoxForEntity(&cl.entities[0].render);
1158 // check memory integrity
1159 Mem_CheckSentinelsGlobal();
1162 void CL_ValidateState(entity_state_t *s)
1169 if (s->modelindex >= MAX_MODELS && (65536-s->modelindex) >= MAX_MODELS)
1170 Host_Error("CL_ValidateState: modelindex (%i) >= MAX_MODELS (%i)\n", s->modelindex, MAX_MODELS);
1172 // colormap is client index + 1
1173 if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
1175 Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
1179 model = cl.model_precache[s->modelindex];
1180 if (model && model->type && s->frame >= model->numframes)
1182 Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
1185 if (model && model->type && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
1187 Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\" (which has %i skins)\n", s->skin, model->name, model->numskins);
1192 void CL_MoveLerpEntityStates(entity_t *ent)
1194 float odelta[3], adelta[3];
1195 CL_ValidateState(&ent->state_current);
1196 VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
1197 VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
1198 if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
1200 // reset all persistent stuff if this is a new entity
1201 ent->persistent.lerpdeltatime = 0;
1202 ent->persistent.lerpstarttime = cl.mtime[1];
1203 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1204 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1205 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1206 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1207 // reset animation interpolation as well
1208 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
1209 ent->render.frame1time = ent->render.frame2time = cl.time;
1210 ent->render.framelerp = 1;
1211 // reset various persistent stuff
1212 ent->persistent.muzzleflash = 0;
1213 VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
1215 else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000 || (cl.fixangle[0] && !cl.fixangle[1]))
1217 // don't interpolate the move
1218 // (the fixangle[] check detects teleports, but not constant fixangles
1219 // such as when spectating)
1220 ent->persistent.lerpdeltatime = 0;
1221 ent->persistent.lerpstarttime = cl.mtime[1];
1222 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1223 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1224 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1225 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1227 else if (ent->state_current.flags & RENDER_STEP)
1229 // monster interpolation
1230 if (DotProduct(odelta, odelta) + DotProduct(adelta, adelta) > 0.01)
1232 ent->persistent.lerpdeltatime = bound(0, cl.mtime[1] - ent->persistent.lerpstarttime, 0.1);
1233 ent->persistent.lerpstarttime = cl.mtime[1];
1234 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1235 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1236 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1237 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1243 ent->persistent.lerpstarttime = ent->state_previous.time;
1244 // no lerp if it's singleplayer
1245 if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
1246 ent->persistent.lerpdeltatime = 0;
1248 ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
1249 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1250 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1251 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1252 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1261 void CL_ParseBaseline (entity_t *ent, int large)
1265 ent->state_baseline = defaultstate;
1266 // FIXME: set ent->state_baseline.number?
1267 ent->state_baseline.active = true;
1270 ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
1271 ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
1275 ent->state_baseline.modelindex = MSG_ReadByte ();
1276 ent->state_baseline.frame = MSG_ReadByte ();
1278 ent->state_baseline.colormap = MSG_ReadByte();
1279 ent->state_baseline.skin = MSG_ReadByte();
1280 for (i = 0;i < 3;i++)
1282 ent->state_baseline.origin[i] = MSG_ReadCoord(cls.protocol);
1283 ent->state_baseline.angles[i] = MSG_ReadAngle(cls.protocol);
1285 CL_ValidateState(&ent->state_baseline);
1286 ent->state_previous = ent->state_current = ent->state_baseline;
1294 Server information pertaining to this client only
1297 void CL_ParseClientdata (void)
1301 VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
1302 VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
1303 VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
1304 cl.mviewzoom[1] = cl.mviewzoom[0];
1306 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)
1308 cl.stats[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
1309 cl.stats[STAT_ITEMS] = 0;
1310 cl.stats[STAT_VIEWZOOM] = 255;
1313 cl.mpunchangle[0][0] = 0;
1314 cl.mpunchangle[0][1] = 0;
1315 cl.mpunchangle[0][2] = 0;
1316 cl.mpunchvector[0][0] = 0;
1317 cl.mpunchvector[0][1] = 0;
1318 cl.mpunchvector[0][2] = 0;
1319 cl.mvelocity[0][0] = 0;
1320 cl.mvelocity[0][1] = 0;
1321 cl.mvelocity[0][2] = 0;
1322 cl.mviewzoom[0] = 1;
1324 bits = (unsigned short) MSG_ReadShort ();
1325 if (bits & SU_EXTEND1)
1326 bits |= (MSG_ReadByte() << 16);
1327 if (bits & SU_EXTEND2)
1328 bits |= (MSG_ReadByte() << 24);
1330 if (bits & SU_VIEWHEIGHT)
1331 cl.stats[STAT_VIEWHEIGHT] = MSG_ReadChar ();
1333 if (bits & SU_IDEALPITCH)
1334 cl.idealpitch = MSG_ReadChar ();
1336 for (i = 0;i < 3;i++)
1338 if (bits & (SU_PUNCH1<<i) )
1340 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
1341 cl.mpunchangle[0][i] = MSG_ReadChar();
1343 cl.mpunchangle[0][i] = MSG_ReadAngle16i();
1345 if (bits & (SU_PUNCHVEC1<<i))
1347 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1348 cl.mpunchvector[0][i] = MSG_ReadCoord16i();
1350 cl.mpunchvector[0][i] = MSG_ReadCoord32f();
1352 if (bits & (SU_VELOCITY1<<i) )
1354 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)
1355 cl.mvelocity[0][i] = MSG_ReadChar()*16;
1357 cl.mvelocity[0][i] = MSG_ReadCoord32f();
1361 // LordHavoc: hipnotic demos don't have this bit set but should
1362 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)
1363 cl.stats[STAT_ITEMS] = MSG_ReadLong ();
1365 cl.onground = (bits & SU_ONGROUND) != 0;
1366 csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
1367 cl.inwater = (bits & SU_INWATER) != 0;
1369 if (cls.protocol == PROTOCOL_DARKPLACES5)
1371 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadShort() : 0;
1372 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadShort() : 0;
1373 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadShort() : 0;
1374 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1375 cl.stats[STAT_AMMO] = MSG_ReadShort();
1376 cl.stats[STAT_SHELLS] = MSG_ReadShort();
1377 cl.stats[STAT_NAILS] = MSG_ReadShort();
1378 cl.stats[STAT_ROCKETS] = MSG_ReadShort();
1379 cl.stats[STAT_CELLS] = MSG_ReadShort();
1380 cl.stats[STAT_ACTIVEWEAPON] = (unsigned short) MSG_ReadShort ();
1382 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)
1384 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadByte() : 0;
1385 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadByte() : 0;
1386 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadByte() : 0;
1387 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1388 cl.stats[STAT_AMMO] = MSG_ReadByte();
1389 cl.stats[STAT_SHELLS] = MSG_ReadByte();
1390 cl.stats[STAT_NAILS] = MSG_ReadByte();
1391 cl.stats[STAT_ROCKETS] = MSG_ReadByte();
1392 cl.stats[STAT_CELLS] = MSG_ReadByte();
1393 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
1394 cl.stats[STAT_ACTIVEWEAPON] = (1<<MSG_ReadByte ());
1396 cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte ();
1399 if (bits & SU_VIEWZOOM)
1401 if (cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1402 cl.stats[STAT_VIEWZOOM] = MSG_ReadByte();
1404 cl.stats[STAT_VIEWZOOM] = (unsigned short) MSG_ReadShort();
1407 // viewzoom interpolation
1408 cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
1412 =====================
1414 =====================
1416 void CL_ParseStatic (int large)
1420 if (cl.num_static_entities >= cl.max_static_entities)
1421 Host_Error ("Too many static entities");
1422 ent = &cl.static_entities[cl.num_static_entities++];
1423 CL_ParseBaseline (ent, large);
1425 // copy it to the current state
1426 ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
1427 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_baseline.frame;
1428 ent->render.framelerp = 0;
1429 // make torchs play out of sync
1430 ent->render.frame1time = ent->render.frame2time = lhrandom(-10, -1);
1431 ent->render.colormap = -1; // no special coloring
1432 ent->render.skinnum = ent->state_baseline.skin;
1433 ent->render.effects = ent->state_baseline.effects;
1434 ent->render.alpha = 1;
1435 //ent->render.scale = 1;
1437 //VectorCopy (ent->state_baseline.origin, ent->render.origin);
1438 //VectorCopy (ent->state_baseline.angles, ent->render.angles);
1440 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);
1441 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1442 CL_BoundingBoxForEntity(&ent->render);
1444 // This is definitely cheating...
1445 if (ent->render.model == NULL)
1446 cl.num_static_entities--;
1454 void CL_ParseStaticSound (int large)
1457 int sound_num, vol, atten;
1459 MSG_ReadVector(org, cls.protocol);
1461 sound_num = (unsigned short) MSG_ReadShort ();
1463 sound_num = MSG_ReadByte ();
1464 vol = MSG_ReadByte ();
1465 atten = MSG_ReadByte ();
1467 S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
1470 void CL_ParseEffect (void)
1473 int modelindex, startframe, framecount, framerate;
1475 MSG_ReadVector(org, cls.protocol);
1476 modelindex = MSG_ReadByte ();
1477 startframe = MSG_ReadByte ();
1478 framecount = MSG_ReadByte ();
1479 framerate = MSG_ReadByte ();
1481 CL_Effect(org, modelindex, startframe, framecount, framerate);
1484 void CL_ParseEffect2 (void)
1487 int modelindex, startframe, framecount, framerate;
1489 MSG_ReadVector(org, cls.protocol);
1490 modelindex = (unsigned short) MSG_ReadShort ();
1491 startframe = (unsigned short) MSG_ReadShort ();
1492 framecount = MSG_ReadByte ();
1493 framerate = MSG_ReadByte ();
1495 CL_Effect(org, modelindex, startframe, framecount, framerate);
1498 void CL_ParseBeam (model_t *m, int lightning)
1504 ent = (unsigned short) MSG_ReadShort ();
1505 MSG_ReadVector(start, cls.protocol);
1506 MSG_ReadVector(end, cls.protocol);
1508 if (ent >= MAX_EDICTS)
1510 Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
1514 if (ent >= cl.max_entities)
1515 CL_ExpandEntities(ent);
1517 // override any beam with the same entity
1520 for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
1521 if (b->entity == ent)
1523 // if the entity was not found then just replace an unused beam
1524 if (i == cl.max_beams)
1525 for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
1526 if (!b->model || b->endtime < cl.time)
1528 if (i < cl.max_beams)
1530 cl.num_beams = max(cl.num_beams, i + 1);
1532 b->lightning = lightning;
1534 b->endtime = cl.time + 0.2;
1535 VectorCopy (start, b->start);
1536 VectorCopy (end, b->end);
1537 b->relativestartvalid = 0;
1538 if (ent && cl.entities[ent].state_current.active)
1541 matrix4x4_t matrix, imatrix;
1542 if (ent == cl.viewentity && cl.movement)
1543 p = &cl.entities[b->entity].state_previous;
1545 p = &cl.entities[b->entity].state_current;
1546 // not really valid yet, we need to get the orientation now
1547 // (ParseBeam flagged this because it is received before
1548 // entities are received, by now they have been received)
1549 // note: because players create lightning in their think
1550 // function (which occurs before movement), they actually
1551 // have some lag in it's location, so compare to the
1552 // previous player state, not the latest
1553 Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
1554 Matrix4x4_Invert_Simple(&imatrix, &matrix);
1555 Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
1556 Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
1557 b->relativestartvalid = 1;
1561 Con_Print("beam list overflow!\n");
1564 void CL_ParseTempEntity(void)
1572 int colorStart, colorLength, count;
1573 float velspeed, radius;
1574 unsigned char *tempcolor;
1575 matrix4x4_t tempmatrix;
1577 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1579 type = MSG_ReadByte();
1582 case QW_TE_WIZSPIKE:
1583 // spike hitting wall
1584 MSG_ReadVector(pos, cls.protocol);
1585 CL_FindNonSolidLocation(pos, pos, 4);
1586 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1587 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1590 case QW_TE_KNIGHTSPIKE:
1591 // spike hitting wall
1592 MSG_ReadVector(pos, cls.protocol);
1593 CL_FindNonSolidLocation(pos, pos, 4);
1594 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1595 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1599 // spike hitting wall
1600 MSG_ReadVector(pos, cls.protocol);
1601 CL_FindNonSolidLocation(pos, pos, 4);
1602 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1604 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1609 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1611 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1613 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1616 case QW_TE_SUPERSPIKE:
1617 // super spike hitting wall
1618 MSG_ReadVector(pos, cls.protocol);
1619 CL_FindNonSolidLocation(pos, pos, 4);
1620 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 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);
1635 case QW_TE_EXPLOSION:
1637 MSG_ReadVector(pos, cls.protocol);
1638 CL_FindNonSolidLocation(pos, pos, 10);
1639 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1640 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1641 CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
1644 case QW_TE_TAREXPLOSION:
1645 // tarbaby explosion
1646 MSG_ReadVector(pos, cls.protocol);
1647 CL_FindNonSolidLocation(pos, pos, 10);
1648 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1649 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1652 case QW_TE_LIGHTNING1:
1654 CL_ParseBeam(cl.model_bolt, true);
1657 case QW_TE_LIGHTNING2:
1659 CL_ParseBeam(cl.model_bolt2, true);
1662 case QW_TE_LIGHTNING3:
1664 CL_ParseBeam(cl.model_bolt3, false);
1667 case QW_TE_LAVASPLASH:
1668 MSG_ReadVector(pos, cls.protocol);
1669 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1672 case QW_TE_TELEPORT:
1673 MSG_ReadVector(pos, cls.protocol);
1674 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1678 // bullet hitting wall
1679 radius = MSG_ReadByte();
1680 MSG_ReadVector(pos, cls.protocol);
1681 CL_FindNonSolidLocation(pos, pos, 4);
1682 VectorSet(pos2, pos[0] + radius, pos[1] + radius, pos[2] + radius);
1683 VectorSet(pos, pos[0] - radius, pos[1] - radius, pos[2] - radius);
1684 CL_ParticleEffect(EFFECT_TE_GUNSHOT, radius, pos, pos2, vec3_origin, vec3_origin, NULL, 0);
1688 count = MSG_ReadByte();
1689 MSG_ReadVector(pos, cls.protocol);
1690 CL_FindNonSolidLocation(pos, pos, 4);
1691 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1694 case QW_TE_LIGHTNINGBLOOD:
1695 MSG_ReadVector(pos, cls.protocol);
1696 CL_FindNonSolidLocation(pos, pos, 4);
1697 CL_ParticleEffect(EFFECT_TE_BLOOD, 2.5, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1701 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
1706 type = MSG_ReadByte();
1710 // spike hitting wall
1711 MSG_ReadVector(pos, cls.protocol);
1712 CL_FindNonSolidLocation(pos, pos, 4);
1713 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1714 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1717 case TE_KNIGHTSPIKE:
1718 // spike hitting wall
1719 MSG_ReadVector(pos, cls.protocol);
1720 CL_FindNonSolidLocation(pos, pos, 4);
1721 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1722 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1726 // spike hitting wall
1727 MSG_ReadVector(pos, cls.protocol);
1728 CL_FindNonSolidLocation(pos, pos, 4);
1729 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1731 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1736 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1738 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1740 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1744 // quad spike hitting wall
1745 MSG_ReadVector(pos, cls.protocol);
1746 CL_FindNonSolidLocation(pos, pos, 4);
1747 CL_ParticleEffect(EFFECT_TE_SPIKEQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 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 // super spike hitting wall
1763 MSG_ReadVector(pos, cls.protocol);
1764 CL_FindNonSolidLocation(pos, pos, 4);
1765 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1767 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1772 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1774 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1776 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1779 case TE_SUPERSPIKEQUAD:
1780 // quad super spike hitting wall
1781 MSG_ReadVector(pos, cls.protocol);
1782 CL_FindNonSolidLocation(pos, pos, 4);
1783 CL_ParticleEffect(EFFECT_TE_SUPERSPIKEQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1785 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1790 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1792 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1794 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1797 // LordHavoc: added for improved blood splatters
1800 MSG_ReadVector(pos, cls.protocol);
1801 CL_FindNonSolidLocation(pos, pos, 4);
1802 dir[0] = MSG_ReadChar();
1803 dir[1] = MSG_ReadChar();
1804 dir[2] = MSG_ReadChar();
1805 count = MSG_ReadByte();
1806 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos, dir, dir, NULL, 0);
1810 MSG_ReadVector(pos, cls.protocol);
1811 CL_FindNonSolidLocation(pos, pos, 4);
1812 dir[0] = MSG_ReadChar();
1813 dir[1] = MSG_ReadChar();
1814 dir[2] = MSG_ReadChar();
1815 count = MSG_ReadByte();
1816 CL_ParticleEffect(EFFECT_TE_SPARK, count, pos, pos, dir, dir, NULL, 0);
1819 MSG_ReadVector(pos, cls.protocol);
1820 CL_FindNonSolidLocation(pos, pos, 4);
1821 CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1823 // LordHavoc: added for improved gore
1824 case TE_BLOODSHOWER:
1826 MSG_ReadVector(pos, cls.protocol); // mins
1827 MSG_ReadVector(pos2, cls.protocol); // maxs
1828 velspeed = MSG_ReadCoord(cls.protocol); // speed
1829 count = (unsigned short) MSG_ReadShort(); // number of particles
1830 vel1[0] = -velspeed;
1831 vel1[1] = -velspeed;
1832 vel1[2] = -velspeed;
1836 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos2, vel1, vel2, NULL, 0);
1839 case TE_PARTICLECUBE:
1840 // general purpose particle effect
1841 MSG_ReadVector(pos, cls.protocol); // mins
1842 MSG_ReadVector(pos2, cls.protocol); // maxs
1843 MSG_ReadVector(dir, cls.protocol); // dir
1844 count = (unsigned short) MSG_ReadShort(); // number of particles
1845 colorStart = MSG_ReadByte(); // color
1846 colorLength = MSG_ReadByte(); // gravity (1 or 0)
1847 velspeed = MSG_ReadCoord(cls.protocol); // randomvel
1848 CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength != 0, velspeed);
1851 case TE_PARTICLERAIN:
1852 // general purpose particle effect
1853 MSG_ReadVector(pos, cls.protocol); // mins
1854 MSG_ReadVector(pos2, cls.protocol); // maxs
1855 MSG_ReadVector(dir, cls.protocol); // dir
1856 count = (unsigned short) MSG_ReadShort(); // number of particles
1857 colorStart = MSG_ReadByte(); // color
1858 CL_ParticleRain(pos, pos2, dir, count, colorStart, 0);
1861 case TE_PARTICLESNOW:
1862 // general purpose particle effect
1863 MSG_ReadVector(pos, cls.protocol); // mins
1864 MSG_ReadVector(pos2, cls.protocol); // maxs
1865 MSG_ReadVector(dir, cls.protocol); // dir
1866 count = (unsigned short) MSG_ReadShort(); // number of particles
1867 colorStart = MSG_ReadByte(); // color
1868 CL_ParticleRain(pos, pos2, dir, count, colorStart, 1);
1872 // bullet hitting wall
1873 MSG_ReadVector(pos, cls.protocol);
1874 CL_FindNonSolidLocation(pos, pos, 4);
1875 CL_ParticleEffect(EFFECT_TE_GUNSHOT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1878 case TE_GUNSHOTQUAD:
1879 // quad bullet hitting wall
1880 MSG_ReadVector(pos, cls.protocol);
1881 CL_FindNonSolidLocation(pos, pos, 4);
1882 CL_ParticleEffect(EFFECT_TE_GUNSHOTQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1887 MSG_ReadVector(pos, cls.protocol);
1888 CL_FindNonSolidLocation(pos, pos, 10);
1889 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1890 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1893 case TE_EXPLOSIONQUAD:
1894 // quad rocket explosion
1895 MSG_ReadVector(pos, cls.protocol);
1896 CL_FindNonSolidLocation(pos, pos, 10);
1897 CL_ParticleEffect(EFFECT_TE_EXPLOSIONQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1898 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1902 // Nehahra movie colored lighting explosion
1903 MSG_ReadVector(pos, cls.protocol);
1904 CL_FindNonSolidLocation(pos, pos, 10);
1905 color[0] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1906 color[1] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1907 color[2] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1908 CL_ParticleExplosion(pos);
1909 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1910 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);
1911 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1914 case TE_EXPLOSIONRGB:
1915 // colored lighting explosion
1916 MSG_ReadVector(pos, cls.protocol);
1917 CL_FindNonSolidLocation(pos, pos, 10);
1918 CL_ParticleExplosion(pos);
1919 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1920 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1921 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1922 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1923 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);
1924 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1927 case TE_TAREXPLOSION:
1928 // tarbaby explosion
1929 MSG_ReadVector(pos, cls.protocol);
1930 CL_FindNonSolidLocation(pos, pos, 10);
1931 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1932 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1936 MSG_ReadVector(pos, cls.protocol);
1937 CL_FindNonSolidLocation(pos, pos, 10);
1938 CL_ParticleEffect(EFFECT_TE_SMALLFLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1941 case TE_CUSTOMFLASH:
1942 MSG_ReadVector(pos, cls.protocol);
1943 CL_FindNonSolidLocation(pos, pos, 4);
1944 radius = (MSG_ReadByte() + 1) * 8;
1945 velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0);
1946 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1947 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1948 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1949 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1950 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);
1954 MSG_ReadVector(pos, cls.protocol);
1955 MSG_ReadVector(dir, cls.protocol);
1956 count = MSG_ReadByte();
1957 CL_ParticleEffect(EFFECT_TE_FLAMEJET, count, pos, pos, dir, dir, NULL, 0);
1962 CL_ParseBeam(cl.model_bolt, true);
1967 CL_ParseBeam(cl.model_bolt2, true);
1972 CL_ParseBeam(cl.model_bolt3, false);
1977 // grappling hook beam
1978 CL_ParseBeam(cl.model_beam, false);
1982 // LordHavoc: for compatibility with the Nehahra movie...
1983 case TE_LIGHTNING4NEH:
1984 CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false);
1988 MSG_ReadVector(pos, cls.protocol);
1989 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1993 MSG_ReadVector(pos, cls.protocol);
1994 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1998 // color mapped explosion
1999 MSG_ReadVector(pos, cls.protocol);
2000 CL_FindNonSolidLocation(pos, pos, 10);
2001 colorStart = MSG_ReadByte();
2002 colorLength = MSG_ReadByte();
2003 CL_ParticleExplosion2(pos, colorStart, colorLength);
2004 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
2005 color[0] = tempcolor[0] * (2.0f / 255.0f);
2006 color[1] = tempcolor[1] * (2.0f / 255.0f);
2007 color[2] = tempcolor[2] * (2.0f / 255.0f);
2008 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2009 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);
2010 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2014 MSG_ReadVector(pos, cls.protocol);
2015 MSG_ReadVector(pos2, cls.protocol);
2016 MSG_ReadVector(dir, cls.protocol);
2017 CL_ParticleEffect(EFFECT_TE_TEI_G3, 1, pos, pos2, dir, dir, NULL, 0);
2021 MSG_ReadVector(pos, cls.protocol);
2022 MSG_ReadVector(dir, cls.protocol);
2023 count = MSG_ReadByte();
2024 CL_FindNonSolidLocation(pos, pos, 4);
2025 CL_ParticleEffect(EFFECT_TE_TEI_SMOKE, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2028 case TE_TEI_BIGEXPLOSION:
2029 MSG_ReadVector(pos, cls.protocol);
2030 CL_FindNonSolidLocation(pos, pos, 10);
2031 CL_ParticleEffect(EFFECT_TE_TEI_BIGEXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2032 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2035 case TE_TEI_PLASMAHIT:
2036 MSG_ReadVector(pos, cls.protocol);
2037 MSG_ReadVector(dir, cls.protocol);
2038 count = MSG_ReadByte();
2039 CL_FindNonSolidLocation(pos, pos, 5);
2040 CL_ParticleEffect(EFFECT_TE_TEI_PLASMAHIT, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2044 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
2049 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
2052 void CL_VM_Init (void);
2053 qboolean CL_VM_Parse_TempEntity (void);
2054 void CL_VM_Parse_StuffCmd (const char *msg);
2055 void CL_VM_Parse_CenterPrint (const char *msg);
2056 void CSQC_AddPrintText (const char *msg);
2057 void CSQC_ReadEntities (void);
2060 =====================
2061 CL_ParseServerMessage
2062 =====================
2064 int parsingerror = false;
2065 void CL_ParseServerMessage(void)
2069 protocolversion_t protocol;
2070 unsigned char cmdlog[32];
2071 char *cmdlogname[32], *temp;
2072 int cmdindex, cmdcount = 0;
2074 if (cls.demorecording)
2075 CL_WriteDemoMessage ();
2077 cl.last_received_message = realtime;
2080 // if recording demos, copy the message out
2082 if (cl_shownet.integer == 1)
2083 Con_Printf("%f %i\n", realtime, net_message.cursize);
2084 else if (cl_shownet.integer == 2)
2085 Con_Print("------------------\n");
2087 cl.onground = false; // unless the server says otherwise
2089 // parse the message
2091 //MSG_BeginReading ();
2093 parsingerror = true;
2095 if (cls.protocol == PROTOCOL_QUAKEWORLD)
2097 cl.mtime[1] = cl.mtime[0];
2098 cl.mtime[0] = realtime; // qw has no clock
2099 cl.movement_needupdate = true;
2100 // if true the cl.viewangles are interpolated from cl.mviewangles[]
2101 // during this frame
2102 // (makes spectating players much smoother and prevents mouse movement from turning)
2103 cl.fixangle[1] = cl.fixangle[0];
2104 cl.fixangle[0] = false;
2105 if (!cls.demoplayback)
2106 VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
2108 // slightly kill qw player entities each frame
2109 for (i = 1;i < cl.maxclients;i++)
2110 cl.entities_active[i] = false;
2112 // kill all qw nails
2113 cl.qw_num_nails = 0;
2115 // fade weapon view kick
2116 cl.qw_weaponkick = min(cl.qw_weaponkick + 10 * (cl.time - cl.oldtime), 0);
2121 Host_Error ("CL_ParseServerMessage: Bad QW server message");
2123 cmd = MSG_ReadByte ();
2127 SHOWNET("END OF MESSAGE");
2128 break; // end of message
2131 cmdindex = cmdcount & 31;
2133 cmdlog[cmdindex] = cmd;
2135 SHOWNET(qw_svc_strings[cmd]);
2136 cmdlogname[cmdindex] = qw_svc_strings[cmd];
2137 if (!cmdlogname[cmdindex])
2139 // 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)
2141 cmdlogname[cmdindex] = temp;
2149 char description[32*64], temp[64];
2151 strcpy(description, "packet dump: ");
2155 count = cmdcount - i;
2159 dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2160 strlcat(description, temp, sizeof(description));
2165 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2166 Con_Print(description);
2167 Host_Error("CL_ParseServerMessage: Illegible server message");
2172 //Con_Printf("qw_svc_nop\n");
2175 case qw_svc_disconnect:
2176 Con_Printf("Server disconnected\n");
2177 if (cls.demonum != -1)
2186 CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
2188 CSQC_AddPrintText(MSG_ReadString());
2191 case qw_svc_centerprint:
2192 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2195 case qw_svc_stufftext:
2196 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2200 // svc_damage protocol is identical to nq
2204 case qw_svc_serverdata:
2205 //Cbuf_Execute(); // make sure any stuffed commands are done
2206 CL_ParseServerInfo();
2207 CL_VM_Init(); //[515]: init csqc
2210 case qw_svc_setangle:
2211 for (i=0 ; i<3 ; i++)
2212 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2213 if (!cls.demoplayback)
2215 cl.fixangle[0] = true;
2216 VectorCopy(cl.viewangles, cl.mviewangles[0]);
2217 // disable interpolation if this is new
2218 if (!cl.fixangle[1])
2219 VectorCopy(cl.viewangles, cl.mviewangles[1]);
2223 case qw_svc_lightstyle:
2224 i = MSG_ReadByte ();
2225 if (i >= cl.max_lightstyle)
2227 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2230 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
2231 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2232 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
2236 CL_ParseStartSoundPacket(false);
2239 case qw_svc_stopsound:
2240 i = (unsigned short) MSG_ReadShort();
2241 S_StopSound(i>>3, i&7);
2244 case qw_svc_updatefrags:
2246 if (i >= cl.maxclients)
2247 Host_Error("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2248 cl.scores[i].frags = (signed short) MSG_ReadShort();
2251 case qw_svc_updateping:
2253 if (i >= cl.maxclients)
2254 Host_Error("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
2255 cl.scores[i].qw_ping = MSG_ReadShort();
2258 case qw_svc_updatepl:
2260 if (i >= cl.maxclients)
2261 Host_Error("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
2262 cl.scores[i].qw_packetloss = MSG_ReadByte();
2265 case qw_svc_updateentertime:
2267 if (i >= cl.maxclients)
2268 Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
2270 cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
2273 case qw_svc_spawnbaseline:
2274 i = (unsigned short) MSG_ReadShort();
2275 if (i < 0 || i >= MAX_EDICTS)
2276 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2277 if (i >= cl.max_entities)
2278 CL_ExpandEntities(i);
2279 CL_ParseBaseline(cl.entities + i, false);
2281 case qw_svc_spawnstatic:
2282 CL_ParseStatic(false);
2284 case qw_svc_temp_entity:
2285 if(!CL_VM_Parse_TempEntity())
2286 CL_ParseTempEntity ();
2289 case qw_svc_killedmonster:
2290 cl.stats[STAT_MONSTERS]++;
2293 case qw_svc_foundsecret:
2294 cl.stats[STAT_SECRETS]++;
2297 case qw_svc_updatestat:
2298 i = MSG_ReadByte ();
2299 if (i < 0 || i >= MAX_CL_STATS)
2300 Host_Error ("svc_updatestat: %i is invalid", i);
2301 cl.stats[i] = MSG_ReadByte ();
2304 case qw_svc_updatestatlong:
2305 i = MSG_ReadByte ();
2306 if (i < 0 || i >= MAX_CL_STATS)
2307 Host_Error ("svc_updatestatlong: %i is invalid", i);
2308 cl.stats[i] = MSG_ReadLong ();
2311 case qw_svc_spawnstaticsound:
2312 CL_ParseStaticSound (false);
2315 case qw_svc_cdtrack:
2316 cl.cdtrack = cl.looptrack = MSG_ReadByte ();
2317 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2318 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2320 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2323 case qw_svc_intermission:
2324 cl.intermission = 1;
2325 cl.completed_time = cl.time;
2326 MSG_ReadVector(cl.qw_intermission_origin, cls.protocol);
2327 for (i = 0;i < 3;i++)
2328 cl.qw_intermission_angles[i] = MSG_ReadAngle(cls.protocol);
2332 cl.intermission = 2;
2333 cl.completed_time = cl.time;
2334 SCR_CenterPrint(MSG_ReadString ());
2337 case qw_svc_sellscreen:
2338 Cmd_ExecuteString ("help", src_command);
2341 case qw_svc_smallkick:
2342 cl.qw_weaponkick = -2;
2344 case qw_svc_bigkick:
2345 cl.qw_weaponkick = -4;
2348 case qw_svc_muzzleflash:
2349 i = (unsigned short) MSG_ReadShort();
2350 // NOTE: in QW this only worked on clients
2351 if (i < 0 || i >= MAX_EDICTS)
2352 Host_Error("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2353 if (i >= cl.max_entities)
2354 CL_ExpandEntities(i);
2355 cl.entities[i].persistent.muzzleflash = 1.0f;
2358 case qw_svc_updateuserinfo:
2359 QW_CL_UpdateUserInfo();
2362 case qw_svc_setinfo:
2366 case qw_svc_serverinfo:
2370 case qw_svc_download:
2371 QW_CL_ParseDownload();
2374 case qw_svc_playerinfo:
2375 EntityStateQW_ReadPlayerUpdate();
2382 case qw_svc_chokecount:
2384 // FIXME: apply to netgraph
2385 //for (j = 0;j < i;j++)
2386 // cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK].receivedtime = -2;
2389 case qw_svc_modellist:
2390 QW_CL_ParseModelList();
2393 case qw_svc_soundlist:
2394 QW_CL_ParseSoundList();
2397 case qw_svc_packetentities:
2398 EntityFrameQW_CL_ReadFrame(false);
2399 // first update is the final signon stage
2400 if (cls.signon == SIGNONS - 1)
2401 cls.signon = SIGNONS;
2404 case qw_svc_deltapacketentities:
2405 EntityFrameQW_CL_ReadFrame(true);
2406 // first update is the final signon stage
2407 if (cls.signon == SIGNONS - 1)
2408 cls.signon = SIGNONS;
2411 case qw_svc_maxspeed:
2412 cl.qw_movevars_maxspeed = MSG_ReadFloat();
2415 case qw_svc_entgravity:
2416 cl.qw_movevars_entgravity = MSG_ReadFloat();
2419 case qw_svc_setpause:
2420 cl.paused = MSG_ReadByte ();
2425 S_PauseGameSounds (cl.paused);
2430 // fully kill the still slightly dead qw player entities each frame
2431 for (i = 1;i < cl.maxclients;i++)
2432 if (!cl.entities_active[i])
2433 cl.entities[i].state_current.active = false;
2440 Host_Error ("CL_ParseServerMessage: Bad server message");
2442 cmd = MSG_ReadByte ();
2446 SHOWNET("END OF MESSAGE");
2447 break; // end of message
2450 cmdindex = cmdcount & 31;
2452 cmdlog[cmdindex] = cmd;
2454 // if the high bit of the command byte is set, it is a fast update
2457 // 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)
2459 cmdlogname[cmdindex] = temp;
2460 SHOWNET("fast update");
2461 if (cls.signon == SIGNONS - 1)
2463 // first update is the final signon stage
2464 cls.signon = SIGNONS;
2467 EntityFrameQuake_ReadEntity (cmd&127);
2471 SHOWNET(svc_strings[cmd]);
2472 cmdlogname[cmdindex] = svc_strings[cmd];
2473 if (!cmdlogname[cmdindex])
2475 // 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)
2477 cmdlogname[cmdindex] = temp;
2485 char description[32*64], temp[64];
2487 strcpy (description, "packet dump: ");
2491 count = cmdcount - i;
2495 dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2496 strlcat (description, temp, sizeof (description));
2501 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2502 Con_Print(description);
2503 Host_Error ("CL_ParseServerMessage: Illegible server message");
2508 if (cls.signon < SIGNONS)
2509 Con_Print("<-- server to client keepalive\n");
2513 cl.mtime[1] = cl.mtime[0];
2514 cl.mtime[0] = MSG_ReadFloat ();
2515 cl.movement_needupdate = true;
2516 // if true the cl.viewangles are interpolated from cl.mviewangles[]
2517 // during this frame
2518 // (makes spectating players much smoother and prevents mouse movement from turning)
2519 cl.fixangle[1] = cl.fixangle[0];
2520 cl.fixangle[0] = false;
2521 if (!cls.demoplayback)
2522 VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
2525 case svc_clientdata:
2526 CL_ParseClientdata();
2530 i = MSG_ReadLong ();
2531 protocol = Protocol_EnumForNumber(i);
2532 if (protocol == PROTOCOL_UNKNOWN)
2533 Host_Error("CL_ParseServerMessage: Server is unrecognized protocol number (%i)", i);
2534 // hack for unmarked Nehahra movie demos which had a custom protocol
2535 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
2536 protocol = PROTOCOL_NEHAHRAMOVIE;
2537 cls.protocol = protocol;
2540 case svc_disconnect:
2541 Con_Printf ("Server disconnected\n");
2542 if (cls.demonum != -1)
2549 CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
2552 case svc_centerprint:
2553 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2557 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2564 case svc_serverinfo:
2565 CL_ParseServerInfo ();
2566 CL_VM_Init(); //[515]: init csqc
2570 for (i=0 ; i<3 ; i++)
2571 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2572 if (!cls.demoplayback)
2574 cl.fixangle[0] = true;
2575 VectorCopy(cl.viewangles, cl.mviewangles[0]);
2576 // disable interpolation if this is new
2577 if (!cl.fixangle[1])
2578 VectorCopy(cl.viewangles, cl.mviewangles[1]);
2583 cl.viewentity = (unsigned short)MSG_ReadShort ();
2584 if (cl.viewentity >= MAX_EDICTS)
2585 Host_Error("svc_setview >= MAX_EDICTS");
2586 if (cl.viewentity >= cl.max_entities)
2587 CL_ExpandEntities(cl.viewentity);
2588 // LordHavoc: assume first setview recieved is the real player entity
2589 if (!cl.playerentity)
2590 cl.playerentity = cl.viewentity;
2593 case svc_lightstyle:
2594 i = MSG_ReadByte ();
2595 if (i >= cl.max_lightstyle)
2597 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2600 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
2601 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2602 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
2606 CL_ParseStartSoundPacket(false);
2610 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2612 // was svc_sound2 in protocols 1, 2, 3, removed in 4, 5, changed to svc_precache in 6
2613 CL_ParseStartSoundPacket(true);
2617 int i = (unsigned short)MSG_ReadShort();
2618 char *s = MSG_ReadString();
2621 if (i >= 1 && i < MAX_MODELS)
2623 model_t *model = Mod_ForName(s, false, false, i == 1);
2625 Con_Printf("svc_precache: Mod_ForName(\"%s\") failed\n", s);
2626 cl.model_precache[i] = model;
2629 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_MODELS);
2634 if (i >= 1 && i < MAX_SOUNDS)
2636 sfx_t *sfx = S_PrecacheSound (s, true, false);
2637 if (!sfx && snd_initialized.integer)
2638 Con_Printf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s);
2639 cl.sound_precache[i] = sfx;
2642 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_SOUNDS);
2648 i = (unsigned short) MSG_ReadShort();
2649 S_StopSound(i>>3, i&7);
2652 case svc_updatename:
2653 i = MSG_ReadByte ();
2654 if (i >= cl.maxclients)
2655 Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
2656 strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
2659 case svc_updatefrags:
2660 i = MSG_ReadByte ();
2661 if (i >= cl.maxclients)
2662 Host_Error ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2663 cl.scores[i].frags = (signed short) MSG_ReadShort ();
2666 case svc_updatecolors:
2667 i = MSG_ReadByte ();
2668 if (i >= cl.maxclients)
2669 Host_Error ("CL_ParseServerMessage: svc_updatecolors >= cl.maxclients");
2670 cl.scores[i].colors = MSG_ReadByte ();
2674 CL_ParseParticleEffect ();
2685 case svc_spawnbaseline:
2686 i = (unsigned short) MSG_ReadShort ();
2687 if (i < 0 || i >= MAX_EDICTS)
2688 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2689 if (i >= cl.max_entities)
2690 CL_ExpandEntities(i);
2691 CL_ParseBaseline (cl.entities + i, false);
2693 case svc_spawnbaseline2:
2694 i = (unsigned short) MSG_ReadShort ();
2695 if (i < 0 || i >= MAX_EDICTS)
2696 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline2: invalid entity number %i", i);
2697 if (i >= cl.max_entities)
2698 CL_ExpandEntities(i);
2699 CL_ParseBaseline (cl.entities + i, true);
2701 case svc_spawnstatic:
2702 CL_ParseStatic (false);
2704 case svc_spawnstatic2:
2705 CL_ParseStatic (true);
2707 case svc_temp_entity:
2708 if(!CL_VM_Parse_TempEntity())
2709 CL_ParseTempEntity ();
2713 cl.paused = MSG_ReadByte ();
2718 S_PauseGameSounds (cl.paused);
2722 i = MSG_ReadByte ();
2723 // LordHavoc: it's rude to kick off the client if they missed the
2724 // reconnect somehow, so allow signon 1 even if at signon 1
2725 if (i <= cls.signon && i != 1)
2726 Host_Error ("Received signon %i when at %i", i, cls.signon);
2731 case svc_killedmonster:
2732 cl.stats[STAT_MONSTERS]++;
2735 case svc_foundsecret:
2736 cl.stats[STAT_SECRETS]++;
2739 case svc_updatestat:
2740 i = MSG_ReadByte ();
2741 if (i < 0 || i >= MAX_CL_STATS)
2742 Host_Error ("svc_updatestat: %i is invalid", i);
2743 cl.stats[i] = MSG_ReadLong ();
2746 case svc_updatestatubyte:
2747 i = MSG_ReadByte ();
2748 if (i < 0 || i >= MAX_CL_STATS)
2749 Host_Error ("svc_updatestat: %i is invalid", i);
2750 cl.stats[i] = MSG_ReadByte ();
2753 case svc_spawnstaticsound:
2754 CL_ParseStaticSound (false);
2757 case svc_spawnstaticsound2:
2758 CL_ParseStaticSound (true);
2762 cl.cdtrack = MSG_ReadByte ();
2763 cl.looptrack = MSG_ReadByte ();
2764 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2765 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2767 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2770 case svc_intermission:
2771 cl.intermission = 1;
2772 cl.completed_time = cl.time;
2776 cl.intermission = 2;
2777 cl.completed_time = cl.time;
2778 SCR_CenterPrint(MSG_ReadString ());
2782 cl.intermission = 3;
2783 cl.completed_time = cl.time;
2784 SCR_CenterPrint(MSG_ReadString ());
2787 case svc_sellscreen:
2788 Cmd_ExecuteString ("help", src_command);
2791 if (gamemode == GAME_TENEBRAE)
2793 // repeating particle effect
2794 MSG_ReadCoord(cls.protocol);
2795 MSG_ReadCoord(cls.protocol);
2796 MSG_ReadCoord(cls.protocol);
2797 MSG_ReadCoord(cls.protocol);
2798 MSG_ReadCoord(cls.protocol);
2799 MSG_ReadCoord(cls.protocol);
2806 SHOWLMP_decodehide();
2809 if (gamemode == GAME_TENEBRAE)
2812 MSG_ReadCoord(cls.protocol);
2813 MSG_ReadCoord(cls.protocol);
2814 MSG_ReadCoord(cls.protocol);
2819 SHOWLMP_decodeshow();
2822 R_SetSkyBox(MSG_ReadString());
2825 if (cls.signon == SIGNONS - 1)
2827 // first update is the final signon stage
2828 cls.signon = SIGNONS;
2831 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2832 EntityFrame_CL_ReadFrame();
2833 else if (cls.protocol == PROTOCOL_DARKPLACES4)
2834 EntityFrame4_CL_ReadFrame();
2836 EntityFrame5_CL_ReadFrame();
2838 case svc_csqcentities:
2839 CSQC_ReadEntities();
2845 CL_UpdateItemsAndWeapon();
2847 EntityFrameQuake_ISeeDeadEntities();
2849 parsingerror = false;
2852 void CL_Parse_DumpPacket(void)
2856 Con_Print("Packet dump:\n");
2857 SZ_HexDumpToConsole(&net_message);
2858 parsingerror = false;
2861 void CL_Parse_ErrorCleanUp(void)
2863 if (cls.qw_downloadmemory)
2865 Mem_Free(cls.qw_downloadmemory);
2866 cls.qw_downloadmemory = NULL;
2868 cls.qw_downloadpercent = 0;
2872 void CL_Parse_Init(void)
2874 // LordHavoc: added demo_nehahra cvar
2875 Cvar_RegisterVariable (&demo_nehahra);
2876 if (gamemode == GAME_NEHAHRA)
2877 Cvar_SetValue("demo_nehahra", 1);
2878 Cvar_RegisterVariable(&developer_networkentities);
2880 Cvar_RegisterVariable(&cl_sound_wizardhit);
2881 Cvar_RegisterVariable(&cl_sound_hknighthit);
2882 Cvar_RegisterVariable(&cl_sound_tink1);
2883 Cvar_RegisterVariable(&cl_sound_ric1);
2884 Cvar_RegisterVariable(&cl_sound_ric2);
2885 Cvar_RegisterVariable(&cl_sound_ric3);
2886 Cvar_RegisterVariable(&cl_sound_r_exp3);
2888 Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
2889 Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
2890 Cmd_AddCommand("skins", QW_CL_Skins_f, "downloads missing qw skins from server");
2891 Cmd_AddCommand("changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change");
2894 void CL_Parse_Shutdown(void)