cl_parse.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. /*
  2. Copyright (C) 1997-2001 Id Software, Inc.
  3. This program is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU General Public License
  5. as published by the Free Software Foundation; either version 2
  6. of the License, or (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. See the GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  14. */
  15. // cl_parse.c -- parse a message received from the server
  16. #include "client.h"
  17. char *svc_strings[256] =
  18. {
  19. "svc_bad",
  20. "svc_muzzleflash",
  21. "svc_muzzlflash2",
  22. "svc_temp_entity",
  23. "svc_layout",
  24. "svc_inventory",
  25. "svc_nop",
  26. "svc_disconnect",
  27. "svc_reconnect",
  28. "svc_sound",
  29. "svc_print",
  30. "svc_stufftext",
  31. "svc_serverdata",
  32. "svc_configstring",
  33. "svc_spawnbaseline",
  34. "svc_centerprint",
  35. "svc_download",
  36. "svc_playerinfo",
  37. "svc_packetentities",
  38. "svc_deltapacketentities",
  39. "svc_frame"
  40. };
  41. //=============================================================================
  42. void CL_DownloadFileName(char *dest, int destlen, char *fn)
  43. {
  44. if (strncmp(fn, "players", 7) == 0)
  45. Com_sprintf (dest, destlen, "%s/%s", BASEDIRNAME, fn);
  46. else
  47. Com_sprintf (dest, destlen, "%s/%s", FS_Gamedir(), fn);
  48. }
  49. /*
  50. ===============
  51. CL_CheckOrDownloadFile
  52. Returns true if the file exists, otherwise it attempts
  53. to start a download from the server.
  54. ===============
  55. */
  56. qboolean CL_CheckOrDownloadFile (char *filename)
  57. {
  58. FILE *fp;
  59. char name[MAX_OSPATH];
  60. if (strstr (filename, ".."))
  61. {
  62. Com_Printf ("Refusing to download a path with ..\n");
  63. return true;
  64. }
  65. if (FS_LoadFile (filename, NULL) != -1)
  66. { // it exists, no need to download
  67. return true;
  68. }
  69. strcpy (cls.downloadname, filename);
  70. // download to a temp name, and only rename
  71. // to the real name when done, so if interrupted
  72. // a runt file wont be left
  73. COM_StripExtension (cls.downloadname, cls.downloadtempname);
  74. strcat (cls.downloadtempname, ".tmp");
  75. //ZOID
  76. // check to see if we already have a tmp for this file, if so, try to resume
  77. // open the file if not opened yet
  78. CL_DownloadFileName(name, sizeof(name), cls.downloadtempname);
  79. // FS_CreatePath (name);
  80. fp = fopen (name, "r+b");
  81. if (fp) { // it exists
  82. int len;
  83. fseek(fp, 0, SEEK_END);
  84. len = ftell(fp);
  85. cls.download = fp;
  86. // give the server an offset to start the download
  87. Com_Printf ("Resuming %s\n", cls.downloadname);
  88. MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
  89. MSG_WriteString (&cls.netchan.message,
  90. va("download %s %i", cls.downloadname, len));
  91. } else {
  92. Com_Printf ("Downloading %s\n", cls.downloadname);
  93. MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
  94. MSG_WriteString (&cls.netchan.message,
  95. va("download %s", cls.downloadname));
  96. }
  97. cls.downloadnumber++;
  98. return false;
  99. }
  100. /*
  101. ===============
  102. CL_Download_f
  103. Request a download from the server
  104. ===============
  105. */
  106. void CL_Download_f (void)
  107. {
  108. char filename[MAX_OSPATH];
  109. if (Cmd_Argc() != 2) {
  110. Com_Printf("Usage: download <filename>\n");
  111. return;
  112. }
  113. Com_sprintf(filename, sizeof(filename), "%s", Cmd_Argv(1));
  114. if (strstr (filename, ".."))
  115. {
  116. Com_Printf ("Refusing to download a path with ..\n");
  117. return;
  118. }
  119. if (FS_LoadFile (filename, NULL) != -1)
  120. { // it exists, no need to download
  121. Com_Printf("File already exists.\n");
  122. return;
  123. }
  124. strcpy (cls.downloadname, filename);
  125. Com_Printf ("Downloading %s\n", cls.downloadname);
  126. // download to a temp name, and only rename
  127. // to the real name when done, so if interrupted
  128. // a runt file wont be left
  129. COM_StripExtension (cls.downloadname, cls.downloadtempname);
  130. strcat (cls.downloadtempname, ".tmp");
  131. MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
  132. MSG_WriteString (&cls.netchan.message,
  133. va("download %s", cls.downloadname));
  134. cls.downloadnumber++;
  135. }
  136. /*
  137. ======================
  138. CL_RegisterSounds
  139. ======================
  140. */
  141. void CL_RegisterSounds (void)
  142. {
  143. int i;
  144. S_BeginRegistration ();
  145. CL_RegisterTEntSounds ();
  146. for (i=1 ; i<MAX_SOUNDS ; i++)
  147. {
  148. if (!cl.configstrings[CS_SOUNDS+i][0])
  149. break;
  150. cl.sound_precache[i] = S_RegisterSound (cl.configstrings[CS_SOUNDS+i]);
  151. Sys_SendKeyEvents (); // pump message loop
  152. }
  153. S_EndRegistration ();
  154. }
  155. /*
  156. =====================
  157. CL_ParseDownload
  158. A download message has been received from the server
  159. =====================
  160. */
  161. void CL_ParseDownload (void)
  162. {
  163. int size, percent;
  164. char name[MAX_OSPATH];
  165. int r;
  166. // read the data
  167. size = MSG_ReadShort (&net_message);
  168. percent = MSG_ReadByte (&net_message);
  169. if (size == -1)
  170. {
  171. Com_Printf ("Server does not have this file.\n");
  172. if (cls.download)
  173. {
  174. // if here, we tried to resume a file but the server said no
  175. fclose (cls.download);
  176. cls.download = NULL;
  177. }
  178. CL_RequestNextDownload ();
  179. return;
  180. }
  181. // open the file if not opened yet
  182. if (!cls.download)
  183. {
  184. CL_DownloadFileName(name, sizeof(name), cls.downloadtempname);
  185. FS_CreatePath (name);
  186. cls.download = fopen (name, "wb");
  187. if (!cls.download)
  188. {
  189. net_message.readcount += size;
  190. Com_Printf ("Failed to open %s\n", cls.downloadtempname);
  191. CL_RequestNextDownload ();
  192. return;
  193. }
  194. }
  195. fwrite (net_message.data + net_message.readcount, 1, size, cls.download);
  196. net_message.readcount += size;
  197. if (percent != 100)
  198. {
  199. // request next block
  200. // change display routines by zoid
  201. #if 0
  202. Com_Printf (".");
  203. if (10*(percent/10) != cls.downloadpercent)
  204. {
  205. cls.downloadpercent = 10*(percent/10);
  206. Com_Printf ("%i%%", cls.downloadpercent);
  207. }
  208. #endif
  209. cls.downloadpercent = percent;
  210. MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
  211. SZ_Print (&cls.netchan.message, "nextdl");
  212. }
  213. else
  214. {
  215. char oldn[MAX_OSPATH];
  216. char newn[MAX_OSPATH];
  217. // Com_Printf ("100%%\n");
  218. fclose (cls.download);
  219. // rename the temp file to it's final name
  220. CL_DownloadFileName(oldn, sizeof(oldn), cls.downloadtempname);
  221. CL_DownloadFileName(newn, sizeof(newn), cls.downloadname);
  222. r = rename (oldn, newn);
  223. if (r)
  224. Com_Printf ("failed to rename.\n");
  225. cls.download = NULL;
  226. cls.downloadpercent = 0;
  227. // get another file if needed
  228. CL_RequestNextDownload ();
  229. }
  230. }
  231. /*
  232. =====================================================================
  233. SERVER CONNECTING MESSAGES
  234. =====================================================================
  235. */
  236. /*
  237. ==================
  238. CL_ParseServerData
  239. ==================
  240. */
  241. void CL_ParseServerData (void)
  242. {
  243. extern cvar_t *fs_gamedirvar;
  244. char *str;
  245. int i;
  246. Com_DPrintf ("Serverdata packet received.\n");
  247. //
  248. // wipe the client_state_t struct
  249. //
  250. CL_ClearState ();
  251. cls.state = ca_connected;
  252. // parse protocol version number
  253. i = MSG_ReadLong (&net_message);
  254. cls.serverProtocol = i;
  255. // BIG HACK to let demos from release work with the 3.0x patch!!!
  256. if (Com_ServerState() && PROTOCOL_VERSION == 34)
  257. {
  258. }
  259. else if (i != PROTOCOL_VERSION)
  260. Com_Error (ERR_DROP,"Server returned version %i, not %i", i, PROTOCOL_VERSION);
  261. cl.servercount = MSG_ReadLong (&net_message);
  262. cl.attractloop = MSG_ReadByte (&net_message);
  263. // game directory
  264. str = MSG_ReadString (&net_message);
  265. strncpy (cl.gamedir, str, sizeof(cl.gamedir)-1);
  266. // set gamedir
  267. if ((*str && (!fs_gamedirvar->string || !*fs_gamedirvar->string || strcmp(fs_gamedirvar->string, str))) || (!*str && (fs_gamedirvar->string || *fs_gamedirvar->string)))
  268. Cvar_Set("game", str);
  269. // parse player entity number
  270. cl.playernum = MSG_ReadShort (&net_message);
  271. // get the full level name
  272. str = MSG_ReadString (&net_message);
  273. if (cl.playernum == -1)
  274. { // playing a cinematic or showing a pic, not a level
  275. SCR_PlayCinematic (str);
  276. }
  277. else
  278. {
  279. // seperate the printfs so the server message can have a color
  280. Com_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");
  281. Com_Printf ("%c%s\n", 2, str);
  282. // need to prep refresh at next oportunity
  283. cl.refresh_prepped = false;
  284. }
  285. }
  286. /*
  287. ==================
  288. CL_ParseBaseline
  289. ==================
  290. */
  291. void CL_ParseBaseline (void)
  292. {
  293. entity_state_t *es;
  294. int bits;
  295. int newnum;
  296. entity_state_t nullstate;
  297. memset (&nullstate, 0, sizeof(nullstate));
  298. newnum = CL_ParseEntityBits (&bits);
  299. es = &cl_entities[newnum].baseline;
  300. CL_ParseDelta (&nullstate, es, newnum, bits);
  301. }
  302. /*
  303. ================
  304. CL_LoadClientinfo
  305. ================
  306. */
  307. void CL_LoadClientinfo (clientinfo_t *ci, char *s)
  308. {
  309. int i;
  310. char *t;
  311. char model_name[MAX_QPATH];
  312. char skin_name[MAX_QPATH];
  313. char model_filename[MAX_QPATH];
  314. char skin_filename[MAX_QPATH];
  315. char weapon_filename[MAX_QPATH];
  316. strncpy(ci->cinfo, s, sizeof(ci->cinfo));
  317. ci->cinfo[sizeof(ci->cinfo)-1] = 0;
  318. // isolate the player's name
  319. strncpy(ci->name, s, sizeof(ci->name));
  320. ci->name[sizeof(ci->name)-1] = 0;
  321. t = strstr (s, "\\");
  322. if (t)
  323. {
  324. ci->name[t-s] = 0;
  325. s = t+1;
  326. }
  327. if (cl_noskins->value || *s == 0)
  328. {
  329. Com_sprintf (model_filename, sizeof(model_filename), "players/male/tris.md2");
  330. Com_sprintf (weapon_filename, sizeof(weapon_filename), "players/male/weapon.md2");
  331. Com_sprintf (skin_filename, sizeof(skin_filename), "players/male/grunt.pcx");
  332. Com_sprintf (ci->iconname, sizeof(ci->iconname), "/players/male/grunt_i.pcx");
  333. ci->model = re.RegisterModel (model_filename);
  334. memset(ci->weaponmodel, 0, sizeof(ci->weaponmodel));
  335. ci->weaponmodel[0] = re.RegisterModel (weapon_filename);
  336. ci->skin = re.RegisterSkin (skin_filename);
  337. ci->icon = re.RegisterPic (ci->iconname);
  338. }
  339. else
  340. {
  341. // isolate the model name
  342. strcpy (model_name, s);
  343. t = strstr(model_name, "/");
  344. if (!t)
  345. t = strstr(model_name, "\\");
  346. if (!t)
  347. t = model_name;
  348. *t = 0;
  349. // isolate the skin name
  350. strcpy (skin_name, s + strlen(model_name) + 1);
  351. // model file
  352. Com_sprintf (model_filename, sizeof(model_filename), "players/%s/tris.md2", model_name);
  353. ci->model = re.RegisterModel (model_filename);
  354. if (!ci->model)
  355. {
  356. strcpy(model_name, "male");
  357. Com_sprintf (model_filename, sizeof(model_filename), "players/male/tris.md2");
  358. ci->model = re.RegisterModel (model_filename);
  359. }
  360. // skin file
  361. Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/%s.pcx", model_name, skin_name);
  362. ci->skin = re.RegisterSkin (skin_filename);
  363. // if we don't have the skin and the model wasn't male,
  364. // see if the male has it (this is for CTF's skins)
  365. if (!ci->skin && Q_stricmp(model_name, "male"))
  366. {
  367. // change model to male
  368. strcpy(model_name, "male");
  369. Com_sprintf (model_filename, sizeof(model_filename), "players/male/tris.md2");
  370. ci->model = re.RegisterModel (model_filename);
  371. // see if the skin exists for the male model
  372. Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/%s.pcx", model_name, skin_name);
  373. ci->skin = re.RegisterSkin (skin_filename);
  374. }
  375. // if we still don't have a skin, it means that the male model didn't have
  376. // it, so default to grunt
  377. if (!ci->skin) {
  378. // see if the skin exists for the male model
  379. Com_sprintf (skin_filename, sizeof(skin_filename), "players/%s/grunt.pcx", model_name, skin_name);
  380. ci->skin = re.RegisterSkin (skin_filename);
  381. }
  382. // weapon file
  383. for (i = 0; i < num_cl_weaponmodels; i++) {
  384. Com_sprintf (weapon_filename, sizeof(weapon_filename), "players/%s/%s", model_name, cl_weaponmodels[i]);
  385. ci->weaponmodel[i] = re.RegisterModel(weapon_filename);
  386. if (!ci->weaponmodel[i] && strcmp(model_name, "cyborg") == 0) {
  387. // try male
  388. Com_sprintf (weapon_filename, sizeof(weapon_filename), "players/male/%s", cl_weaponmodels[i]);
  389. ci->weaponmodel[i] = re.RegisterModel(weapon_filename);
  390. }
  391. if (!cl_vwep->value)
  392. break; // only one when vwep is off
  393. }
  394. // icon file
  395. Com_sprintf (ci->iconname, sizeof(ci->iconname), "/players/%s/%s_i.pcx", model_name, skin_name);
  396. ci->icon = re.RegisterPic (ci->iconname);
  397. }
  398. // must have loaded all data types to be valud
  399. if (!ci->skin || !ci->icon || !ci->model || !ci->weaponmodel[0])
  400. {
  401. ci->skin = NULL;
  402. ci->icon = NULL;
  403. ci->model = NULL;
  404. ci->weaponmodel[0] = NULL;
  405. return;
  406. }
  407. }
  408. /*
  409. ================
  410. CL_ParseClientinfo
  411. Load the skin, icon, and model for a client
  412. ================
  413. */
  414. void CL_ParseClientinfo (int player)
  415. {
  416. char *s;
  417. clientinfo_t *ci;
  418. s = cl.configstrings[player+CS_PLAYERSKINS];
  419. ci = &cl.clientinfo[player];
  420. CL_LoadClientinfo (ci, s);
  421. }
  422. /*
  423. ================
  424. CL_ParseConfigString
  425. ================
  426. */
  427. void CL_ParseConfigString (void)
  428. {
  429. int i;
  430. char *s;
  431. i = MSG_ReadShort (&net_message);
  432. if (i < 0 || i >= MAX_CONFIGSTRINGS)
  433. Com_Error (ERR_DROP, "configstring > MAX_CONFIGSTRINGS");
  434. s = MSG_ReadString(&net_message);
  435. strcpy (cl.configstrings[i], s);
  436. // do something apropriate
  437. if (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES)
  438. CL_SetLightstyle (i - CS_LIGHTS);
  439. else if (i == CS_CDTRACK)
  440. {
  441. if (cl.refresh_prepped)
  442. CDAudio_Play (atoi(cl.configstrings[CS_CDTRACK]), true);
  443. }
  444. else if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS)
  445. {
  446. if (cl.refresh_prepped)
  447. {
  448. cl.model_draw[i-CS_MODELS] = re.RegisterModel (cl.configstrings[i]);
  449. if (cl.configstrings[i][0] == '*')
  450. cl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]);
  451. else
  452. cl.model_clip[i-CS_MODELS] = NULL;
  453. }
  454. }
  455. else if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_MODELS)
  456. {
  457. if (cl.refresh_prepped)
  458. cl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]);
  459. }
  460. else if (i >= CS_IMAGES && i < CS_IMAGES+MAX_MODELS)
  461. {
  462. if (cl.refresh_prepped)
  463. cl.image_precache[i-CS_IMAGES] = re.RegisterPic (cl.configstrings[i]);
  464. }
  465. else if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS)
  466. {
  467. if (cl.refresh_prepped)
  468. CL_ParseClientinfo (i-CS_PLAYERSKINS);
  469. }
  470. }
  471. /*
  472. =====================================================================
  473. ACTION MESSAGES
  474. =====================================================================
  475. */
  476. /*
  477. ==================
  478. CL_ParseStartSoundPacket
  479. ==================
  480. */
  481. void CL_ParseStartSoundPacket(void)
  482. {
  483. vec3_t pos_v;
  484. float *pos;
  485. int channel, ent;
  486. int sound_num;
  487. float volume;
  488. float attenuation;
  489. int flags;
  490. float ofs;
  491. flags = MSG_ReadByte (&net_message);
  492. sound_num = MSG_ReadByte (&net_message);
  493. if (flags & SND_VOLUME)
  494. volume = MSG_ReadByte (&net_message) / 255.0;
  495. else
  496. volume = DEFAULT_SOUND_PACKET_VOLUME;
  497. if (flags & SND_ATTENUATION)
  498. attenuation = MSG_ReadByte (&net_message) / 64.0;
  499. else
  500. attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
  501. if (flags & SND_OFFSET)
  502. ofs = MSG_ReadByte (&net_message) / 1000.0;
  503. else
  504. ofs = 0;
  505. if (flags & SND_ENT)
  506. { // entity reletive
  507. channel = MSG_ReadShort(&net_message);
  508. ent = channel>>3;
  509. if (ent > MAX_EDICTS)
  510. Com_Error (ERR_DROP,"CL_ParseStartSoundPacket: ent = %i", ent);
  511. channel &= 7;
  512. }
  513. else
  514. {
  515. ent = 0;
  516. channel = 0;
  517. }
  518. if (flags & SND_POS)
  519. { // positioned in space
  520. MSG_ReadPos (&net_message, pos_v);
  521. pos = pos_v;
  522. }
  523. else // use entity number
  524. pos = NULL;
  525. if (!cl.sound_precache[sound_num])
  526. return;
  527. S_StartSound (pos, ent, channel, cl.sound_precache[sound_num], volume, attenuation, ofs);
  528. }
  529. void SHOWNET(char *s)
  530. {
  531. if (cl_shownet->value>=2)
  532. Com_Printf ("%3i:%s\n", net_message.readcount-1, s);
  533. }
  534. /*
  535. =====================
  536. CL_ParseServerMessage
  537. =====================
  538. */
  539. void CL_ParseServerMessage (void)
  540. {
  541. int cmd;
  542. char *s;
  543. int i;
  544. //
  545. // if recording demos, copy the message out
  546. //
  547. if (cl_shownet->value == 1)
  548. Com_Printf ("%i ",net_message.cursize);
  549. else if (cl_shownet->value >= 2)
  550. Com_Printf ("------------------\n");
  551. //
  552. // parse the message
  553. //
  554. while (1)
  555. {
  556. if (net_message.readcount > net_message.cursize)
  557. {
  558. Com_Error (ERR_DROP,"CL_ParseServerMessage: Bad server message");
  559. break;
  560. }
  561. cmd = MSG_ReadByte (&net_message);
  562. if (cmd == -1)
  563. {
  564. SHOWNET("END OF MESSAGE");
  565. break;
  566. }
  567. if (cl_shownet->value>=2)
  568. {
  569. if (!svc_strings[cmd])
  570. Com_Printf ("%3i:BAD CMD %i\n", net_message.readcount-1,cmd);
  571. else
  572. SHOWNET(svc_strings[cmd]);
  573. }
  574. // other commands
  575. switch (cmd)
  576. {
  577. default:
  578. Com_Error (ERR_DROP,"CL_ParseServerMessage: Illegible server message\n");
  579. break;
  580. case svc_nop:
  581. // Com_Printf ("svc_nop\n");
  582. break;
  583. case svc_disconnect:
  584. Com_Error (ERR_DISCONNECT,"Server disconnected\n");
  585. break;
  586. case svc_reconnect:
  587. Com_Printf ("Server disconnected, reconnecting\n");
  588. if (cls.download) {
  589. //ZOID, close download
  590. fclose (cls.download);
  591. cls.download = NULL;
  592. }
  593. cls.state = ca_connecting;
  594. cls.connect_time = -99999; // CL_CheckForResend() will fire immediately
  595. break;
  596. case svc_print:
  597. i = MSG_ReadByte (&net_message);
  598. if (i == PRINT_CHAT)
  599. {
  600. S_StartLocalSound ("misc/talk.wav");
  601. con.ormask = 128;
  602. }
  603. Com_Printf ("%s", MSG_ReadString (&net_message));
  604. con.ormask = 0;
  605. break;
  606. case svc_centerprint:
  607. SCR_CenterPrint (MSG_ReadString (&net_message));
  608. break;
  609. case svc_stufftext:
  610. s = MSG_ReadString (&net_message);
  611. Com_DPrintf ("stufftext: %s\n", s);
  612. Cbuf_AddText (s);
  613. break;
  614. case svc_serverdata:
  615. Cbuf_Execute (); // make sure any stuffed commands are done
  616. CL_ParseServerData ();
  617. break;
  618. case svc_configstring:
  619. CL_ParseConfigString ();
  620. break;
  621. case svc_sound:
  622. CL_ParseStartSoundPacket();
  623. break;
  624. case svc_spawnbaseline:
  625. CL_ParseBaseline ();
  626. break;
  627. case svc_temp_entity:
  628. CL_ParseTEnt ();
  629. break;
  630. case svc_muzzleflash:
  631. CL_ParseMuzzleFlash ();
  632. break;
  633. case svc_muzzleflash2:
  634. CL_ParseMuzzleFlash2 ();
  635. break;
  636. case svc_download:
  637. CL_ParseDownload ();
  638. break;
  639. case svc_frame:
  640. CL_ParseFrame ();
  641. break;
  642. case svc_inventory:
  643. CL_ParseInventory ();
  644. break;
  645. case svc_layout:
  646. s = MSG_ReadString (&net_message);
  647. strncpy (cl.layout, s, sizeof(cl.layout)-1);
  648. break;
  649. case svc_playerinfo:
  650. case svc_packetentities:
  651. case svc_deltapacketentities:
  652. Com_Error (ERR_DROP, "Out of place frame data");
  653. break;
  654. }
  655. }
  656. CL_AddNetgraph ();
  657. //
  658. // we don't know if it is ok to save a demo message until
  659. // after we have parsed the frame
  660. //
  661. if (cls.demorecording && !cls.demowaiting)
  662. CL_WriteDemoMessage ();
  663. }