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;
394 cls.qw_downloadmemorycursize = 0;
399 static void QW_CL_ProcessUserInfo(int slot);
400 static void QW_CL_RequestNextDownload(void)
404 // clear name of file that just finished
405 cls.qw_downloadname[0] = 0;
407 switch (cls.qw_downloadtype)
412 if (cls.qw_downloadnumber == 0)
413 Con_Printf("Checking skins...\n");
414 for (;cls.qw_downloadnumber < cl.maxclients;cls.qw_downloadnumber++)
416 if (!cl.scores[cls.qw_downloadnumber].name[0])
418 // check if we need to download the file, and return if so
419 if (!QW_CL_CheckOrDownloadFile(va("skins/%s.pcx", cl.scores[cls.qw_downloadnumber].qw_skin)))
423 cls.qw_downloadtype = dl_none;
425 // load any newly downloaded skins
426 for (i = 0;i < cl.maxclients;i++)
427 QW_CL_ProcessUserInfo(i);
429 // if we're still in signon stages, request the next one
430 if (cls.signon != SIGNONS)
432 cls.signon = SIGNONS-1;
433 // we'll go to SIGNONS when the first entity update is received
434 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
435 MSG_WriteString(&cls.netcon->message, va("begin %i", cl.qw_servercount));
439 if (cls.qw_downloadnumber == 0)
441 Con_Printf("Checking models...\n");
442 cls.qw_downloadnumber = 1;
445 for (;cls.qw_downloadnumber < MAX_MODELS && cl.model_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
448 if (cl.model_name[cls.qw_downloadnumber][0] == '*')
450 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/spike.mdl"))
451 cl.qw_modelindex_spike = cls.qw_downloadnumber;
452 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/player.mdl"))
453 cl.qw_modelindex_player = cls.qw_downloadnumber;
454 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/flag.mdl"))
455 cl.qw_modelindex_flag = cls.qw_downloadnumber;
456 if (!strcmp(cl.model_name[cls.qw_downloadnumber], "progs/s_explod.spr"))
457 cl.qw_modelindex_s_explod = cls.qw_downloadnumber;
458 // check if we need to download the file, and return if so
459 if (!QW_CL_CheckOrDownloadFile(cl.model_name[cls.qw_downloadnumber]))
463 cls.qw_downloadtype = dl_none;
465 // touch all of the precached models that are still loaded so we can free
466 // anything that isn't needed
468 for (i = 1;i < MAX_MODELS && cl.model_name[i][0];i++)
469 Mod_FindName(cl.model_name[i]);
470 // precache any models used by the client (this also marks them used)
471 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
472 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
473 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
474 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
477 // now we try to load everything that is new
480 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
481 if (cl.model_precache[1]->Draw == NULL)
482 Con_Printf("Map %s could not be found or downloaded\n", cl.model_name[1]);
485 for (i = 2;i < MAX_MODELS && cl.model_name[i][0];i++)
486 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
487 Con_Printf("Model %s could not be found or downloaded\n", cl.model_name[i]);
489 // check memory integrity
490 Mem_CheckSentinelsGlobal();
492 // now that we have a world model, set up the world entity, renderer
494 cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1];
495 CL_BoundingBoxForEntity(&cl.entities[0].render);
499 // TODO: add pmodel/emodel player.mdl/eyes.mdl CRCs to userinfo
501 // done checking sounds and models, send a prespawn command now
502 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
503 MSG_WriteString(&cls.netcon->message, va("prespawn %i 0 %i", cl.qw_servercount, cl.model_precache[1]->brush.qw_md4sum2));
505 if (cls.qw_downloadmemory)
507 Mem_Free(cls.qw_downloadmemory);
508 cls.qw_downloadmemory = NULL;
512 if (cls.qw_downloadnumber == 0)
514 Con_Printf("Checking sounds...\n");
515 cls.qw_downloadnumber = 1;
518 for (;cl.sound_name[cls.qw_downloadnumber][0];cls.qw_downloadnumber++)
520 // check if we need to download the file, and return if so
521 if (!QW_CL_CheckOrDownloadFile(va("sound/%s", cl.sound_name[cls.qw_downloadnumber])))
525 cls.qw_downloadtype = dl_none;
527 // load new sounds and unload old ones
528 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
529 S_ServerSounds(cl.sound_name, cls.qw_downloadnumber);
531 // precache any sounds used by the client
532 cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true);
533 cl.sfx_knighthit = S_PrecacheSound(cl_sound_hknighthit.string, false, true);
534 cl.sfx_tink1 = S_PrecacheSound(cl_sound_tink1.string, false, true);
535 cl.sfx_ric1 = S_PrecacheSound(cl_sound_ric1.string, false, true);
536 cl.sfx_ric2 = S_PrecacheSound(cl_sound_ric2.string, false, true);
537 cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true);
538 cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true);
541 for (i = 1;i < MAX_SOUNDS && cl.sound_name[i][0];i++)
543 // Don't lock the sfx here, S_ServerSounds already did that
544 cl.sound_precache[i] = S_PrecacheSound(cl.sound_name[i], true, false);
547 // check memory integrity
548 Mem_CheckSentinelsGlobal();
550 // done with sound downloads, next we check models
551 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
552 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, 0));
556 Con_Printf("Unknown download type.\n");
560 static void QW_CL_ParseDownload(void)
562 int size = (signed short)MSG_ReadShort();
563 int percent = MSG_ReadByte();
565 //Con_Printf("download %i %i%% (%i/%i)\n", size, percent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize);
567 // skip the download fragment if playing a demo
571 msg_readcount += size;
577 Con_Printf("File not found.\n");
578 QW_CL_RequestNextDownload();
582 if (msg_readcount + (unsigned short)size > net_message.cursize)
583 Host_Error("corrupt download message\n");
585 // make sure the buffer is big enough to include this new fragment
586 if (!cls.qw_downloadmemory || cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
589 while (cls.qw_downloadmemorymaxsize < cls.qw_downloadmemorycursize + size)
590 cls.qw_downloadmemorymaxsize *= 2;
591 old = cls.qw_downloadmemory;
592 cls.qw_downloadmemory = (unsigned char *)Mem_Alloc(cls.permanentmempool, cls.qw_downloadmemorymaxsize);
595 memcpy(cls.qw_downloadmemory, old, cls.qw_downloadmemorycursize);
600 // read the fragment out of the packet
601 MSG_ReadBytes(size, cls.qw_downloadmemory + cls.qw_downloadmemorycursize);
602 cls.qw_downloadmemorycursize += size;
604 cls.qw_downloadpercent = percent;
608 // request next fragment
609 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
610 MSG_WriteString(&cls.netcon->message, "nextdl");
615 Con_Printf("Downloaded \"%s\"\n", cls.qw_downloadname);
617 FS_WriteFile(cls.qw_downloadname, cls.qw_downloadmemory, cls.qw_downloadmemorycursize);
619 cls.qw_downloadpercent = 0;
621 // start downloading the next file (or join the game)
622 QW_CL_RequestNextDownload();
626 static void QW_CL_ParseModelList(void)
629 int nummodels = MSG_ReadByte();
632 // parse model precache list
635 str = MSG_ReadString();
639 if (nummodels==MAX_MODELS)
640 Host_Error("Server sent too many model precaches");
641 if (strlen(str) >= MAX_QPATH)
642 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
643 strlcpy(cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
649 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
650 MSG_WriteString(&cls.netcon->message, va("modellist %i %i", cl.qw_servercount, n));
655 cls.qw_downloadnumber = 0;
656 cls.qw_downloadtype = dl_model;
657 QW_CL_RequestNextDownload();
660 static void QW_CL_ParseSoundList(void)
663 int numsounds = MSG_ReadByte();
666 // parse sound precache list
669 str = MSG_ReadString();
673 if (numsounds==MAX_SOUNDS)
674 Host_Error("Server sent too many sound precaches");
675 if (strlen(str) >= MAX_QPATH)
676 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
677 strlcpy(cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
684 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
685 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, n));
690 cls.qw_downloadnumber = 0;
691 cls.qw_downloadtype = dl_sound;
692 QW_CL_RequestNextDownload();
695 static void QW_CL_Skins_f(void)
697 cls.qw_downloadnumber = 0;
698 cls.qw_downloadtype = dl_skin;
699 QW_CL_RequestNextDownload();
702 static void QW_CL_Changing_f(void)
704 if (cls.qw_downloadmemory) // don't change when downloading
709 cls.signon = 1; // not active anymore, but not disconnected
710 Con_Printf("\nChanging map...\n");
713 void QW_CL_NextUpload(void)
715 int r, percent, size;
717 if (!cls.qw_uploaddata)
720 r = cls.qw_uploadsize - cls.qw_uploadpos;
723 size = min(1, cls.qw_uploadsize);
724 percent = (cls.qw_uploadpos+r)*100/size;
726 MSG_WriteByte(&cls.netcon->message, qw_clc_upload);
727 MSG_WriteShort(&cls.netcon->message, r);
728 MSG_WriteByte(&cls.netcon->message, percent);
729 SZ_Write(&cls.netcon->message, cls.qw_uploaddata + cls.qw_uploadpos, r);
731 Con_DPrintf("UPLOAD: %6d: %d written\n", cls.qw_uploadpos, r);
733 cls.qw_uploadpos += r;
735 if (cls.qw_uploadpos < cls.qw_uploadsize)
738 Con_Printf("Upload completed\n");
743 void QW_CL_StartUpload(unsigned char *data, int size)
745 // do nothing in demos or if not connected
749 // abort existing upload if in progress
752 Con_DPrintf("Starting upload of %d bytes...\n", size);
754 cls.qw_uploaddata = (unsigned char *)Mem_Alloc(cls.permanentmempool, size);
755 memcpy(cls.qw_uploaddata, data, size);
756 cls.qw_uploadsize = size;
757 cls.qw_uploadpos = 0;
763 qboolean QW_CL_IsUploading(void)
765 return cls.qw_uploaddata != NULL;
769 void QW_CL_StopUpload(void)
771 if (cls.qw_uploaddata)
772 Mem_Free(cls.qw_uploaddata);
773 cls.qw_uploaddata = NULL;
774 cls.qw_uploadsize = 0;
775 cls.qw_uploadpos = 0;
778 static void QW_CL_ProcessUserInfo(int slot)
780 int topcolor, bottomcolor;
782 InfoString_GetValue(cl.scores[slot].qw_userinfo, "name", cl.scores[slot].name, sizeof(cl.scores[slot].name));
783 InfoString_GetValue(cl.scores[slot].qw_userinfo, "topcolor", temp, sizeof(temp));topcolor = atoi(temp);
784 InfoString_GetValue(cl.scores[slot].qw_userinfo, "bottomcolor", temp, sizeof(temp));bottomcolor = atoi(temp);
785 cl.scores[slot].colors = topcolor * 16 + bottomcolor;
786 InfoString_GetValue(cl.scores[slot].qw_userinfo, "*spectator", temp, sizeof(temp));
787 cl.scores[slot].qw_spectator = temp[0] != 0;
788 InfoString_GetValue(cl.scores[slot].qw_userinfo, "team", cl.scores[slot].qw_team, sizeof(cl.scores[slot].qw_team));
789 InfoString_GetValue(cl.scores[slot].qw_userinfo, "skin", cl.scores[slot].qw_skin, sizeof(cl.scores[slot].qw_skin));
790 if (!cl.scores[slot].qw_skin[0])
791 strlcpy(cl.scores[slot].qw_skin, "base", sizeof(cl.scores[slot].qw_skin));
795 static void QW_CL_UpdateUserInfo(void)
798 slot = MSG_ReadByte();
799 if (slot >= cl.maxclients)
801 Con_Printf("svc_updateuserinfo >= cl.maxclients\n");
806 cl.scores[slot].qw_userid = MSG_ReadLong();
807 strlcpy(cl.scores[slot].qw_userinfo, MSG_ReadString(), sizeof(cl.scores[slot].qw_userinfo));
809 QW_CL_ProcessUserInfo(slot);
812 static void QW_CL_SetInfo(void)
817 slot = MSG_ReadByte();
818 strlcpy(key, MSG_ReadString(), sizeof(key));
819 strlcpy(value, MSG_ReadString(), sizeof(value));
820 if (slot >= cl.maxclients)
822 Con_Printf("svc_setinfo >= cl.maxclients\n");
825 InfoString_SetValue(cl.scores[slot].qw_userinfo, sizeof(cl.scores[slot].qw_userinfo), key, value);
827 QW_CL_ProcessUserInfo(slot);
830 static void QW_CL_ServerInfo(void)
835 strlcpy(key, MSG_ReadString(), sizeof(key));
836 strlcpy(value, MSG_ReadString(), sizeof(value));
837 Con_DPrintf("SERVERINFO: %s=%s\n", key, value);
838 InfoString_SetValue(cl.qw_serverinfo, sizeof(cl.qw_serverinfo), key, value);
839 InfoString_GetValue(cl.qw_serverinfo, "teamplay", temp, sizeof(temp));
840 cl.qw_teamplay = atoi(temp);
843 static void QW_CL_ParseNails(void)
846 int numnails = MSG_ReadByte();
848 unsigned char bits[6];
849 for (i = 0;i < numnails;i++)
851 for (j = 0;j < 6;j++)
852 bits[j] = MSG_ReadByte();
853 if (cl.qw_num_nails > 255)
855 v = cl.qw_nails[cl.qw_num_nails++];
856 v[0] = ( ( bits[0] + ((bits[1]&15)<<8) ) <<1) - 4096;
857 v[1] = ( ( (bits[1]>>4) + (bits[2]<<4) ) <<1) - 4096;
858 v[2] = ( ( bits[3] + ((bits[4]&15)<<8) ) <<1) - 4096;
859 v[3] = -360*(bits[4]>>4)/16;
860 v[4] = 360*bits[5]/256;
865 static void CL_UpdateItemsAndWeapon(void)
868 // check for important changes
871 if (cl.olditems != cl.stats[STAT_ITEMS])
872 for (j = 0;j < 32;j++)
873 if ((cl.stats[STAT_ITEMS] & (1<<j)) && !(cl.olditems & (1<<j)))
874 cl.item_gettime[j] = cl.time;
875 cl.olditems = cl.stats[STAT_ITEMS];
877 // GAME_NEXUIZ hud needs weapon change time
878 if (cl.activeweapon != cl.stats[STAT_ACTIVEWEAPON])
879 cl.weapontime = cl.time;
880 cl.activeweapon = cl.stats[STAT_ACTIVEWEAPON];
884 =====================
887 An svc_signonnum has been received, perform a client side setup
888 =====================
890 static void CL_SignonReply (void)
892 Con_DPrintf("CL_SignonReply: %i\n", cls.signon);
899 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
900 MSG_WriteString (&cls.netcon->message, "prespawn");
907 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
908 MSG_WriteString (&cls.netcon->message, va("name \"%s\"", cl_name.string));
910 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
911 MSG_WriteString (&cls.netcon->message, va("color %i %i", cl_color.integer >> 4, cl_color.integer & 15));
913 if (cl_pmodel.integer)
915 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
916 MSG_WriteString (&cls.netcon->message, va("pmodel %i", cl_pmodel.integer));
918 if (*cl_playermodel.string)
920 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
921 MSG_WriteString (&cls.netcon->message, va("playermodel %s", cl_playermodel.string));
923 if (*cl_playerskin.string)
925 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
926 MSG_WriteString (&cls.netcon->message, va("playerskin %s", cl_playerskin.string));
929 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
930 MSG_WriteString (&cls.netcon->message, va("rate %i", cl_rate.integer));
932 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
933 MSG_WriteString (&cls.netcon->message, "spawn");
940 MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
941 MSG_WriteString (&cls.netcon->message, "begin");
956 void CL_ParseServerInfo (void)
960 protocolversion_t protocol;
961 int nummodels, numsounds;
963 Con_DPrint("Serverinfo packet received.\n");
965 // if server is active, we already began a loading plaque
967 SCR_BeginLoadingPlaque();
969 // check memory integrity
970 Mem_CheckSentinelsGlobal();
973 // wipe the client_state_t struct
977 // parse protocol version number
979 protocol = Protocol_EnumForNumber(i);
980 if (protocol == PROTOCOL_UNKNOWN)
982 Host_Error("CL_ParseServerInfo: Server is unrecognized protocol number (%i)", i);
985 // hack for unmarked Nehahra movie demos which had a custom protocol
986 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
987 protocol = PROTOCOL_NEHAHRAMOVIE;
988 cls.protocol = protocol;
989 Con_DPrintf("Server protocol is %s\n", Protocol_NameForEnum(cls.protocol));
993 if (protocol == PROTOCOL_QUAKEWORLD)
995 cl.qw_servercount = MSG_ReadLong();
997 str = MSG_ReadString();
998 Con_Printf("server gamedir is %s\n", str);
1000 // FIXME: change gamedir if needed!
1001 if (strcasecmp(gamedirfile, str))
1003 Host_SaveConfig_f();
1007 Com_Gamedir(str); // change gamedir
1011 // exec the new config stuff
1015 cl.gametype = GAME_DEATHMATCH;
1018 // parse player number
1020 cl.qw_spectator = (i & 128) != 0;
1021 cl.playerentity = cl.viewentity = (i & 127) + 1;
1022 cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
1024 // get the full level name
1025 str = MSG_ReadString ();
1026 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1029 cl.qw_movevars_gravity = MSG_ReadFloat();
1030 cl.qw_movevars_stopspeed = MSG_ReadFloat();
1031 cl.qw_movevars_maxspeed = MSG_ReadFloat();
1032 cl.qw_movevars_spectatormaxspeed = MSG_ReadFloat();
1033 cl.qw_movevars_accelerate = MSG_ReadFloat();
1034 cl.qw_movevars_airaccelerate = MSG_ReadFloat();
1035 cl.qw_movevars_wateraccelerate = MSG_ReadFloat();
1036 cl.qw_movevars_friction = MSG_ReadFloat();
1037 cl.qw_movevars_waterfriction = MSG_ReadFloat();
1038 cl.qw_movevars_entgravity = MSG_ReadFloat();
1040 // seperate the printfs so the server message can have a color
1041 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);
1043 // check memory integrity
1044 Mem_CheckSentinelsGlobal();
1046 MSG_WriteByte(&cls.netcon->message, qw_clc_stringcmd);
1047 MSG_WriteString(&cls.netcon->message, va("soundlist %i %i", cl.qw_servercount, 0));
1049 cls.state = ca_connected;
1052 // note: on QW protocol we can't set up the gameworld until after
1053 // downloads finish...
1054 // (we don't even know the name of the map yet)
1059 cl.maxclients = MSG_ReadByte ();
1060 if (cl.maxclients < 1 || cl.maxclients > MAX_SCOREBOARD)
1062 Host_Error("Bad maxclients (%u) from server", cl.maxclients);
1065 cl.scores = (scoreboard_t *)Mem_Alloc(cls.levelmempool, cl.maxclients*sizeof(*cl.scores));
1068 cl.gametype = MSG_ReadByte ();
1070 // parse signon message
1071 str = MSG_ReadString ();
1072 strlcpy (cl.levelname, str, sizeof(cl.levelname));
1074 // seperate the printfs so the server message can have a color
1075 if (cls.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
1076 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);
1078 // check memory integrity
1079 Mem_CheckSentinelsGlobal();
1081 // parse model precache list
1082 for (nummodels=1 ; ; nummodels++)
1084 str = MSG_ReadString();
1087 if (nummodels==MAX_MODELS)
1088 Host_Error ("Server sent too many model precaches");
1089 if (strlen(str) >= MAX_QPATH)
1090 Host_Error ("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1091 strlcpy (cl.model_name[nummodels], str, sizeof (cl.model_name[nummodels]));
1093 // parse sound precache list
1094 for (numsounds=1 ; ; numsounds++)
1096 str = MSG_ReadString();
1099 if (numsounds==MAX_SOUNDS)
1100 Host_Error("Server sent too many sound precaches");
1101 if (strlen(str) >= MAX_QPATH)
1102 Host_Error("Server sent a precache name of %i characters (max %i)", strlen(str), MAX_QPATH - 1);
1103 strlcpy (cl.sound_name[numsounds], str, sizeof (cl.sound_name[numsounds]));
1106 // touch all of the precached models that are still loaded so we can free
1107 // anything that isn't needed
1109 for (i = 1;i < nummodels;i++)
1110 Mod_FindName(cl.model_name[i]);
1111 // precache any models used by the client (this also marks them used)
1112 cl.model_bolt = Mod_ForName("progs/bolt.mdl", false, false, false);
1113 cl.model_bolt2 = Mod_ForName("progs/bolt2.mdl", false, false, false);
1114 cl.model_bolt3 = Mod_ForName("progs/bolt3.mdl", false, false, false);
1115 cl.model_beam = Mod_ForName("progs/beam.mdl", false, false, false);
1118 // do the same for sounds
1119 // FIXME: S_ServerSounds does not know about cl.sfx_ sounds
1120 S_ServerSounds (cl.sound_name, numsounds);
1122 // precache any sounds used by the client
1123 cl.sfx_wizhit = S_PrecacheSound(cl_sound_wizardhit.string, false, true);
1124 cl.sfx_knighthit = S_PrecacheSound(cl_sound_hknighthit.string, false, true);
1125 cl.sfx_tink1 = S_PrecacheSound(cl_sound_tink1.string, false, true);
1126 cl.sfx_ric1 = S_PrecacheSound(cl_sound_ric1.string, false, true);
1127 cl.sfx_ric2 = S_PrecacheSound(cl_sound_ric2.string, false, true);
1128 cl.sfx_ric3 = S_PrecacheSound(cl_sound_ric3.string, false, true);
1129 cl.sfx_r_exp3 = S_PrecacheSound(cl_sound_r_exp3.string, false, true);
1131 // now we try to load everything that is new
1134 CL_KeepaliveMessage ();
1135 cl.model_precache[1] = Mod_ForName(cl.model_name[1], false, false, true);
1136 if (cl.model_precache[1]->Draw == NULL)
1137 Con_Printf("Map %s not found\n", cl.model_name[1]);
1140 for (i=2 ; i<nummodels ; i++)
1142 CL_KeepaliveMessage();
1143 if ((cl.model_precache[i] = Mod_ForName(cl.model_name[i], false, false, false))->Draw == NULL)
1144 Con_Printf("Model %s not found\n", cl.model_name[i]);
1148 for (i=1 ; i<numsounds ; i++)
1150 CL_KeepaliveMessage();
1151 // Don't lock the sfx here, S_ServerSounds already did that
1152 cl.sound_precache[i] = S_PrecacheSound (cl.sound_name[i], true, false);
1155 // we now have the worldmodel so we can set up the game world
1156 cl.entities[0].render.model = cl.worldmodel = cl.model_precache[1];
1157 CL_BoundingBoxForEntity(&cl.entities[0].render);
1161 // check memory integrity
1162 Mem_CheckSentinelsGlobal();
1165 void CL_ValidateState(entity_state_t *s)
1172 if (s->modelindex >= MAX_MODELS && (65536-s->modelindex) >= MAX_MODELS)
1173 Host_Error("CL_ValidateState: modelindex (%i) >= MAX_MODELS (%i)\n", s->modelindex, MAX_MODELS);
1175 // colormap is client index + 1
1176 if ((!s->flags & RENDER_COLORMAPPED) && s->colormap > cl.maxclients)
1178 Con_DPrintf("CL_ValidateState: colormap (%i) > cl.maxclients (%i)\n", s->colormap, cl.maxclients);
1182 model = cl.model_precache[s->modelindex];
1183 if (model && model->type && s->frame >= model->numframes)
1185 Con_DPrintf("CL_ValidateState: no such frame %i in \"%s\" (which has %i frames)\n", s->frame, model->name, model->numframes);
1188 if (model && model->type && s->skin > 0 && s->skin >= model->numskins && !(s->lightpflags & PFLAGS_FULLDYNAMIC))
1190 Con_DPrintf("CL_ValidateState: no such skin %i in \"%s\" (which has %i skins)\n", s->skin, model->name, model->numskins);
1195 void CL_MoveLerpEntityStates(entity_t *ent)
1197 float odelta[3], adelta[3];
1198 CL_ValidateState(&ent->state_current);
1199 VectorSubtract(ent->state_current.origin, ent->persistent.neworigin, odelta);
1200 VectorSubtract(ent->state_current.angles, ent->persistent.newangles, adelta);
1201 if (!ent->state_previous.active || ent->state_previous.modelindex != ent->state_current.modelindex)
1203 // reset all persistent stuff if this is a new entity
1204 ent->persistent.lerpdeltatime = 0;
1205 ent->persistent.lerpstarttime = cl.mtime[1];
1206 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1207 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1208 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1209 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1210 // reset animation interpolation as well
1211 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_current.frame;
1212 ent->render.frame1time = ent->render.frame2time = cl.time;
1213 ent->render.framelerp = 1;
1214 // reset various persistent stuff
1215 ent->persistent.muzzleflash = 0;
1216 VectorCopy(ent->state_current.origin, ent->persistent.trail_origin);
1218 else if (cls.timedemo || cl_nolerp.integer || DotProduct(odelta, odelta) > 1000*1000 || (cl.fixangle[0] && !cl.fixangle[1]))
1220 // don't interpolate the move
1221 // (the fixangle[] check detects teleports, but not constant fixangles
1222 // such as when spectating)
1223 ent->persistent.lerpdeltatime = 0;
1224 ent->persistent.lerpstarttime = cl.mtime[1];
1225 VectorCopy(ent->state_current.origin, ent->persistent.oldorigin);
1226 VectorCopy(ent->state_current.angles, ent->persistent.oldangles);
1227 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1228 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1230 else if (ent->state_current.flags & RENDER_STEP)
1232 // monster interpolation
1233 if (DotProduct(odelta, odelta) + DotProduct(adelta, adelta) > 0.01)
1235 ent->persistent.lerpdeltatime = bound(0, cl.mtime[1] - ent->persistent.lerpstarttime, 0.1);
1236 ent->persistent.lerpstarttime = cl.mtime[1];
1237 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1238 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1239 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1240 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1246 ent->persistent.lerpstarttime = ent->state_previous.time;
1247 // no lerp if it's singleplayer
1248 if (cl.islocalgame && !sv_fixedframeratesingleplayer.integer)
1249 ent->persistent.lerpdeltatime = 0;
1251 ent->persistent.lerpdeltatime = bound(0, ent->state_current.time - ent->state_previous.time, 0.1);
1252 VectorCopy(ent->persistent.neworigin, ent->persistent.oldorigin);
1253 VectorCopy(ent->persistent.newangles, ent->persistent.oldangles);
1254 VectorCopy(ent->state_current.origin, ent->persistent.neworigin);
1255 VectorCopy(ent->state_current.angles, ent->persistent.newangles);
1264 void CL_ParseBaseline (entity_t *ent, int large)
1268 ent->state_baseline = defaultstate;
1269 // FIXME: set ent->state_baseline.number?
1270 ent->state_baseline.active = true;
1273 ent->state_baseline.modelindex = (unsigned short) MSG_ReadShort ();
1274 ent->state_baseline.frame = (unsigned short) MSG_ReadShort ();
1278 ent->state_baseline.modelindex = MSG_ReadByte ();
1279 ent->state_baseline.frame = MSG_ReadByte ();
1281 ent->state_baseline.colormap = MSG_ReadByte();
1282 ent->state_baseline.skin = MSG_ReadByte();
1283 for (i = 0;i < 3;i++)
1285 ent->state_baseline.origin[i] = MSG_ReadCoord(cls.protocol);
1286 ent->state_baseline.angles[i] = MSG_ReadAngle(cls.protocol);
1288 CL_ValidateState(&ent->state_baseline);
1289 ent->state_previous = ent->state_current = ent->state_baseline;
1297 Server information pertaining to this client only
1300 void CL_ParseClientdata (void)
1304 VectorCopy (cl.mpunchangle[0], cl.mpunchangle[1]);
1305 VectorCopy (cl.mpunchvector[0], cl.mpunchvector[1]);
1306 VectorCopy (cl.mvelocity[0], cl.mvelocity[1]);
1307 cl.mviewzoom[1] = cl.mviewzoom[0];
1309 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)
1311 cl.stats[STAT_VIEWHEIGHT] = DEFAULT_VIEWHEIGHT;
1312 cl.stats[STAT_ITEMS] = 0;
1313 cl.stats[STAT_VIEWZOOM] = 255;
1316 cl.mpunchangle[0][0] = 0;
1317 cl.mpunchangle[0][1] = 0;
1318 cl.mpunchangle[0][2] = 0;
1319 cl.mpunchvector[0][0] = 0;
1320 cl.mpunchvector[0][1] = 0;
1321 cl.mpunchvector[0][2] = 0;
1322 cl.mvelocity[0][0] = 0;
1323 cl.mvelocity[0][1] = 0;
1324 cl.mvelocity[0][2] = 0;
1325 cl.mviewzoom[0] = 1;
1327 bits = (unsigned short) MSG_ReadShort ();
1328 if (bits & SU_EXTEND1)
1329 bits |= (MSG_ReadByte() << 16);
1330 if (bits & SU_EXTEND2)
1331 bits |= (MSG_ReadByte() << 24);
1333 if (bits & SU_VIEWHEIGHT)
1334 cl.stats[STAT_VIEWHEIGHT] = MSG_ReadChar ();
1336 if (bits & SU_IDEALPITCH)
1337 cl.idealpitch = MSG_ReadChar ();
1339 for (i = 0;i < 3;i++)
1341 if (bits & (SU_PUNCH1<<i) )
1343 if (cls.protocol == PROTOCOL_QUAKE || cls.protocol == PROTOCOL_QUAKEDP || cls.protocol == PROTOCOL_NEHAHRAMOVIE)
1344 cl.mpunchangle[0][i] = MSG_ReadChar();
1346 cl.mpunchangle[0][i] = MSG_ReadAngle16i();
1348 if (bits & (SU_PUNCHVEC1<<i))
1350 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1351 cl.mpunchvector[0][i] = MSG_ReadCoord16i();
1353 cl.mpunchvector[0][i] = MSG_ReadCoord32f();
1355 if (bits & (SU_VELOCITY1<<i) )
1357 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)
1358 cl.mvelocity[0][i] = MSG_ReadChar()*16;
1360 cl.mvelocity[0][i] = MSG_ReadCoord32f();
1364 // LordHavoc: hipnotic demos don't have this bit set but should
1365 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)
1366 cl.stats[STAT_ITEMS] = MSG_ReadLong ();
1368 cl.onground = (bits & SU_ONGROUND) != 0;
1369 csqc_onground = cl.onground; //[515]: cause without this csqc will receive not right value on svc_print =/
1370 cl.inwater = (bits & SU_INWATER) != 0;
1372 if (cls.protocol == PROTOCOL_DARKPLACES5)
1374 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadShort() : 0;
1375 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadShort() : 0;
1376 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadShort() : 0;
1377 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1378 cl.stats[STAT_AMMO] = MSG_ReadShort();
1379 cl.stats[STAT_SHELLS] = MSG_ReadShort();
1380 cl.stats[STAT_NAILS] = MSG_ReadShort();
1381 cl.stats[STAT_ROCKETS] = MSG_ReadShort();
1382 cl.stats[STAT_CELLS] = MSG_ReadShort();
1383 cl.stats[STAT_ACTIVEWEAPON] = (unsigned short) MSG_ReadShort ();
1385 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)
1387 cl.stats[STAT_WEAPONFRAME] = (bits & SU_WEAPONFRAME) ? MSG_ReadByte() : 0;
1388 cl.stats[STAT_ARMOR] = (bits & SU_ARMOR) ? MSG_ReadByte() : 0;
1389 cl.stats[STAT_WEAPON] = (bits & SU_WEAPON) ? MSG_ReadByte() : 0;
1390 cl.stats[STAT_HEALTH] = MSG_ReadShort();
1391 cl.stats[STAT_AMMO] = MSG_ReadByte();
1392 cl.stats[STAT_SHELLS] = MSG_ReadByte();
1393 cl.stats[STAT_NAILS] = MSG_ReadByte();
1394 cl.stats[STAT_ROCKETS] = MSG_ReadByte();
1395 cl.stats[STAT_CELLS] = MSG_ReadByte();
1396 if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE || gamemode == GAME_NEXUIZ)
1397 cl.stats[STAT_ACTIVEWEAPON] = (1<<MSG_ReadByte ());
1399 cl.stats[STAT_ACTIVEWEAPON] = MSG_ReadByte ();
1402 if (bits & SU_VIEWZOOM)
1404 if (cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3 || cls.protocol == PROTOCOL_DARKPLACES4)
1405 cl.stats[STAT_VIEWZOOM] = MSG_ReadByte();
1407 cl.stats[STAT_VIEWZOOM] = (unsigned short) MSG_ReadShort();
1410 // viewzoom interpolation
1411 cl.mviewzoom[0] = (float) max(cl.stats[STAT_VIEWZOOM], 2) * (1.0f / 255.0f);
1415 =====================
1417 =====================
1419 void CL_ParseStatic (int large)
1423 if (cl.num_static_entities >= cl.max_static_entities)
1424 Host_Error ("Too many static entities");
1425 ent = &cl.static_entities[cl.num_static_entities++];
1426 CL_ParseBaseline (ent, large);
1428 // copy it to the current state
1429 ent->render.model = cl.model_precache[ent->state_baseline.modelindex];
1430 ent->render.frame = ent->render.frame1 = ent->render.frame2 = ent->state_baseline.frame;
1431 ent->render.framelerp = 0;
1432 // make torchs play out of sync
1433 ent->render.frame1time = ent->render.frame2time = lhrandom(-10, -1);
1434 ent->render.colormap = -1; // no special coloring
1435 ent->render.skinnum = ent->state_baseline.skin;
1436 ent->render.effects = ent->state_baseline.effects;
1437 ent->render.alpha = 1;
1438 //ent->render.scale = 1;
1440 //VectorCopy (ent->state_baseline.origin, ent->render.origin);
1441 //VectorCopy (ent->state_baseline.angles, ent->render.angles);
1443 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);
1444 Matrix4x4_Invert_Simple(&ent->render.inversematrix, &ent->render.matrix);
1445 CL_BoundingBoxForEntity(&ent->render);
1447 // This is definitely cheating...
1448 if (ent->render.model == NULL)
1449 cl.num_static_entities--;
1457 void CL_ParseStaticSound (int large)
1460 int sound_num, vol, atten;
1462 MSG_ReadVector(org, cls.protocol);
1464 sound_num = (unsigned short) MSG_ReadShort ();
1466 sound_num = MSG_ReadByte ();
1467 vol = MSG_ReadByte ();
1468 atten = MSG_ReadByte ();
1470 S_StaticSound (cl.sound_precache[sound_num], org, vol/255.0f, atten);
1473 void CL_ParseEffect (void)
1476 int modelindex, startframe, framecount, framerate;
1478 MSG_ReadVector(org, cls.protocol);
1479 modelindex = MSG_ReadByte ();
1480 startframe = MSG_ReadByte ();
1481 framecount = MSG_ReadByte ();
1482 framerate = MSG_ReadByte ();
1484 CL_Effect(org, modelindex, startframe, framecount, framerate);
1487 void CL_ParseEffect2 (void)
1490 int modelindex, startframe, framecount, framerate;
1492 MSG_ReadVector(org, cls.protocol);
1493 modelindex = (unsigned short) MSG_ReadShort ();
1494 startframe = (unsigned short) MSG_ReadShort ();
1495 framecount = MSG_ReadByte ();
1496 framerate = MSG_ReadByte ();
1498 CL_Effect(org, modelindex, startframe, framecount, framerate);
1501 void CL_ParseBeam (model_t *m, int lightning)
1507 ent = (unsigned short) MSG_ReadShort ();
1508 MSG_ReadVector(start, cls.protocol);
1509 MSG_ReadVector(end, cls.protocol);
1511 if (ent >= MAX_EDICTS)
1513 Con_Printf("CL_ParseBeam: invalid entity number %i\n", ent);
1517 if (ent >= cl.max_entities)
1518 CL_ExpandEntities(ent);
1520 // override any beam with the same entity
1523 for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
1524 if (b->entity == ent)
1526 // if the entity was not found then just replace an unused beam
1527 if (i == cl.max_beams)
1528 for (i = 0, b = cl.beams;i < cl.max_beams;i++, b++)
1529 if (!b->model || b->endtime < cl.time)
1531 if (i < cl.max_beams)
1533 cl.num_beams = max(cl.num_beams, i + 1);
1535 b->lightning = lightning;
1537 b->endtime = cl.time + 0.2;
1538 VectorCopy (start, b->start);
1539 VectorCopy (end, b->end);
1540 b->relativestartvalid = 0;
1541 if (ent && cl.entities[ent].state_current.active)
1544 matrix4x4_t matrix, imatrix;
1545 if (ent == cl.viewentity && cl.movement)
1546 p = &cl.entities[b->entity].state_previous;
1548 p = &cl.entities[b->entity].state_current;
1549 // not really valid yet, we need to get the orientation now
1550 // (ParseBeam flagged this because it is received before
1551 // entities are received, by now they have been received)
1552 // note: because players create lightning in their think
1553 // function (which occurs before movement), they actually
1554 // have some lag in it's location, so compare to the
1555 // previous player state, not the latest
1556 Matrix4x4_CreateFromQuakeEntity(&matrix, p->origin[0], p->origin[1], p->origin[2], -p->angles[0], p->angles[1], p->angles[2], 1);
1557 Matrix4x4_Invert_Simple(&imatrix, &matrix);
1558 Matrix4x4_Transform(&imatrix, b->start, b->relativestart);
1559 Matrix4x4_Transform(&imatrix, b->end, b->relativeend);
1560 b->relativestartvalid = 1;
1564 Con_Print("beam list overflow!\n");
1567 void CL_ParseTempEntity(void)
1575 int colorStart, colorLength, count;
1576 float velspeed, radius;
1577 unsigned char *tempcolor;
1578 matrix4x4_t tempmatrix;
1580 if (cls.protocol == PROTOCOL_QUAKEWORLD)
1582 type = MSG_ReadByte();
1585 case QW_TE_WIZSPIKE:
1586 // spike hitting wall
1587 MSG_ReadVector(pos, cls.protocol);
1588 CL_FindNonSolidLocation(pos, pos, 4);
1589 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1590 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1593 case QW_TE_KNIGHTSPIKE:
1594 // spike hitting wall
1595 MSG_ReadVector(pos, cls.protocol);
1596 CL_FindNonSolidLocation(pos, pos, 4);
1597 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1598 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1602 // spike hitting wall
1603 MSG_ReadVector(pos, cls.protocol);
1604 CL_FindNonSolidLocation(pos, pos, 4);
1605 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1607 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1612 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1614 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1616 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1619 case QW_TE_SUPERSPIKE:
1620 // super spike hitting wall
1621 MSG_ReadVector(pos, cls.protocol);
1622 CL_FindNonSolidLocation(pos, pos, 4);
1623 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1625 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1630 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1632 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1634 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1638 case QW_TE_EXPLOSION:
1640 MSG_ReadVector(pos, cls.protocol);
1641 CL_FindNonSolidLocation(pos, pos, 10);
1642 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1643 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1644 CL_Effect(pos, cl.qw_modelindex_s_explod, 0, 6, 10);
1647 case QW_TE_TAREXPLOSION:
1648 // tarbaby explosion
1649 MSG_ReadVector(pos, cls.protocol);
1650 CL_FindNonSolidLocation(pos, pos, 10);
1651 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1652 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1655 case QW_TE_LIGHTNING1:
1657 CL_ParseBeam(cl.model_bolt, true);
1660 case QW_TE_LIGHTNING2:
1662 CL_ParseBeam(cl.model_bolt2, true);
1665 case QW_TE_LIGHTNING3:
1667 CL_ParseBeam(cl.model_bolt3, false);
1670 case QW_TE_LAVASPLASH:
1671 MSG_ReadVector(pos, cls.protocol);
1672 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1675 case QW_TE_TELEPORT:
1676 MSG_ReadVector(pos, cls.protocol);
1677 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1681 // bullet hitting wall
1682 radius = MSG_ReadByte();
1683 MSG_ReadVector(pos, cls.protocol);
1684 CL_FindNonSolidLocation(pos, pos, 4);
1685 VectorSet(pos2, pos[0] + radius, pos[1] + radius, pos[2] + radius);
1686 VectorSet(pos, pos[0] - radius, pos[1] - radius, pos[2] - radius);
1687 CL_ParticleEffect(EFFECT_TE_GUNSHOT, radius, pos, pos2, vec3_origin, vec3_origin, NULL, 0);
1691 count = MSG_ReadByte();
1692 MSG_ReadVector(pos, cls.protocol);
1693 CL_FindNonSolidLocation(pos, pos, 4);
1694 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1697 case QW_TE_LIGHTNINGBLOOD:
1698 MSG_ReadVector(pos, cls.protocol);
1699 CL_FindNonSolidLocation(pos, pos, 4);
1700 CL_ParticleEffect(EFFECT_TE_BLOOD, 2.5, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1704 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
1709 type = MSG_ReadByte();
1713 // spike hitting wall
1714 MSG_ReadVector(pos, cls.protocol);
1715 CL_FindNonSolidLocation(pos, pos, 4);
1716 CL_ParticleEffect(EFFECT_TE_WIZSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1717 S_StartSound(-1, 0, cl.sfx_wizhit, pos, 1, 1);
1720 case TE_KNIGHTSPIKE:
1721 // spike hitting wall
1722 MSG_ReadVector(pos, cls.protocol);
1723 CL_FindNonSolidLocation(pos, pos, 4);
1724 CL_ParticleEffect(EFFECT_TE_KNIGHTSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1725 S_StartSound(-1, 0, cl.sfx_knighthit, pos, 1, 1);
1729 // spike hitting wall
1730 MSG_ReadVector(pos, cls.protocol);
1731 CL_FindNonSolidLocation(pos, pos, 4);
1732 CL_ParticleEffect(EFFECT_TE_SPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1734 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1739 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1741 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1743 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1747 // quad spike hitting wall
1748 MSG_ReadVector(pos, cls.protocol);
1749 CL_FindNonSolidLocation(pos, pos, 4);
1750 CL_ParticleEffect(EFFECT_TE_SPIKEQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1752 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1757 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1759 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1761 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1765 // super spike hitting wall
1766 MSG_ReadVector(pos, cls.protocol);
1767 CL_FindNonSolidLocation(pos, pos, 4);
1768 CL_ParticleEffect(EFFECT_TE_SUPERSPIKE, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1770 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1775 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1777 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1779 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1782 case TE_SUPERSPIKEQUAD:
1783 // quad super spike hitting wall
1784 MSG_ReadVector(pos, cls.protocol);
1785 CL_FindNonSolidLocation(pos, pos, 4);
1786 CL_ParticleEffect(EFFECT_TE_SUPERSPIKEQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1788 S_StartSound(-1, 0, cl.sfx_tink1, pos, 1, 1);
1793 S_StartSound(-1, 0, cl.sfx_ric1, pos, 1, 1);
1795 S_StartSound(-1, 0, cl.sfx_ric2, pos, 1, 1);
1797 S_StartSound(-1, 0, cl.sfx_ric3, pos, 1, 1);
1800 // LordHavoc: added for improved blood splatters
1803 MSG_ReadVector(pos, cls.protocol);
1804 CL_FindNonSolidLocation(pos, pos, 4);
1805 dir[0] = MSG_ReadChar();
1806 dir[1] = MSG_ReadChar();
1807 dir[2] = MSG_ReadChar();
1808 count = MSG_ReadByte();
1809 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos, dir, dir, NULL, 0);
1813 MSG_ReadVector(pos, cls.protocol);
1814 CL_FindNonSolidLocation(pos, pos, 4);
1815 dir[0] = MSG_ReadChar();
1816 dir[1] = MSG_ReadChar();
1817 dir[2] = MSG_ReadChar();
1818 count = MSG_ReadByte();
1819 CL_ParticleEffect(EFFECT_TE_SPARK, count, pos, pos, dir, dir, NULL, 0);
1822 MSG_ReadVector(pos, cls.protocol);
1823 CL_FindNonSolidLocation(pos, pos, 4);
1824 CL_ParticleEffect(EFFECT_TE_PLASMABURN, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1826 // LordHavoc: added for improved gore
1827 case TE_BLOODSHOWER:
1829 MSG_ReadVector(pos, cls.protocol); // mins
1830 MSG_ReadVector(pos2, cls.protocol); // maxs
1831 velspeed = MSG_ReadCoord(cls.protocol); // speed
1832 count = (unsigned short) MSG_ReadShort(); // number of particles
1833 vel1[0] = -velspeed;
1834 vel1[1] = -velspeed;
1835 vel1[2] = -velspeed;
1839 CL_ParticleEffect(EFFECT_TE_BLOOD, count, pos, pos2, vel1, vel2, NULL, 0);
1842 case TE_PARTICLECUBE:
1843 // general purpose particle effect
1844 MSG_ReadVector(pos, cls.protocol); // mins
1845 MSG_ReadVector(pos2, cls.protocol); // maxs
1846 MSG_ReadVector(dir, cls.protocol); // dir
1847 count = (unsigned short) MSG_ReadShort(); // number of particles
1848 colorStart = MSG_ReadByte(); // color
1849 colorLength = MSG_ReadByte(); // gravity (1 or 0)
1850 velspeed = MSG_ReadCoord(cls.protocol); // randomvel
1851 CL_ParticleCube(pos, pos2, dir, count, colorStart, colorLength != 0, velspeed);
1854 case TE_PARTICLERAIN:
1855 // general purpose particle effect
1856 MSG_ReadVector(pos, cls.protocol); // mins
1857 MSG_ReadVector(pos2, cls.protocol); // maxs
1858 MSG_ReadVector(dir, cls.protocol); // dir
1859 count = (unsigned short) MSG_ReadShort(); // number of particles
1860 colorStart = MSG_ReadByte(); // color
1861 CL_ParticleRain(pos, pos2, dir, count, colorStart, 0);
1864 case TE_PARTICLESNOW:
1865 // general purpose particle effect
1866 MSG_ReadVector(pos, cls.protocol); // mins
1867 MSG_ReadVector(pos2, cls.protocol); // maxs
1868 MSG_ReadVector(dir, cls.protocol); // dir
1869 count = (unsigned short) MSG_ReadShort(); // number of particles
1870 colorStart = MSG_ReadByte(); // color
1871 CL_ParticleRain(pos, pos2, dir, count, colorStart, 1);
1875 // bullet hitting wall
1876 MSG_ReadVector(pos, cls.protocol);
1877 CL_FindNonSolidLocation(pos, pos, 4);
1878 CL_ParticleEffect(EFFECT_TE_GUNSHOT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1881 case TE_GUNSHOTQUAD:
1882 // quad bullet hitting wall
1883 MSG_ReadVector(pos, cls.protocol);
1884 CL_FindNonSolidLocation(pos, pos, 4);
1885 CL_ParticleEffect(EFFECT_TE_GUNSHOTQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1890 MSG_ReadVector(pos, cls.protocol);
1891 CL_FindNonSolidLocation(pos, pos, 10);
1892 CL_ParticleEffect(EFFECT_TE_EXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1893 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1896 case TE_EXPLOSIONQUAD:
1897 // quad rocket explosion
1898 MSG_ReadVector(pos, cls.protocol);
1899 CL_FindNonSolidLocation(pos, pos, 10);
1900 CL_ParticleEffect(EFFECT_TE_EXPLOSIONQUAD, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1901 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1905 // Nehahra movie colored lighting explosion
1906 MSG_ReadVector(pos, cls.protocol);
1907 CL_FindNonSolidLocation(pos, pos, 10);
1908 color[0] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1909 color[1] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1910 color[2] = MSG_ReadCoord(cls.protocol) * (2.0f / 1.0f);
1911 CL_ParticleExplosion(pos);
1912 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1913 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);
1914 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1917 case TE_EXPLOSIONRGB:
1918 // colored lighting explosion
1919 MSG_ReadVector(pos, cls.protocol);
1920 CL_FindNonSolidLocation(pos, pos, 10);
1921 CL_ParticleExplosion(pos);
1922 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1923 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1924 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1925 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1926 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);
1927 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1930 case TE_TAREXPLOSION:
1931 // tarbaby explosion
1932 MSG_ReadVector(pos, cls.protocol);
1933 CL_FindNonSolidLocation(pos, pos, 10);
1934 CL_ParticleEffect(EFFECT_TE_TAREXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1935 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
1939 MSG_ReadVector(pos, cls.protocol);
1940 CL_FindNonSolidLocation(pos, pos, 10);
1941 CL_ParticleEffect(EFFECT_TE_SMALLFLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1944 case TE_CUSTOMFLASH:
1945 MSG_ReadVector(pos, cls.protocol);
1946 CL_FindNonSolidLocation(pos, pos, 4);
1947 radius = (MSG_ReadByte() + 1) * 8;
1948 velspeed = (MSG_ReadByte() + 1) * (1.0 / 256.0);
1949 color[0] = MSG_ReadByte() * (2.0f / 255.0f);
1950 color[1] = MSG_ReadByte() * (2.0f / 255.0f);
1951 color[2] = MSG_ReadByte() * (2.0f / 255.0f);
1952 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
1953 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);
1957 MSG_ReadVector(pos, cls.protocol);
1958 MSG_ReadVector(dir, cls.protocol);
1959 count = MSG_ReadByte();
1960 CL_ParticleEffect(EFFECT_TE_FLAMEJET, count, pos, pos, dir, dir, NULL, 0);
1965 CL_ParseBeam(cl.model_bolt, true);
1970 CL_ParseBeam(cl.model_bolt2, true);
1975 CL_ParseBeam(cl.model_bolt3, false);
1980 // grappling hook beam
1981 CL_ParseBeam(cl.model_beam, false);
1985 // LordHavoc: for compatibility with the Nehahra movie...
1986 case TE_LIGHTNING4NEH:
1987 CL_ParseBeam(Mod_ForName(MSG_ReadString(), true, false, false), false);
1991 MSG_ReadVector(pos, cls.protocol);
1992 CL_ParticleEffect(EFFECT_TE_LAVASPLASH, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
1996 MSG_ReadVector(pos, cls.protocol);
1997 CL_ParticleEffect(EFFECT_TE_TELEPORT, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2001 // color mapped explosion
2002 MSG_ReadVector(pos, cls.protocol);
2003 CL_FindNonSolidLocation(pos, pos, 10);
2004 colorStart = MSG_ReadByte();
2005 colorLength = MSG_ReadByte();
2006 CL_ParticleExplosion2(pos, colorStart, colorLength);
2007 tempcolor = (unsigned char *)&palette_complete[(rand()%colorLength) + colorStart];
2008 color[0] = tempcolor[0] * (2.0f / 255.0f);
2009 color[1] = tempcolor[1] * (2.0f / 255.0f);
2010 color[2] = tempcolor[2] * (2.0f / 255.0f);
2011 Matrix4x4_CreateTranslate(&tempmatrix, pos[0], pos[1], pos[2]);
2012 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);
2013 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2017 MSG_ReadVector(pos, cls.protocol);
2018 MSG_ReadVector(pos2, cls.protocol);
2019 MSG_ReadVector(dir, cls.protocol);
2020 CL_ParticleEffect(EFFECT_TE_TEI_G3, 1, pos, pos2, dir, dir, NULL, 0);
2024 MSG_ReadVector(pos, cls.protocol);
2025 MSG_ReadVector(dir, cls.protocol);
2026 count = MSG_ReadByte();
2027 CL_FindNonSolidLocation(pos, pos, 4);
2028 CL_ParticleEffect(EFFECT_TE_TEI_SMOKE, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2031 case TE_TEI_BIGEXPLOSION:
2032 MSG_ReadVector(pos, cls.protocol);
2033 CL_FindNonSolidLocation(pos, pos, 10);
2034 CL_ParticleEffect(EFFECT_TE_TEI_BIGEXPLOSION, 1, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2035 S_StartSound(-1, 0, cl.sfx_r_exp3, pos, 1, 1);
2038 case TE_TEI_PLASMAHIT:
2039 MSG_ReadVector(pos, cls.protocol);
2040 MSG_ReadVector(dir, cls.protocol);
2041 count = MSG_ReadByte();
2042 CL_FindNonSolidLocation(pos, pos, 5);
2043 CL_ParticleEffect(EFFECT_TE_TEI_PLASMAHIT, count, pos, pos, vec3_origin, vec3_origin, NULL, 0);
2047 Host_Error("CL_ParseTempEntity: bad type %d (hex %02X)", type, type);
2052 #define SHOWNET(x) if(cl_shownet.integer==2)Con_Printf("%3i:%s\n", msg_readcount-1, x);
2055 void CL_VM_Init (void);
2056 qboolean CL_VM_Parse_TempEntity (void);
2057 void CL_VM_Parse_StuffCmd (const char *msg);
2058 void CL_VM_Parse_CenterPrint (const char *msg);
2059 void CSQC_AddPrintText (const char *msg);
2060 void CSQC_ReadEntities (void);
2063 =====================
2064 CL_ParseServerMessage
2065 =====================
2067 int parsingerror = false;
2068 void CL_ParseServerMessage(void)
2072 protocolversion_t protocol;
2073 unsigned char cmdlog[32];
2074 char *cmdlogname[32], *temp;
2075 int cmdindex, cmdcount = 0;
2077 if (cls.demorecording)
2078 CL_WriteDemoMessage ();
2080 cl.last_received_message = realtime;
2083 // if recording demos, copy the message out
2085 if (cl_shownet.integer == 1)
2086 Con_Printf("%f %i\n", realtime, net_message.cursize);
2087 else if (cl_shownet.integer == 2)
2088 Con_Print("------------------\n");
2091 // parse the message
2093 //MSG_BeginReading ();
2095 parsingerror = true;
2097 if (cls.protocol == PROTOCOL_QUAKEWORLD)
2099 cl.mtime[1] = cl.mtime[0];
2100 cl.mtime[0] = realtime; // qw has no clock
2101 cl.movement_needupdate = true;
2102 // if true the cl.viewangles are interpolated from cl.mviewangles[]
2103 // during this frame
2104 // (makes spectating players much smoother and prevents mouse movement from turning)
2105 cl.fixangle[1] = cl.fixangle[0];
2106 cl.fixangle[0] = false;
2107 if (!cls.demoplayback)
2108 VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
2110 // slightly kill qw player entities each frame
2111 for (i = 1;i < cl.maxclients;i++)
2112 cl.entities_active[i] = false;
2114 // kill all qw nails
2115 cl.qw_num_nails = 0;
2117 // fade weapon view kick
2118 cl.qw_weaponkick = min(cl.qw_weaponkick + 10 * (cl.time - cl.oldtime), 0);
2123 Host_Error ("CL_ParseServerMessage: Bad QW server message");
2125 cmd = MSG_ReadByte ();
2129 SHOWNET("END OF MESSAGE");
2130 break; // end of message
2133 cmdindex = cmdcount & 31;
2135 cmdlog[cmdindex] = cmd;
2137 SHOWNET(qw_svc_strings[cmd]);
2138 cmdlogname[cmdindex] = qw_svc_strings[cmd];
2139 if (!cmdlogname[cmdindex])
2141 // 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)
2143 cmdlogname[cmdindex] = temp;
2151 char description[32*64], temp[64];
2153 strcpy(description, "packet dump: ");
2157 count = cmdcount - i;
2161 dpsnprintf(temp, sizeof(temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2162 strlcat(description, temp, sizeof(description));
2167 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2168 Con_Print(description);
2169 Host_Error("CL_ParseServerMessage: Illegible server message");
2174 //Con_Printf("qw_svc_nop\n");
2177 case qw_svc_disconnect:
2178 Con_Printf("Server disconnected\n");
2179 if (cls.demonum != -1)
2188 CSQC_AddPrintText(va("\1%s", MSG_ReadString())); //[515]: csqc
2190 CSQC_AddPrintText(MSG_ReadString());
2193 case qw_svc_centerprint:
2194 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2197 case qw_svc_stufftext:
2198 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2202 // svc_damage protocol is identical to nq
2206 case qw_svc_serverdata:
2207 //Cbuf_Execute(); // make sure any stuffed commands are done
2208 CL_ParseServerInfo();
2209 CL_VM_Init(); //[515]: init csqc
2212 case qw_svc_setangle:
2213 for (i=0 ; i<3 ; i++)
2214 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2215 if (!cls.demoplayback)
2217 cl.fixangle[0] = true;
2218 VectorCopy(cl.viewangles, cl.mviewangles[0]);
2219 // disable interpolation if this is new
2220 if (!cl.fixangle[1])
2221 VectorCopy(cl.viewangles, cl.mviewangles[1]);
2225 case qw_svc_lightstyle:
2226 i = MSG_ReadByte ();
2227 if (i >= cl.max_lightstyle)
2229 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2232 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
2233 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2234 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
2238 CL_ParseStartSoundPacket(false);
2241 case qw_svc_stopsound:
2242 i = (unsigned short) MSG_ReadShort();
2243 S_StopSound(i>>3, i&7);
2246 case qw_svc_updatefrags:
2248 if (i >= cl.maxclients)
2249 Host_Error("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2250 cl.scores[i].frags = (signed short) MSG_ReadShort();
2253 case qw_svc_updateping:
2255 if (i >= cl.maxclients)
2256 Host_Error("CL_ParseServerMessage: svc_updateping >= cl.maxclients");
2257 cl.scores[i].qw_ping = MSG_ReadShort();
2260 case qw_svc_updatepl:
2262 if (i >= cl.maxclients)
2263 Host_Error("CL_ParseServerMessage: svc_updatepl >= cl.maxclients");
2264 cl.scores[i].qw_packetloss = MSG_ReadByte();
2267 case qw_svc_updateentertime:
2269 if (i >= cl.maxclients)
2270 Host_Error("CL_ParseServerMessage: svc_updateentertime >= cl.maxclients");
2272 cl.scores[i].qw_entertime = realtime - MSG_ReadFloat();
2275 case qw_svc_spawnbaseline:
2276 i = (unsigned short) MSG_ReadShort();
2277 if (i < 0 || i >= MAX_EDICTS)
2278 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2279 if (i >= cl.max_entities)
2280 CL_ExpandEntities(i);
2281 CL_ParseBaseline(cl.entities + i, false);
2283 case qw_svc_spawnstatic:
2284 CL_ParseStatic(false);
2286 case qw_svc_temp_entity:
2287 if(!CL_VM_Parse_TempEntity())
2288 CL_ParseTempEntity ();
2291 case qw_svc_killedmonster:
2292 cl.stats[STAT_MONSTERS]++;
2295 case qw_svc_foundsecret:
2296 cl.stats[STAT_SECRETS]++;
2299 case qw_svc_updatestat:
2300 i = MSG_ReadByte ();
2301 if (i < 0 || i >= MAX_CL_STATS)
2302 Host_Error ("svc_updatestat: %i is invalid", i);
2303 cl.stats[i] = MSG_ReadByte ();
2306 case qw_svc_updatestatlong:
2307 i = MSG_ReadByte ();
2308 if (i < 0 || i >= MAX_CL_STATS)
2309 Host_Error ("svc_updatestatlong: %i is invalid", i);
2310 cl.stats[i] = MSG_ReadLong ();
2313 case qw_svc_spawnstaticsound:
2314 CL_ParseStaticSound (false);
2317 case qw_svc_cdtrack:
2318 cl.cdtrack = cl.looptrack = MSG_ReadByte ();
2319 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2320 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2322 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2325 case qw_svc_intermission:
2326 cl.intermission = 1;
2327 cl.completed_time = cl.time;
2328 MSG_ReadVector(cl.qw_intermission_origin, cls.protocol);
2329 for (i = 0;i < 3;i++)
2330 cl.qw_intermission_angles[i] = MSG_ReadAngle(cls.protocol);
2334 cl.intermission = 2;
2335 cl.completed_time = cl.time;
2336 SCR_CenterPrint(MSG_ReadString ());
2339 case qw_svc_sellscreen:
2340 Cmd_ExecuteString ("help", src_command);
2343 case qw_svc_smallkick:
2344 cl.qw_weaponkick = -2;
2346 case qw_svc_bigkick:
2347 cl.qw_weaponkick = -4;
2350 case qw_svc_muzzleflash:
2351 i = (unsigned short) MSG_ReadShort();
2352 // NOTE: in QW this only worked on clients
2353 if (i < 0 || i >= MAX_EDICTS)
2354 Host_Error("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2355 if (i >= cl.max_entities)
2356 CL_ExpandEntities(i);
2357 cl.entities[i].persistent.muzzleflash = 1.0f;
2360 case qw_svc_updateuserinfo:
2361 QW_CL_UpdateUserInfo();
2364 case qw_svc_setinfo:
2368 case qw_svc_serverinfo:
2372 case qw_svc_download:
2373 QW_CL_ParseDownload();
2376 case qw_svc_playerinfo:
2377 EntityStateQW_ReadPlayerUpdate();
2384 case qw_svc_chokecount:
2386 // FIXME: apply to netgraph
2387 //for (j = 0;j < i;j++)
2388 // cl.frames[(cls.netcon->qw.incoming_acknowledged-1-j)&QW_UPDATE_MASK].receivedtime = -2;
2391 case qw_svc_modellist:
2392 QW_CL_ParseModelList();
2395 case qw_svc_soundlist:
2396 QW_CL_ParseSoundList();
2399 case qw_svc_packetentities:
2400 EntityFrameQW_CL_ReadFrame(false);
2401 // first update is the final signon stage
2402 if (cls.signon == SIGNONS - 1)
2403 cls.signon = SIGNONS;
2406 case qw_svc_deltapacketentities:
2407 EntityFrameQW_CL_ReadFrame(true);
2408 // first update is the final signon stage
2409 if (cls.signon == SIGNONS - 1)
2410 cls.signon = SIGNONS;
2413 case qw_svc_maxspeed:
2414 cl.qw_movevars_maxspeed = MSG_ReadFloat();
2417 case qw_svc_entgravity:
2418 cl.qw_movevars_entgravity = MSG_ReadFloat();
2421 case qw_svc_setpause:
2422 cl.paused = MSG_ReadByte ();
2427 S_PauseGameSounds (cl.paused);
2432 // fully kill the still slightly dead qw player entities each frame
2433 for (i = 1;i < cl.maxclients;i++)
2434 if (!cl.entities_active[i])
2435 cl.entities[i].state_current.active = false;
2442 Host_Error ("CL_ParseServerMessage: Bad server message");
2444 cmd = MSG_ReadByte ();
2448 SHOWNET("END OF MESSAGE");
2449 break; // end of message
2452 cmdindex = cmdcount & 31;
2454 cmdlog[cmdindex] = cmd;
2456 // if the high bit of the command byte is set, it is a fast update
2459 // 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)
2461 cmdlogname[cmdindex] = temp;
2462 SHOWNET("fast update");
2463 if (cls.signon == SIGNONS - 1)
2465 // first update is the final signon stage
2466 cls.signon = SIGNONS;
2469 EntityFrameQuake_ReadEntity (cmd&127);
2473 SHOWNET(svc_strings[cmd]);
2474 cmdlogname[cmdindex] = svc_strings[cmd];
2475 if (!cmdlogname[cmdindex])
2477 // 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)
2479 cmdlogname[cmdindex] = temp;
2487 char description[32*64], temp[64];
2489 strcpy (description, "packet dump: ");
2493 count = cmdcount - i;
2497 dpsnprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
2498 strlcat (description, temp, sizeof (description));
2503 description[strlen(description)-1] = '\n'; // replace the last space with a newline
2504 Con_Print(description);
2505 Host_Error ("CL_ParseServerMessage: Illegible server message");
2510 if (cls.signon < SIGNONS)
2511 Con_Print("<-- server to client keepalive\n");
2515 cl.mtime[1] = cl.mtime[0];
2516 cl.mtime[0] = MSG_ReadFloat ();
2517 cl.movement_needupdate = true;
2518 // if true the cl.viewangles are interpolated from cl.mviewangles[]
2519 // during this frame
2520 // (makes spectating players much smoother and prevents mouse movement from turning)
2521 cl.fixangle[1] = cl.fixangle[0];
2522 cl.fixangle[0] = false;
2523 if (!cls.demoplayback)
2524 VectorCopy(cl.mviewangles[0], cl.mviewangles[1]);
2527 case svc_clientdata:
2528 CL_ParseClientdata();
2532 i = MSG_ReadLong ();
2533 protocol = Protocol_EnumForNumber(i);
2534 if (protocol == PROTOCOL_UNKNOWN)
2535 Host_Error("CL_ParseServerMessage: Server is unrecognized protocol number (%i)", i);
2536 // hack for unmarked Nehahra movie demos which had a custom protocol
2537 if (protocol == PROTOCOL_QUAKEDP && cls.demoplayback && demo_nehahra.integer)
2538 protocol = PROTOCOL_NEHAHRAMOVIE;
2539 cls.protocol = protocol;
2542 case svc_disconnect:
2543 Con_Printf ("Server disconnected\n");
2544 if (cls.demonum != -1)
2551 CSQC_AddPrintText(MSG_ReadString()); //[515]: csqc
2554 case svc_centerprint:
2555 CL_VM_Parse_CenterPrint(MSG_ReadString ()); //[515]: csqc
2559 CL_VM_Parse_StuffCmd(MSG_ReadString ()); //[515]: csqc
2566 case svc_serverinfo:
2567 CL_ParseServerInfo ();
2568 CL_VM_Init(); //[515]: init csqc
2572 for (i=0 ; i<3 ; i++)
2573 cl.viewangles[i] = MSG_ReadAngle (cls.protocol);
2574 if (!cls.demoplayback)
2576 cl.fixangle[0] = true;
2577 VectorCopy(cl.viewangles, cl.mviewangles[0]);
2578 // disable interpolation if this is new
2579 if (!cl.fixangle[1])
2580 VectorCopy(cl.viewangles, cl.mviewangles[1]);
2585 cl.viewentity = (unsigned short)MSG_ReadShort ();
2586 if (cl.viewentity >= MAX_EDICTS)
2587 Host_Error("svc_setview >= MAX_EDICTS");
2588 if (cl.viewentity >= cl.max_entities)
2589 CL_ExpandEntities(cl.viewentity);
2590 // LordHavoc: assume first setview recieved is the real player entity
2591 if (!cl.playerentity)
2592 cl.playerentity = cl.viewentity;
2595 case svc_lightstyle:
2596 i = MSG_ReadByte ();
2597 if (i >= cl.max_lightstyle)
2599 Con_Printf ("svc_lightstyle >= MAX_LIGHTSTYLES");
2602 strlcpy (cl.lightstyle[i].map, MSG_ReadString(), sizeof (cl.lightstyle[i].map));
2603 cl.lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
2604 cl.lightstyle[i].length = (int)strlen(cl.lightstyle[i].map);
2608 CL_ParseStartSoundPacket(false);
2612 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2614 // was svc_sound2 in protocols 1, 2, 3, removed in 4, 5, changed to svc_precache in 6
2615 CL_ParseStartSoundPacket(true);
2619 int i = (unsigned short)MSG_ReadShort();
2620 char *s = MSG_ReadString();
2623 if (i >= 1 && i < MAX_MODELS)
2625 model_t *model = Mod_ForName(s, false, false, i == 1);
2627 Con_Printf("svc_precache: Mod_ForName(\"%s\") failed\n", s);
2628 cl.model_precache[i] = model;
2631 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_MODELS);
2636 if (i >= 1 && i < MAX_SOUNDS)
2638 sfx_t *sfx = S_PrecacheSound (s, true, false);
2639 if (!sfx && snd_initialized.integer)
2640 Con_Printf("svc_precache: S_PrecacheSound(\"%s\") failed\n", s);
2641 cl.sound_precache[i] = sfx;
2644 Con_Printf("svc_precache: index %i outside range %i...%i\n", i, 1, MAX_SOUNDS);
2650 i = (unsigned short) MSG_ReadShort();
2651 S_StopSound(i>>3, i&7);
2654 case svc_updatename:
2655 i = MSG_ReadByte ();
2656 if (i >= cl.maxclients)
2657 Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
2658 strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
2661 case svc_updatefrags:
2662 i = MSG_ReadByte ();
2663 if (i >= cl.maxclients)
2664 Host_Error ("CL_ParseServerMessage: svc_updatefrags >= cl.maxclients");
2665 cl.scores[i].frags = (signed short) MSG_ReadShort ();
2668 case svc_updatecolors:
2669 i = MSG_ReadByte ();
2670 if (i >= cl.maxclients)
2671 Host_Error ("CL_ParseServerMessage: svc_updatecolors >= cl.maxclients");
2672 cl.scores[i].colors = MSG_ReadByte ();
2676 CL_ParseParticleEffect ();
2687 case svc_spawnbaseline:
2688 i = (unsigned short) MSG_ReadShort ();
2689 if (i < 0 || i >= MAX_EDICTS)
2690 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline: invalid entity number %i", i);
2691 if (i >= cl.max_entities)
2692 CL_ExpandEntities(i);
2693 CL_ParseBaseline (cl.entities + i, false);
2695 case svc_spawnbaseline2:
2696 i = (unsigned short) MSG_ReadShort ();
2697 if (i < 0 || i >= MAX_EDICTS)
2698 Host_Error ("CL_ParseServerMessage: svc_spawnbaseline2: invalid entity number %i", i);
2699 if (i >= cl.max_entities)
2700 CL_ExpandEntities(i);
2701 CL_ParseBaseline (cl.entities + i, true);
2703 case svc_spawnstatic:
2704 CL_ParseStatic (false);
2706 case svc_spawnstatic2:
2707 CL_ParseStatic (true);
2709 case svc_temp_entity:
2710 if(!CL_VM_Parse_TempEntity())
2711 CL_ParseTempEntity ();
2715 cl.paused = MSG_ReadByte ();
2720 S_PauseGameSounds (cl.paused);
2724 i = MSG_ReadByte ();
2725 // LordHavoc: it's rude to kick off the client if they missed the
2726 // reconnect somehow, so allow signon 1 even if at signon 1
2727 if (i <= cls.signon && i != 1)
2728 Host_Error ("Received signon %i when at %i", i, cls.signon);
2733 case svc_killedmonster:
2734 cl.stats[STAT_MONSTERS]++;
2737 case svc_foundsecret:
2738 cl.stats[STAT_SECRETS]++;
2741 case svc_updatestat:
2742 i = MSG_ReadByte ();
2743 if (i < 0 || i >= MAX_CL_STATS)
2744 Host_Error ("svc_updatestat: %i is invalid", i);
2745 cl.stats[i] = MSG_ReadLong ();
2748 case svc_updatestatubyte:
2749 i = MSG_ReadByte ();
2750 if (i < 0 || i >= MAX_CL_STATS)
2751 Host_Error ("svc_updatestat: %i is invalid", i);
2752 cl.stats[i] = MSG_ReadByte ();
2755 case svc_spawnstaticsound:
2756 CL_ParseStaticSound (false);
2759 case svc_spawnstaticsound2:
2760 CL_ParseStaticSound (true);
2764 cl.cdtrack = MSG_ReadByte ();
2765 cl.looptrack = MSG_ReadByte ();
2766 if ( (cls.demoplayback || cls.demorecording) && (cls.forcetrack != -1) )
2767 CDAudio_Play ((unsigned char)cls.forcetrack, true);
2769 CDAudio_Play ((unsigned char)cl.cdtrack, true);
2772 case svc_intermission:
2773 cl.intermission = 1;
2774 cl.completed_time = cl.time;
2778 cl.intermission = 2;
2779 cl.completed_time = cl.time;
2780 SCR_CenterPrint(MSG_ReadString ());
2784 cl.intermission = 3;
2785 cl.completed_time = cl.time;
2786 SCR_CenterPrint(MSG_ReadString ());
2789 case svc_sellscreen:
2790 Cmd_ExecuteString ("help", src_command);
2793 if (gamemode == GAME_TENEBRAE)
2795 // repeating particle effect
2796 MSG_ReadCoord(cls.protocol);
2797 MSG_ReadCoord(cls.protocol);
2798 MSG_ReadCoord(cls.protocol);
2799 MSG_ReadCoord(cls.protocol);
2800 MSG_ReadCoord(cls.protocol);
2801 MSG_ReadCoord(cls.protocol);
2808 SHOWLMP_decodehide();
2811 if (gamemode == GAME_TENEBRAE)
2814 MSG_ReadCoord(cls.protocol);
2815 MSG_ReadCoord(cls.protocol);
2816 MSG_ReadCoord(cls.protocol);
2821 SHOWLMP_decodeshow();
2824 R_SetSkyBox(MSG_ReadString());
2827 if (cls.signon == SIGNONS - 1)
2829 // first update is the final signon stage
2830 cls.signon = SIGNONS;
2833 if (cls.protocol == PROTOCOL_DARKPLACES1 || cls.protocol == PROTOCOL_DARKPLACES2 || cls.protocol == PROTOCOL_DARKPLACES3)
2834 EntityFrame_CL_ReadFrame();
2835 else if (cls.protocol == PROTOCOL_DARKPLACES4)
2836 EntityFrame4_CL_ReadFrame();
2838 EntityFrame5_CL_ReadFrame();
2840 case svc_csqcentities:
2841 CSQC_ReadEntities();
2847 CL_UpdateItemsAndWeapon();
2849 EntityFrameQuake_ISeeDeadEntities();
2851 parsingerror = false;
2854 void CL_Parse_DumpPacket(void)
2858 Con_Print("Packet dump:\n");
2859 SZ_HexDumpToConsole(&net_message);
2860 parsingerror = false;
2863 void CL_Parse_ErrorCleanUp(void)
2865 if (cls.qw_downloadmemory)
2867 Mem_Free(cls.qw_downloadmemory);
2868 cls.qw_downloadmemory = NULL;
2870 cls.qw_downloadpercent = 0;
2874 void CL_Parse_Init(void)
2876 // LordHavoc: added demo_nehahra cvar
2877 Cvar_RegisterVariable (&demo_nehahra);
2878 if (gamemode == GAME_NEHAHRA)
2879 Cvar_SetValue("demo_nehahra", 1);
2880 Cvar_RegisterVariable(&developer_networkentities);
2882 Cvar_RegisterVariable(&cl_sound_wizardhit);
2883 Cvar_RegisterVariable(&cl_sound_hknighthit);
2884 Cvar_RegisterVariable(&cl_sound_tink1);
2885 Cvar_RegisterVariable(&cl_sound_ric1);
2886 Cvar_RegisterVariable(&cl_sound_ric2);
2887 Cvar_RegisterVariable(&cl_sound_ric3);
2888 Cvar_RegisterVariable(&cl_sound_r_exp3);
2890 Cmd_AddCommand("nextul", QW_CL_NextUpload, "sends next fragment of current upload buffer (screenshot for example)");
2891 Cmd_AddCommand("stopul", QW_CL_StopUpload, "aborts current upload (screenshot for example)");
2892 Cmd_AddCommand("skins", QW_CL_Skins_f, "downloads missing qw skins from server");
2893 Cmd_AddCommand("changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change");
2896 void CL_Parse_Shutdown(void)