vkQuake2 doxygen  1.0 dev
common.c
Go to the documentation of this file.
1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 Copyright (C) 2018-2019 Krzysztof Kondrak
4 
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 
14 See the GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 
20 */
21 // common.c -- misc functions used in client and server
22 #include "qcommon.h"
23 #include <setjmp.h>
24 
25 #define MAXPRINTMSG 8192
26 
27 #define MAX_NUM_ARGVS 50
28 
29 
32 
34 
35 jmp_buf abortframe; // an ERR_DROP occured, exit the entire frame
36 static qboolean shutdown_game = false;
37 
39 
45 cvar_t *logfile_active; // 1 = buffer log, 2 = flush after each print
48 
49 FILE *logfile;
50 
52 
53 // host_speeds times
58 
59 /*
60 ============================================================================
61 
62 CLIENT / SERVER interactions
63 
64 ============================================================================
65 */
66 
67 static int rd_target;
68 static char *rd_buffer;
69 static int rd_buffersize;
70 static void (*rd_flush)(int target, char *buffer);
71 
72 extern void SV_ShutdownGameProgs(void);
73 
74 void Com_BeginRedirect (int target, char *buffer, int buffersize, void (*flush))
75 {
76  if (!target || !buffer || !buffersize || !flush)
77  return;
78  rd_target = target;
79  rd_buffer = buffer;
80  rd_buffersize = buffersize;
81  rd_flush = flush;
82 
83  *rd_buffer = 0;
84 }
85 
86 void Com_EndRedirect (void)
87 {
89 
90  rd_target = 0;
91  rd_buffer = NULL;
92  rd_buffersize = 0;
93  rd_flush = NULL;
94 }
95 
96 /*
97 =============
98 Com_Printf
99 
100 Both client and server can use this, and it will output
101 to the apropriate place.
102 =============
103 */
104 void Com_Printf (char *fmt, ...)
105 {
106  va_list argptr;
107  char msg[MAXPRINTMSG];
108 
109  va_start (argptr,fmt);
110  vsnprintf (msg,MAXPRINTMSG,fmt,argptr);
111  va_end (argptr);
112 
113  if (rd_target)
114  {
115  if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1))
116  {
118  *rd_buffer = 0;
119  }
120  strcat (rd_buffer, msg);
121  return;
122  }
123 
124  Con_Print (msg);
125 
126  // also echo to debugging console
128 
129  // logfile
131  {
132  char name[MAX_QPATH];
133 
134  if (!logfile)
135  {
136  Com_sprintf (name, sizeof(name), "%s/qconsole.log", FS_Gamedir ());
137  if (logfile_active->value > 2)
138  logfile = fopen (name, "a");
139  else
140  logfile = fopen (name, "w");
141  }
142  if (logfile)
143  fprintf (logfile, "%s", msg);
144  if (logfile_active->value > 1)
145  fflush (logfile); // force it to save every time
146  }
147 }
148 
149 
150 /*
151 ================
152 Com_DPrintf
153 
154 A Com_Printf that only shows up if the "developer" cvar is set
155 ================
156 */
157 void Com_DPrintf (char *fmt, ...)
158 {
159  va_list argptr;
160  char msg[MAXPRINTMSG];
161 
162  if (!developer || !developer->value)
163  return; // don't confuse non-developers with techie stuff...
164 
165  va_start (argptr,fmt);
166  vsnprintf (msg,MAXPRINTMSG,fmt,argptr);
167  va_end (argptr);
168 
169  Com_Printf ("%s", msg);
170 }
171 
172 
173 /*
174 =============
175 Com_Error
176 
177 Both client and server can use this, and it will
178 do the apropriate things.
179 =============
180 */
181 void Com_Error (int code, char *fmt, ...)
182 {
183  va_list argptr;
184  static char msg[MAXPRINTMSG];
185  static qboolean recursive;
186 
187  if (recursive)
188  Sys_Error ("recursive error after: %s", msg);
189  recursive = true;
190 
191  va_start (argptr,fmt);
192  vsnprintf (msg,MAXPRINTMSG,fmt,argptr);
193  va_end (argptr);
194 
195  if (code == ERR_DISCONNECT)
196  {
197  CL_Drop ();
198  recursive = false;
199  longjmp (abortframe, -1);
200  }
201  else if (code == ERR_DROP)
202  {
203  Com_Printf ("********************\nERROR: %s\n********************\n", msg);
204  SV_Shutdown (va("Server crashed: %s\n", msg), false);
205  CL_Drop ();
206  recursive = false;
207  shutdown_game = true;
208  longjmp (abortframe, -1);
209  }
210  else
211  {
212  SV_Shutdown (va("Server fatal crashed: %s\n", msg), false);
214  CL_Shutdown ();
215  }
216 
217  if (logfile)
218  {
219  fclose (logfile);
220  logfile = NULL;
221  }
222 
223  Sys_Error ("%s", msg);
224 }
225 
226 
227 /*
228 =============
229 Com_Quit
230 
231 Both client and server can use this, and it will
232 do the apropriate things.
233 =============
234 */
235 void Com_Quit (void)
236 {
237  SV_Shutdown ("Server quit\n", false);
239  CL_Shutdown ();
240 
241  if (logfile)
242  {
243  fclose (logfile);
244  logfile = NULL;
245  }
246 
247  Sys_Quit ();
248 }
249 
250 
251 /*
252 ==================
253 Com_ServerState
254 ==================
255 */
256 int Com_ServerState (void)
257 {
258  return server_state;
259 }
260 
261 /*
262 ==================
263 Com_SetServerState
264 ==================
265 */
266 void Com_SetServerState (int state)
267 {
268  server_state = state;
269 }
270 
271 
272 /*
273 ==============================================================================
274 
275  MESSAGE IO FUNCTIONS
276 
277 Handles byte ordering and avoids alignment errors
278 ==============================================================================
279 */
280 
282 {
283 #include "../client/anorms.h"
284 };
285 
286 //
287 // writing functions
288 //
289 
290 void MSG_WriteChar (sizebuf_t *sb, int c)
291 {
292  byte *buf;
293 
294 #ifdef PARANOID
295  if (c < -128 || c > 127)
296  Com_Error (ERR_FATAL, "MSG_WriteChar: range error");
297 #endif
298 
299  buf = SZ_GetSpace (sb, 1);
300  buf[0] = c;
301 }
302 
303 void MSG_WriteByte (sizebuf_t *sb, int c)
304 {
305  byte *buf;
306 
307 #ifdef PARANOID
308  if (c < 0 || c > 255)
309  Com_Error (ERR_FATAL, "MSG_WriteByte: range error");
310 #endif
311 
312  buf = SZ_GetSpace (sb, 1);
313  buf[0] = c;
314 }
315 
316 void MSG_WriteShort (sizebuf_t *sb, int c)
317 {
318  byte *buf;
319 
320 #ifdef PARANOID
321  if (c < ((short)0x8000) || c > (short)0x7fff)
322  Com_Error (ERR_FATAL, "MSG_WriteShort: range error");
323 #endif
324 
325  buf = SZ_GetSpace (sb, 2);
326  buf[0] = c&0xff;
327  buf[1] = c>>8;
328 }
329 
330 void MSG_WriteLong (sizebuf_t *sb, int c)
331 {
332  byte *buf;
333 
334  buf = SZ_GetSpace (sb, 4);
335  buf[0] = c&0xff;
336  buf[1] = (c>>8)&0xff;
337  buf[2] = (c>>16)&0xff;
338  buf[3] = c>>24;
339 }
340 
341 void MSG_WriteFloat (sizebuf_t *sb, float f)
342 {
343  union
344  {
345  float f;
346  int l;
347  } dat;
348 
349 
350  dat.f = f;
351  dat.l = LittleLong (dat.l);
352 
353  SZ_Write (sb, &dat.l, 4);
354 }
355 
356 void MSG_WriteString (sizebuf_t *sb, char *s)
357 {
358  if (!s)
359  SZ_Write (sb, "", 1);
360  else
361  SZ_Write (sb, s, (int)strlen(s)+1);
362 }
363 
364 void MSG_WriteCoord (sizebuf_t *sb, float f)
365 {
366  MSG_WriteShort (sb, (int)(f*8));
367 }
368 
370 {
371  MSG_WriteShort (sb, (int)(pos[0]*8));
372  MSG_WriteShort (sb, (int)(pos[1]*8));
373  MSG_WriteShort (sb, (int)(pos[2]*8));
374 }
375 
376 void MSG_WriteAngle (sizebuf_t *sb, float f)
377 {
378  MSG_WriteByte (sb, (int)(f*256/360) & 255);
379 }
380 
381 void MSG_WriteAngle16 (sizebuf_t *sb, float f)
382 {
383  MSG_WriteShort (sb, ANGLE2SHORT(f));
384 }
385 
386 
388 {
389  int bits;
390 
391 //
392 // send the movement message
393 //
394  bits = 0;
395  if (cmd->angles[0] != from->angles[0])
396  bits |= CM_ANGLE1;
397  if (cmd->angles[1] != from->angles[1])
398  bits |= CM_ANGLE2;
399  if (cmd->angles[2] != from->angles[2])
400  bits |= CM_ANGLE3;
401  if (cmd->forwardmove != from->forwardmove)
402  bits |= CM_FORWARD;
403  if (cmd->sidemove != from->sidemove)
404  bits |= CM_SIDE;
405  if (cmd->upmove != from->upmove)
406  bits |= CM_UP;
407  if (cmd->buttons != from->buttons)
408  bits |= CM_BUTTONS;
409  if (cmd->impulse != from->impulse)
410  bits |= CM_IMPULSE;
411 
412  MSG_WriteByte (buf, bits);
413 
414  if (bits & CM_ANGLE1)
415  MSG_WriteShort (buf, cmd->angles[0]);
416  if (bits & CM_ANGLE2)
417  MSG_WriteShort (buf, cmd->angles[1]);
418  if (bits & CM_ANGLE3)
419  MSG_WriteShort (buf, cmd->angles[2]);
420 
421  if (bits & CM_FORWARD)
422  MSG_WriteShort (buf, cmd->forwardmove);
423  if (bits & CM_SIDE)
424  MSG_WriteShort (buf, cmd->sidemove);
425  if (bits & CM_UP)
426  MSG_WriteShort (buf, cmd->upmove);
427 
428  if (bits & CM_BUTTONS)
429  MSG_WriteByte (buf, cmd->buttons);
430  if (bits & CM_IMPULSE)
431  MSG_WriteByte (buf, cmd->impulse);
432 
433  MSG_WriteByte (buf, cmd->msec);
434  MSG_WriteByte (buf, cmd->lightlevel);
435 }
436 
437 
439 {
440  int i, best;
441  float d, bestd;
442 
443  if (!dir)
444  {
445  MSG_WriteByte (sb, 0);
446  return;
447  }
448 
449  bestd = 0;
450  best = 0;
451  for (i=0 ; i<NUMVERTEXNORMALS ; i++)
452  {
453  d = DotProduct (dir, bytedirs[i]);
454  if (d > bestd)
455  {
456  bestd = d;
457  best = i;
458  }
459  }
460  MSG_WriteByte (sb, best);
461 }
462 
463 
464 void MSG_ReadDir (sizebuf_t *sb, vec3_t dir)
465 {
466  int b;
467 
468  b = MSG_ReadByte (sb);
469  if (b >= NUMVERTEXNORMALS)
470  Com_Error (ERR_DROP, "MSF_ReadDir: out of range");
471  VectorCopy (bytedirs[b], dir);
472 }
473 
474 
475 /*
476 ==================
477 MSG_WriteDeltaEntity
478 
479 Writes part of a packetentities message.
480 Can delta from either a baseline or a previous packet_entity
481 ==================
482 */
484 {
485  int bits;
486 
487  if (!to->number)
488  Com_Error (ERR_FATAL, "Unset entity number");
489  if (to->number >= MAX_EDICTS)
490  Com_Error (ERR_FATAL, "Entity number >= MAX_EDICTS");
491 
492 // send an update
493  bits = 0;
494 
495  if (to->number >= 256)
496  bits |= U_NUMBER16; // number8 is implicit otherwise
497 
498  if (to->origin[0] != from->origin[0])
499  bits |= U_ORIGIN1;
500  if (to->origin[1] != from->origin[1])
501  bits |= U_ORIGIN2;
502  if (to->origin[2] != from->origin[2])
503  bits |= U_ORIGIN3;
504 
505  if ( to->angles[0] != from->angles[0] )
506  bits |= U_ANGLE1;
507  if ( to->angles[1] != from->angles[1] )
508  bits |= U_ANGLE2;
509  if ( to->angles[2] != from->angles[2] )
510  bits |= U_ANGLE3;
511 
512  if ( to->skinnum != from->skinnum )
513  {
514  if ((unsigned)to->skinnum < 256)
515  bits |= U_SKIN8;
516  else if ((unsigned)to->skinnum < 0x10000)
517  bits |= U_SKIN16;
518  else
519  bits |= (U_SKIN8|U_SKIN16);
520  }
521 
522  if ( to->frame != from->frame )
523  {
524  if (to->frame < 256)
525  bits |= U_FRAME8;
526  else
527  bits |= U_FRAME16;
528  }
529 
530  if ( to->effects != from->effects )
531  {
532  if (to->effects < 256)
533  bits |= U_EFFECTS8;
534  else if (to->effects < 0x8000)
535  bits |= U_EFFECTS16;
536  else
537  bits |= U_EFFECTS8|U_EFFECTS16;
538  }
539 
540  if ( to->renderfx != from->renderfx )
541  {
542  if (to->renderfx < 256)
543  bits |= U_RENDERFX8;
544  else if (to->renderfx < 0x8000)
545  bits |= U_RENDERFX16;
546  else
547  bits |= U_RENDERFX8|U_RENDERFX16;
548  }
549 
550  if ( to->solid != from->solid )
551  bits |= U_SOLID;
552 
553  // event is not delta compressed, just 0 compressed
554  if ( to->event )
555  bits |= U_EVENT;
556 
557  if ( to->modelindex != from->modelindex )
558  bits |= U_MODEL;
559  if ( to->modelindex2 != from->modelindex2 )
560  bits |= U_MODEL2;
561  if ( to->modelindex3 != from->modelindex3 )
562  bits |= U_MODEL3;
563  if ( to->modelindex4 != from->modelindex4 )
564  bits |= U_MODEL4;
565 
566  if ( to->sound != from->sound )
567  bits |= U_SOUND;
568 
569  if (newentity || (to->renderfx & RF_BEAM))
570  bits |= U_OLDORIGIN;
571 
572  //
573  // write the message
574  //
575  if (!bits && !force)
576  return; // nothing to send!
577 
578  //----------
579 
580  if (bits & 0xff000000)
581  bits |= U_MOREBITS3 | U_MOREBITS2 | U_MOREBITS1;
582  else if (bits & 0x00ff0000)
583  bits |= U_MOREBITS2 | U_MOREBITS1;
584  else if (bits & 0x0000ff00)
585  bits |= U_MOREBITS1;
586 
587  MSG_WriteByte (msg, bits&255 );
588 
589  if (bits & 0xff000000)
590  {
591  MSG_WriteByte (msg, (bits>>8)&255 );
592  MSG_WriteByte (msg, (bits>>16)&255 );
593  MSG_WriteByte (msg, (bits>>24)&255 );
594  }
595  else if (bits & 0x00ff0000)
596  {
597  MSG_WriteByte (msg, (bits>>8)&255 );
598  MSG_WriteByte (msg, (bits>>16)&255 );
599  }
600  else if (bits & 0x0000ff00)
601  {
602  MSG_WriteByte (msg, (bits>>8)&255 );
603  }
604 
605  //----------
606 
607  if (bits & U_NUMBER16)
608  MSG_WriteShort (msg, to->number);
609  else
610  MSG_WriteByte (msg, to->number);
611 
612  if (bits & U_MODEL)
614  if (bits & U_MODEL2)
616  if (bits & U_MODEL3)
618  if (bits & U_MODEL4)
620 
621  if (bits & U_FRAME8)
622  MSG_WriteByte (msg, to->frame);
623  if (bits & U_FRAME16)
624  MSG_WriteShort (msg, to->frame);
625 
626  if ((bits & U_SKIN8) && (bits & U_SKIN16)) //used for laser colors
627  MSG_WriteLong (msg, to->skinnum);
628  else if (bits & U_SKIN8)
629  MSG_WriteByte (msg, to->skinnum);
630  else if (bits & U_SKIN16)
631  MSG_WriteShort (msg, to->skinnum);
632 
633 
634  if ( (bits & (U_EFFECTS8|U_EFFECTS16)) == (U_EFFECTS8|U_EFFECTS16) )
635  MSG_WriteLong (msg, to->effects);
636  else if (bits & U_EFFECTS8)
637  MSG_WriteByte (msg, to->effects);
638  else if (bits & U_EFFECTS16)
639  MSG_WriteShort (msg, to->effects);
640 
641  if ( (bits & (U_RENDERFX8|U_RENDERFX16)) == (U_RENDERFX8|U_RENDERFX16) )
642  MSG_WriteLong (msg, to->renderfx);
643  else if (bits & U_RENDERFX8)
644  MSG_WriteByte (msg, to->renderfx);
645  else if (bits & U_RENDERFX16)
646  MSG_WriteShort (msg, to->renderfx);
647 
648  if (bits & U_ORIGIN1)
649  MSG_WriteCoord (msg, to->origin[0]);
650  if (bits & U_ORIGIN2)
651  MSG_WriteCoord (msg, to->origin[1]);
652  if (bits & U_ORIGIN3)
653  MSG_WriteCoord (msg, to->origin[2]);
654 
655  if (bits & U_ANGLE1)
656  MSG_WriteAngle(msg, to->angles[0]);
657  if (bits & U_ANGLE2)
658  MSG_WriteAngle(msg, to->angles[1]);
659  if (bits & U_ANGLE3)
660  MSG_WriteAngle(msg, to->angles[2]);
661 
662  if (bits & U_OLDORIGIN)
663  {
664  MSG_WriteCoord (msg, to->old_origin[0]);
665  MSG_WriteCoord (msg, to->old_origin[1]);
666  MSG_WriteCoord (msg, to->old_origin[2]);
667  }
668 
669  if (bits & U_SOUND)
670  MSG_WriteByte (msg, to->sound);
671  if (bits & U_EVENT)
672  MSG_WriteByte (msg, to->event);
673  if (bits & U_SOLID)
674  MSG_WriteShort (msg, to->solid);
675 }
676 
677 
678 //============================================================
679 
680 //
681 // reading functions
682 //
683 
685 {
686  msg->readcount = 0;
687 }
688 
689 // returns -1 if no more characters are available
690 int MSG_ReadChar (sizebuf_t *msg_read)
691 {
692  int c;
693 
694  if (msg_read->readcount+1 > msg_read->cursize)
695  c = -1;
696  else
697  c = (signed char)msg_read->data[msg_read->readcount];
698  msg_read->readcount++;
699 
700  return c;
701 }
702 
703 int MSG_ReadByte (sizebuf_t *msg_read)
704 {
705  int c;
706 
707  if (msg_read->readcount+1 > msg_read->cursize)
708  c = -1;
709  else
710  c = (unsigned char)msg_read->data[msg_read->readcount];
711  msg_read->readcount++;
712 
713  return c;
714 }
715 
716 int MSG_ReadShort (sizebuf_t *msg_read)
717 {
718  int c;
719 
720  if (msg_read->readcount+2 > msg_read->cursize)
721  c = -1;
722  else
723  c = (short)(msg_read->data[msg_read->readcount]
724  + (msg_read->data[msg_read->readcount+1]<<8));
725 
726  msg_read->readcount += 2;
727 
728  return c;
729 }
730 
731 int MSG_ReadLong (sizebuf_t *msg_read)
732 {
733  int c;
734 
735  if (msg_read->readcount+4 > msg_read->cursize)
736  c = -1;
737  else
738  c = msg_read->data[msg_read->readcount]
739  + (msg_read->data[msg_read->readcount+1]<<8)
740  + (msg_read->data[msg_read->readcount+2]<<16)
741  + (msg_read->data[msg_read->readcount+3]<<24);
742 
743  msg_read->readcount += 4;
744 
745  return c;
746 }
747 
748 float MSG_ReadFloat (sizebuf_t *msg_read)
749 {
750  union
751  {
752  byte b[4];
753  float f;
754  int l;
755  } dat;
756 
757  if (msg_read->readcount+4 > msg_read->cursize)
758  dat.f = -1;
759  else
760  {
761  dat.b[0] = msg_read->data[msg_read->readcount];
762  dat.b[1] = msg_read->data[msg_read->readcount+1];
763  dat.b[2] = msg_read->data[msg_read->readcount+2];
764  dat.b[3] = msg_read->data[msg_read->readcount+3];
765  }
766  msg_read->readcount += 4;
767 
768  dat.l = LittleLong (dat.l);
769 
770  return dat.f;
771 }
772 
773 char *MSG_ReadString (sizebuf_t *msg_read)
774 {
775  static char string[2048];
776  int l,c;
777 
778  l = 0;
779  do
780  {
781  c = MSG_ReadChar (msg_read);
782  if (c == -1 || c == 0)
783  break;
784  string[l] = c;
785  l++;
786  } while (l < sizeof(string)-1);
787 
788  string[l] = 0;
789 
790  return string;
791 }
792 
793 char *MSG_ReadStringLine (sizebuf_t *msg_read)
794 {
795  static char string[2048];
796  int l,c;
797 
798  l = 0;
799  do
800  {
801  c = MSG_ReadChar (msg_read);
802  if (c == -1 || c == 0 || c == '\n')
803  break;
804  string[l] = c;
805  l++;
806  } while (l < sizeof(string)-1);
807 
808  string[l] = 0;
809 
810  return string;
811 }
812 
813 float MSG_ReadCoord (sizebuf_t *msg_read)
814 {
815  return MSG_ReadShort(msg_read) * (1.0/8);
816 }
817 
818 void MSG_ReadPos (sizebuf_t *msg_read, vec3_t pos)
819 {
820  pos[0] = MSG_ReadShort(msg_read) * (1.0/8);
821  pos[1] = MSG_ReadShort(msg_read) * (1.0/8);
822  pos[2] = MSG_ReadShort(msg_read) * (1.0/8);
823 }
824 
825 float MSG_ReadAngle (sizebuf_t *msg_read)
826 {
827  return MSG_ReadChar(msg_read) * (360.0/256);
828 }
829 
830 float MSG_ReadAngle16 (sizebuf_t *msg_read)
831 {
832  return SHORT2ANGLE(MSG_ReadShort(msg_read));
833 }
834 
835 void MSG_ReadDeltaUsercmd (sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move)
836 {
837  int bits;
838 
839  memcpy (move, from, sizeof(*move));
840 
841  bits = MSG_ReadByte (msg_read);
842 
843 // read current angles
844  if (bits & CM_ANGLE1)
845  move->angles[0] = MSG_ReadShort (msg_read);
846  if (bits & CM_ANGLE2)
847  move->angles[1] = MSG_ReadShort (msg_read);
848  if (bits & CM_ANGLE3)
849  move->angles[2] = MSG_ReadShort (msg_read);
850 
851 // read movement
852  if (bits & CM_FORWARD)
853  move->forwardmove = MSG_ReadShort (msg_read);
854  if (bits & CM_SIDE)
855  move->sidemove = MSG_ReadShort (msg_read);
856  if (bits & CM_UP)
857  move->upmove = MSG_ReadShort (msg_read);
858 
859 // read buttons
860  if (bits & CM_BUTTONS)
861  move->buttons = MSG_ReadByte (msg_read);
862 
863  if (bits & CM_IMPULSE)
864  move->impulse = MSG_ReadByte (msg_read);
865 
866 // read time to run command
867  move->msec = MSG_ReadByte (msg_read);
868 
869 // read the light level
870  move->lightlevel = MSG_ReadByte (msg_read);
871 }
872 
873 
874 void MSG_ReadData (sizebuf_t *msg_read, void *data, int len)
875 {
876  int i;
877 
878  for (i=0 ; i<len ; i++)
879  ((byte *)data)[i] = MSG_ReadByte (msg_read);
880 }
881 
882 
883 //===========================================================================
884 
885 void SZ_Init (sizebuf_t *buf, byte *data, int length)
886 {
887  memset (buf, 0, sizeof(*buf));
888  buf->data = data;
889  buf->maxsize = length;
890 }
891 
892 void SZ_Clear (sizebuf_t *buf)
893 {
894  buf->cursize = 0;
895  buf->overflowed = false;
896 }
897 
898 void *SZ_GetSpace (sizebuf_t *buf, int length)
899 {
900  void *data;
901 
902  if (buf->cursize + length > buf->maxsize)
903  {
904  if (!buf->allowoverflow)
905  Com_Error (ERR_FATAL, "SZ_GetSpace: overflow without allowoverflow set");
906 
907  if (length > buf->maxsize)
908  Com_Error (ERR_FATAL, "SZ_GetSpace: %i is > full buffer size", length);
909 
910  Com_Printf ("SZ_GetSpace: overflow\n");
911  SZ_Clear (buf);
912  buf->overflowed = true;
913  }
914 
915  data = buf->data + buf->cursize;
916  buf->cursize += length;
917 
918  return data;
919 }
920 
921 void SZ_Write (sizebuf_t *buf, void *data, int length)
922 {
923  memcpy (SZ_GetSpace(buf,length),data,length);
924 }
925 
926 void SZ_Print (sizebuf_t *buf, char *data)
927 {
928  int len;
929 
930  len = (int)strlen(data)+1;
931 
932  if (buf->cursize)
933  {
934  if (buf->data[buf->cursize-1])
935  memcpy ((byte *)SZ_GetSpace(buf, len),data,len); // no trailing 0
936  else
937  memcpy ((byte *)SZ_GetSpace(buf, len-1)-1,data,len); // write over trailing 0
938  }
939  else
940  memcpy ((byte *)SZ_GetSpace(buf, len),data,len);
941 }
942 
943 
944 //============================================================================
945 
946 
947 /*
948 ================
949 COM_CheckParm
950 
951 Returns the position (1 to argc-1) in the program's argument list
952 where the given parameter apears, or 0 if not present
953 ================
954 */
955 int COM_CheckParm (char *parm)
956 {
957  int i;
958 
959  for (i=1 ; i<com_argc ; i++)
960  {
961  if (!strcmp (parm,com_argv[i]))
962  return i;
963  }
964 
965  return 0;
966 }
967 
968 int COM_Argc (void)
969 {
970  return com_argc;
971 }
972 
973 char *COM_Argv (int arg)
974 {
975  if (arg < 0 || arg >= com_argc || !com_argv[arg])
976  return "";
977  return com_argv[arg];
978 }
979 
980 void COM_ClearArgv (int arg)
981 {
982  if (arg < 0 || arg >= com_argc || !com_argv[arg])
983  return;
984  com_argv[arg] = "";
985 }
986 
987 
988 /*
989 ================
990 COM_InitArgv
991 ================
992 */
993 void COM_InitArgv (int argc, char **argv)
994 {
995  int i;
996 
997  if (argc > MAX_NUM_ARGVS)
998  Com_Error (ERR_FATAL, "argc > MAX_NUM_ARGVS");
999  com_argc = argc;
1000  for (i=0 ; i<argc ; i++)
1001  {
1002  if (!argv[i] || strlen(argv[i]) >= MAX_TOKEN_CHARS )
1003  com_argv[i] = "";
1004  else
1005  com_argv[i] = argv[i];
1006  }
1007 }
1008 
1009 /*
1010 ================
1011 COM_AddParm
1012 
1013 Adds the given string at the end of the current argument list
1014 ================
1015 */
1016 void COM_AddParm (char *parm)
1017 {
1018  if (com_argc == MAX_NUM_ARGVS)
1019  Com_Error (ERR_FATAL, "COM_AddParm: MAX_NUM)ARGS");
1020  com_argv[com_argc++] = parm;
1021 }
1022 
1023 
1024 
1025 
1027 int memsearch (byte *start, int count, int search)
1028 {
1029  int i;
1030 
1031  for (i=0 ; i<count ; i++)
1032  if (start[i] == search)
1033  return i;
1034  return -1;
1035 }
1036 
1037 
1038 char *CopyString (char *in)
1039 {
1040  char *out;
1041 
1042  out = Z_Malloc ((int)strlen(in)+1);
1043  strcpy (out, in);
1044  return out;
1045 }
1046 
1047 
1048 
1049 void Info_Print (char *s)
1050 {
1051  char key[512];
1052  char value[512];
1053  char *o;
1054  int l;
1055 
1056  if (*s == '\\')
1057  s++;
1058  while (*s)
1059  {
1060  o = key;
1061  while (*s && *s != '\\')
1062  *o++ = *s++;
1063 
1064  l = o - key;
1065  if (l < 20)
1066  {
1067  memset (o, ' ', 20-l);
1068  key[20] = 0;
1069  }
1070  else
1071  *o = 0;
1072  Com_Printf ("%s", key);
1073 
1074  if (!*s)
1075  {
1076  Com_Printf ("MISSING VALUE\n");
1077  return;
1078  }
1079 
1080  o = value;
1081  s++;
1082  while (*s && *s != '\\')
1083  *o++ = *s++;
1084  *o = 0;
1085 
1086  if (*s)
1087  s++;
1088  Com_Printf ("%s\n", value);
1089  }
1090 }
1091 
1092 
1093 /*
1094 ==============================================================================
1095 
1096  ZONE MEMORY ALLOCATION
1097 
1098 just cleared malloc with counters now...
1099 
1100 ==============================================================================
1101 */
1102 
1103 #define Z_MAGIC 0x1d1d
1104 
1105 
1106 typedef struct zhead_s
1107 {
1108  struct zhead_s *prev, *next;
1109  short magic;
1110  short tag; // for group free
1111  int size;
1112 } zhead_t;
1113 
1116 
1117 /*
1118 ========================
1119 Z_Free
1120 ========================
1121 */
1122 void Z_Free (void *ptr)
1123 {
1124  zhead_t *z;
1125 
1126  z = ((zhead_t *)ptr) - 1;
1127 
1128  if (z->magic != Z_MAGIC)
1129  Com_Error (ERR_FATAL, "Z_Free: bad magic");
1130 
1131  z->prev->next = z->next;
1132  z->next->prev = z->prev;
1133 
1134  z_count--;
1135  z_bytes -= z->size;
1136  free (z);
1137 }
1138 
1139 
1140 /*
1141 ========================
1142 Z_Stats_f
1143 ========================
1144 */
1145 void Z_Stats_f (void)
1146 {
1147  Com_Printf ("%i bytes in %i blocks\n", z_bytes, z_count);
1148 }
1149 
1150 /*
1151 ========================
1152 Z_FreeTags
1153 ========================
1154 */
1155 void Z_FreeTags (int tag)
1156 {
1157  zhead_t *z, *next;
1158 
1159  for (z=z_chain.next ; z != &z_chain ; z=next)
1160  {
1161  next = z->next;
1162  if (z->tag == tag)
1163  Z_Free ((void *)(z+1));
1164  }
1165 }
1166 
1167 /*
1168 ========================
1169 Z_TagMalloc
1170 ========================
1171 */
1172 void *Z_TagMalloc (int size, int tag)
1173 {
1174  zhead_t *z;
1175 
1176  size = size + sizeof(zhead_t);
1177  z = malloc(size);
1178  if (!z)
1179  Com_Error (ERR_FATAL, "Z_Malloc: failed on allocation of %i bytes",size);
1180  memset (z, 0, size);
1181  z_count++;
1182  z_bytes += size;
1183  z->magic = Z_MAGIC;
1184  z->tag = tag;
1185  z->size = size;
1186 
1187  z->next = z_chain.next;
1188  z->prev = &z_chain;
1189  z_chain.next->prev = z;
1190  z_chain.next = z;
1191 
1192  return (void *)(z+1);
1193 }
1194 
1195 /*
1196 ========================
1197 Z_Malloc
1198 ========================
1199 */
1200 void *Z_Malloc (int size)
1201 {
1202  return Z_TagMalloc (size, 0);
1203 }
1204 
1205 
1206 //============================================================================
1207 
1208 
1209 /*
1210 ====================
1211 COM_BlockSequenceCheckByte
1212 
1213 For proxy protecting
1214 
1215 // THIS IS MASSIVELY BROKEN! CHALLENGE MAY BE NEGATIVE
1216 // DON'T USE THIS FUNCTION!!!!!
1217 
1218 ====================
1219 */
1220 byte COM_BlockSequenceCheckByte (byte *base, int length, int sequence, int challenge)
1221 {
1222  Sys_Error("COM_BlockSequenceCheckByte called\n");
1223 
1224 #if 0
1225  int checksum;
1226  byte buf[68];
1227  byte *p;
1228  float temp;
1229  byte c;
1230 
1231  temp = bytedirs[(sequence/3) % NUMVERTEXNORMALS][sequence % 3];
1232  temp = LittleFloat(temp);
1233  p = ((byte *)&temp);
1234 
1235  if (length > 60)
1236  length = 60;
1237  memcpy (buf, base, length);
1238 
1239  buf[length] = (sequence & 0xff) ^ p[0];
1240  buf[length+1] = p[1];
1241  buf[length+2] = ((sequence>>8) & 0xff) ^ p[2];
1242  buf[length+3] = p[3];
1243 
1244  temp = bytedirs[((sequence+challenge)/3) % NUMVERTEXNORMALS][(sequence+challenge) % 3];
1245  temp = LittleFloat(temp);
1246  p = ((byte *)&temp);
1247 
1248  buf[length+4] = (sequence & 0xff) ^ p[3];
1249  buf[length+5] = (challenge & 0xff) ^ p[2];
1250  buf[length+6] = ((sequence>>8) & 0xff) ^ p[1];
1251  buf[length+7] = ((challenge >> 7) & 0xff) ^ p[0];
1252 
1253  length += 8;
1254 
1255  checksum = LittleLong(Com_BlockChecksum (buf, length));
1256 
1257  checksum &= 0xff;
1258 
1259  return checksum;
1260 #endif
1261  return 0;
1262 }
1263 
1264 static byte chktbl[1024] = {
1265 0x84, 0x47, 0x51, 0xc1, 0x93, 0x22, 0x21, 0x24, 0x2f, 0x66, 0x60, 0x4d, 0xb0, 0x7c, 0xda,
1266 0x88, 0x54, 0x15, 0x2b, 0xc6, 0x6c, 0x89, 0xc5, 0x9d, 0x48, 0xee, 0xe6, 0x8a, 0xb5, 0xf4,
1267 0xcb, 0xfb, 0xf1, 0x0c, 0x2e, 0xa0, 0xd7, 0xc9, 0x1f, 0xd6, 0x06, 0x9a, 0x09, 0x41, 0x54,
1268 0x67, 0x46, 0xc7, 0x74, 0xe3, 0xc8, 0xb6, 0x5d, 0xa6, 0x36, 0xc4, 0xab, 0x2c, 0x7e, 0x85,
1269 0xa8, 0xa4, 0xa6, 0x4d, 0x96, 0x19, 0x19, 0x9a, 0xcc, 0xd8, 0xac, 0x39, 0x5e, 0x3c, 0xf2,
1270 0xf5, 0x5a, 0x72, 0xe5, 0xa9, 0xd1, 0xb3, 0x23, 0x82, 0x6f, 0x29, 0xcb, 0xd1, 0xcc, 0x71,
1271 0xfb, 0xea, 0x92, 0xeb, 0x1c, 0xca, 0x4c, 0x70, 0xfe, 0x4d, 0xc9, 0x67, 0x43, 0x47, 0x94,
1272 0xb9, 0x47, 0xbc, 0x3f, 0x01, 0xab, 0x7b, 0xa6, 0xe2, 0x76, 0xef, 0x5a, 0x7a, 0x29, 0x0b,
1273 0x51, 0x54, 0x67, 0xd8, 0x1c, 0x14, 0x3e, 0x29, 0xec, 0xe9, 0x2d, 0x48, 0x67, 0xff, 0xed,
1274 0x54, 0x4f, 0x48, 0xc0, 0xaa, 0x61, 0xf7, 0x78, 0x12, 0x03, 0x7a, 0x9e, 0x8b, 0xcf, 0x83,
1275 0x7b, 0xae, 0xca, 0x7b, 0xd9, 0xe9, 0x53, 0x2a, 0xeb, 0xd2, 0xd8, 0xcd, 0xa3, 0x10, 0x25,
1276 0x78, 0x5a, 0xb5, 0x23, 0x06, 0x93, 0xb7, 0x84, 0xd2, 0xbd, 0x96, 0x75, 0xa5, 0x5e, 0xcf,
1277 0x4e, 0xe9, 0x50, 0xa1, 0xe6, 0x9d, 0xb1, 0xe3, 0x85, 0x66, 0x28, 0x4e, 0x43, 0xdc, 0x6e,
1278 0xbb, 0x33, 0x9e, 0xf3, 0x0d, 0x00, 0xc1, 0xcf, 0x67, 0x34, 0x06, 0x7c, 0x71, 0xe3, 0x63,
1279 0xb7, 0xb7, 0xdf, 0x92, 0xc4, 0xc2, 0x25, 0x5c, 0xff, 0xc3, 0x6e, 0xfc, 0xaa, 0x1e, 0x2a,
1280 0x48, 0x11, 0x1c, 0x36, 0x68, 0x78, 0x86, 0x79, 0x30, 0xc3, 0xd6, 0xde, 0xbc, 0x3a, 0x2a,
1281 0x6d, 0x1e, 0x46, 0xdd, 0xe0, 0x80, 0x1e, 0x44, 0x3b, 0x6f, 0xaf, 0x31, 0xda, 0xa2, 0xbd,
1282 0x77, 0x06, 0x56, 0xc0, 0xb7, 0x92, 0x4b, 0x37, 0xc0, 0xfc, 0xc2, 0xd5, 0xfb, 0xa8, 0xda,
1283 0xf5, 0x57, 0xa8, 0x18, 0xc0, 0xdf, 0xe7, 0xaa, 0x2a, 0xe0, 0x7c, 0x6f, 0x77, 0xb1, 0x26,
1284 0xba, 0xf9, 0x2e, 0x1d, 0x16, 0xcb, 0xb8, 0xa2, 0x44, 0xd5, 0x2f, 0x1a, 0x79, 0x74, 0x87,
1285 0x4b, 0x00, 0xc9, 0x4a, 0x3a, 0x65, 0x8f, 0xe6, 0x5d, 0xe5, 0x0a, 0x77, 0xd8, 0x1a, 0x14,
1286 0x41, 0x75, 0xb1, 0xe2, 0x50, 0x2c, 0x93, 0x38, 0x2b, 0x6d, 0xf3, 0xf6, 0xdb, 0x1f, 0xcd,
1287 0xff, 0x14, 0x70, 0xe7, 0x16, 0xe8, 0x3d, 0xf0, 0xe3, 0xbc, 0x5e, 0xb6, 0x3f, 0xcc, 0x81,
1288 0x24, 0x67, 0xf3, 0x97, 0x3b, 0xfe, 0x3a, 0x96, 0x85, 0xdf, 0xe4, 0x6e, 0x3c, 0x85, 0x05,
1289 0x0e, 0xa3, 0x2b, 0x07, 0xc8, 0xbf, 0xe5, 0x13, 0x82, 0x62, 0x08, 0x61, 0x69, 0x4b, 0x47,
1290 0x62, 0x73, 0x44, 0x64, 0x8e, 0xe2, 0x91, 0xa6, 0x9a, 0xb7, 0xe9, 0x04, 0xb6, 0x54, 0x0c,
1291 0xc5, 0xa9, 0x47, 0xa6, 0xc9, 0x08, 0xfe, 0x4e, 0xa6, 0xcc, 0x8a, 0x5b, 0x90, 0x6f, 0x2b,
1292 0x3f, 0xb6, 0x0a, 0x96, 0xc0, 0x78, 0x58, 0x3c, 0x76, 0x6d, 0x94, 0x1a, 0xe4, 0x4e, 0xb8,
1293 0x38, 0xbb, 0xf5, 0xeb, 0x29, 0xd8, 0xb0, 0xf3, 0x15, 0x1e, 0x99, 0x96, 0x3c, 0x5d, 0x63,
1294 0xd5, 0xb1, 0xad, 0x52, 0xb8, 0x55, 0x70, 0x75, 0x3e, 0x1a, 0xd5, 0xda, 0xf6, 0x7a, 0x48,
1295 0x7d, 0x44, 0x41, 0xf9, 0x11, 0xce, 0xd7, 0xca, 0xa5, 0x3d, 0x7a, 0x79, 0x7e, 0x7d, 0x25,
1296 0x1b, 0x77, 0xbc, 0xf7, 0xc7, 0x0f, 0x84, 0x95, 0x10, 0x92, 0x67, 0x15, 0x11, 0x5a, 0x5e,
1297 0x41, 0x66, 0x0f, 0x38, 0x03, 0xb2, 0xf1, 0x5d, 0xf8, 0xab, 0xc0, 0x02, 0x76, 0x84, 0x28,
1298 0xf4, 0x9d, 0x56, 0x46, 0x60, 0x20, 0xdb, 0x68, 0xa7, 0xbb, 0xee, 0xac, 0x15, 0x01, 0x2f,
1299 0x20, 0x09, 0xdb, 0xc0, 0x16, 0xa1, 0x89, 0xf9, 0x94, 0x59, 0x00, 0xc1, 0x76, 0xbf, 0xc1,
1300 0x4d, 0x5d, 0x2d, 0xa9, 0x85, 0x2c, 0xd6, 0xd3, 0x14, 0xcc, 0x02, 0xc3, 0xc2, 0xfa, 0x6b,
1301 0xb7, 0xa6, 0xef, 0xdd, 0x12, 0x26, 0xa4, 0x63, 0xe3, 0x62, 0xbd, 0x56, 0x8a, 0x52, 0x2b,
1302 0xb9, 0xdf, 0x09, 0xbc, 0x0e, 0x97, 0xa9, 0xb0, 0x82, 0x46, 0x08, 0xd5, 0x1a, 0x8e, 0x1b,
1303 0xa7, 0x90, 0x98, 0xb9, 0xbb, 0x3c, 0x17, 0x9a, 0xf2, 0x82, 0xba, 0x64, 0x0a, 0x7f, 0xca,
1304 0x5a, 0x8c, 0x7c, 0xd3, 0x79, 0x09, 0x5b, 0x26, 0xbb, 0xbd, 0x25, 0xdf, 0x3d, 0x6f, 0x9a,
1305 0x8f, 0xee, 0x21, 0x66, 0xb0, 0x8d, 0x84, 0x4c, 0x91, 0x45, 0xd4, 0x77, 0x4f, 0xb3, 0x8c,
1306 0xbc, 0xa8, 0x99, 0xaa, 0x19, 0x53, 0x7c, 0x02, 0x87, 0xbb, 0x0b, 0x7c, 0x1a, 0x2d, 0xdf,
1307 0x48, 0x44, 0x06, 0xd6, 0x7d, 0x0c, 0x2d, 0x35, 0x76, 0xae, 0xc4, 0x5f, 0x71, 0x85, 0x97,
1308 0xc4, 0x3d, 0xef, 0x52, 0xbe, 0x00, 0xe4, 0xcd, 0x49, 0xd1, 0xd1, 0x1c, 0x3c, 0xd0, 0x1c,
1309 0x42, 0xaf, 0xd4, 0xbd, 0x58, 0x34, 0x07, 0x32, 0xee, 0xb9, 0xb5, 0xea, 0xff, 0xd7, 0x8c,
1310 0x0d, 0x2e, 0x2f, 0xaf, 0x87, 0xbb, 0xe6, 0x52, 0x71, 0x22, 0xf5, 0x25, 0x17, 0xa1, 0x82,
1311 0x04, 0xc2, 0x4a, 0xbd, 0x57, 0xc6, 0xab, 0xc8, 0x35, 0x0c, 0x3c, 0xd9, 0xc2, 0x43, 0xdb,
1312 0x27, 0x92, 0xcf, 0xb8, 0x25, 0x60, 0xfa, 0x21, 0x3b, 0x04, 0x52, 0xc8, 0x96, 0xba, 0x74,
1313 0xe3, 0x67, 0x3e, 0x8e, 0x8d, 0x61, 0x90, 0x92, 0x59, 0xb6, 0x1a, 0x1c, 0x5e, 0x21, 0xc1,
1314 0x65, 0xe5, 0xa6, 0x34, 0x05, 0x6f, 0xc5, 0x60, 0xb1, 0x83, 0xc1, 0xd5, 0xd5, 0xed, 0xd9,
1315 0xc7, 0x11, 0x7b, 0x49, 0x7a, 0xf9, 0xf9, 0x84, 0x47, 0x9b, 0xe2, 0xa5, 0x82, 0xe0, 0xc2,
1316 0x88, 0xd0, 0xb2, 0x58, 0x88, 0x7f, 0x45, 0x09, 0x67, 0x74, 0x61, 0xbf, 0xe6, 0x40, 0xe2,
1317 0x9d, 0xc2, 0x47, 0x05, 0x89, 0xed, 0xcb, 0xbb, 0xb7, 0x27, 0xe7, 0xdc, 0x7a, 0xfd, 0xbf,
1318 0xa8, 0xd0, 0xaa, 0x10, 0x39, 0x3c, 0x20, 0xf0, 0xd3, 0x6e, 0xb1, 0x72, 0xf8, 0xe6, 0x0f,
1319 0xef, 0x37, 0xe5, 0x09, 0x33, 0x5a, 0x83, 0x43, 0x80, 0x4f, 0x65, 0x2f, 0x7c, 0x8c, 0x6a,
1320 0xa0, 0x82, 0x0c, 0xd4, 0xd4, 0xfa, 0x81, 0x60, 0x3d, 0xdf, 0x06, 0xf1, 0x5f, 0x08, 0x0d,
1321 0x6d, 0x43, 0xf2, 0xe3, 0x11, 0x7d, 0x80, 0x32, 0xc5, 0xfb, 0xc5, 0xd9, 0x27, 0xec, 0xc6,
1322 0x4e, 0x65, 0x27, 0x76, 0x87, 0xa6, 0xee, 0xee, 0xd7, 0x8b, 0xd1, 0xa0, 0x5c, 0xb0, 0x42,
1323 0x13, 0x0e, 0x95, 0x4a, 0xf2, 0x06, 0xc6, 0x43, 0x33, 0xf4, 0xc7, 0xf8, 0xe7, 0x1f, 0xdd,
1324 0xe4, 0x46, 0x4a, 0x70, 0x39, 0x6c, 0xd0, 0xed, 0xca, 0xbe, 0x60, 0x3b, 0xd1, 0x7b, 0x57,
1325 0x48, 0xe5, 0x3a, 0x79, 0xc1, 0x69, 0x33, 0x53, 0x1b, 0x80, 0xb8, 0x91, 0x7d, 0xb4, 0xf6,
1326 0x17, 0x1a, 0x1d, 0x5a, 0x32, 0xd6, 0xcc, 0x71, 0x29, 0x3f, 0x28, 0xbb, 0xf3, 0x5e, 0x71,
1327 0xb8, 0x43, 0xaf, 0xf8, 0xb9, 0x64, 0xef, 0xc4, 0xa5, 0x6c, 0x08, 0x53, 0xc7, 0x00, 0x10,
1328 0x39, 0x4f, 0xdd, 0xe4, 0xb6, 0x19, 0x27, 0xfb, 0xb8, 0xf5, 0x32, 0x73, 0xe5, 0xcb, 0x32
1329 };
1330 
1331 /*
1332 ====================
1333 COM_BlockSequenceCRCByte
1334 
1335 For proxy protecting
1336 ====================
1337 */
1338 byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence)
1339 {
1340  int n;
1341  byte *p;
1342  int x;
1343  byte chkb[60 + 4];
1344  unsigned short crc;
1345 
1346 
1347  if (sequence < 0)
1348  Sys_Error("sequence < 0, this shouldn't happen\n");
1349 
1350  p = chktbl + (sequence % (sizeof(chktbl) - 4));
1351 
1352  if (length > 60)
1353  length = 60;
1354  memcpy (chkb, base, length);
1355 
1356  chkb[length] = p[0];
1357  chkb[length+1] = p[1];
1358  chkb[length+2] = p[2];
1359  chkb[length+3] = p[3];
1360 
1361  length += 4;
1362 
1363  crc = CRC_Block(chkb, length);
1364 
1365  for (x=0, n=0; n<length; n++)
1366  x += chkb[n];
1367 
1368  crc = (crc ^ x) & 0xff;
1369 
1370  return crc;
1371 }
1372 
1373 //========================================================
1374 
1375 float frand(void)
1376 {
1377  return (rand()&32767)* (1.0/32767);
1378 }
1379 
1380 float crand(void)
1381 {
1382  return (rand()&32767)* (2.0/32767) - 1;
1383 }
1384 
1385 void Key_Init (void);
1386 void SCR_EndLoadingPlaque (void);
1387 
1388 /*
1389 =============
1390 Com_Error_f
1391 
1392 Just throw a fatal error to
1393 test error shutdown procedures
1394 =============
1395 */
1396 void Com_Error_f (void)
1397 {
1398  Com_Error (ERR_FATAL, "%s", Cmd_Argv(1));
1399 }
1400 
1401 
1402 /*
1403 =================
1404 Qcommon_Init
1405 =================
1406 */
1407 void Qcommon_Init (int argc, char **argv)
1408 {
1409  char *s;
1410 
1411  if (setjmp (abortframe) )
1412  Sys_Error ("Error during initialization");
1413 
1415 
1416  // prepare enough of the subsystems to handle
1417  // cvar and command buffer management
1418  COM_InitArgv (argc, argv);
1419 
1420  Swap_Init ();
1421  Cbuf_Init ();
1422 
1423  Cmd_Init ();
1424  Cvar_Init ();
1425 
1426  Key_Init ();
1427 
1428  // we need to add the early commands twice, because
1429  // a basedir or cddir needs to be set before execing
1430  // config files, but we want other parms to override
1431  // the settings of the config files
1432  Cbuf_AddEarlyCommands (false);
1433  Cbuf_Execute ();
1434 
1435  FS_InitFilesystem ();
1436 
1437  Cbuf_AddText ("exec default.cfg\n");
1438  Cbuf_AddText ("exec config.cfg\n");
1439 
1440  Cbuf_AddEarlyCommands (true);
1441  Cbuf_Execute ();
1442 
1443  //
1444  // init commands and vars
1445  //
1446  Cmd_AddCommand ("z_stats", Z_Stats_f);
1447  Cmd_AddCommand ("error", Com_Error_f);
1448 
1449  host_speeds = Cvar_Get ("host_speeds", "0", 0);
1450  log_stats = Cvar_Get ("log_stats", "0", 0);
1451  developer = Cvar_Get ("developer", "0", 0);
1452  timescale = Cvar_Get ("timescale", "1", 0);
1453  fixedtime = Cvar_Get ("fixedtime", "0", 0);
1454  logfile_active = Cvar_Get ("logfile", "0", 0);
1455  showtrace = Cvar_Get ("showtrace", "0", 0);
1456 #ifdef DEDICATED_ONLY
1457  dedicated = Cvar_Get ("dedicated", "1", CVAR_NOSET);
1458 #else
1459  dedicated = Cvar_Get ("dedicated", "0", CVAR_NOSET);
1460 #endif
1461 
1462  s = va("%4.2f %s %s %s", VERSION, CPUSTRING, __DATE__, BUILDSTRING);
1463  Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_NOSET);
1464 
1465 
1466  if (dedicated->value)
1467  Cmd_AddCommand ("quit", Com_Quit);
1468 
1469  Sys_Init ();
1470 
1471  NET_Init ();
1472  Netchan_Init ();
1473 
1474  SV_Init ();
1475  CL_Init ();
1476 
1477  // add + commands from command line
1478  if (!Cbuf_AddLateCommands ())
1479  { // if the user didn't give any commands, run default action
1480  if (!dedicated->value)
1481  Cbuf_AddText ("d1\n");
1482  else
1483  Cbuf_AddText ("dedicated_start\n");
1484  Cbuf_Execute ();
1485  }
1486  else
1487  { // the user asked for something explicit
1488  // so drop the loading plaque
1490  }
1491 
1492  Com_Printf ("====== Quake2 Initialized ======\n\n");
1493 }
1494 
1495 /*
1496 =================
1497 Qcommon_Frame
1498 =================
1499 */
1500 void Qcommon_Frame (int msec)
1501 {
1502  char *s;
1503  int time_before, time_between, time_after;
1504 
1505  if (setjmp (abortframe) )
1506  {
1507  if (shutdown_game)
1509  shutdown_game = false;
1510  return; // an ERR_DROP was thrown
1511  }
1512 
1513  if ( log_stats->modified )
1514  {
1515  log_stats->modified = false;
1516  if ( log_stats->value )
1517  {
1518  if ( log_stats_file )
1519  {
1520  fclose( log_stats_file );
1521  log_stats_file = 0;
1522  }
1523  log_stats_file = fopen( "stats.log", "w" );
1524  if ( log_stats_file )
1525  fprintf( log_stats_file, "entities,dlights,parts,frame time\n" );
1526  }
1527  else
1528  {
1529  if ( log_stats_file )
1530  {
1531  fclose( log_stats_file );
1532  log_stats_file = 0;
1533  }
1534  }
1535  }
1536 
1537  if (fixedtime->value)
1538  msec = fixedtime->value;
1539  else if (timescale->value)
1540  {
1541  msec *= timescale->value;
1542  if (msec < 1)
1543  msec = 1;
1544  }
1545 
1546  if (showtrace->value)
1547  {
1548  extern int c_traces, c_brush_traces;
1549  extern int c_pointcontents;
1550 
1551  Com_Printf ("%4i traces %4i points\n", c_traces, c_pointcontents);
1552  c_traces = 0;
1553  c_brush_traces = 0;
1554  c_pointcontents = 0;
1555  }
1556 
1557  do
1558  {
1559  s = Sys_ConsoleInput ();
1560  if (s)
1561  Cbuf_AddText (va("%s\n",s));
1562  } while (s);
1563  Cbuf_Execute ();
1564 
1565  if (host_speeds->value)
1566  time_before = Sys_Milliseconds ();
1567 
1568  SV_Frame (msec);
1569 
1570  if (host_speeds->value)
1571  time_between = Sys_Milliseconds ();
1572 
1573  CL_Frame (msec);
1574 
1575  if (host_speeds->value)
1576  time_after = Sys_Milliseconds ();
1577 
1578 
1579  if (host_speeds->value)
1580  {
1581  int all, sv, gm, cl, rf;
1582 
1583  all = time_after - time_before;
1584  sv = time_between - time_before;
1585  cl = time_after - time_between;
1588  sv -= gm;
1589  cl -= rf;
1590  Com_Printf ("all:%3i sv:%3i gm:%3i cl:%3i rf:%3i\n",
1591  all, sv, gm, cl, rf);
1592  }
1593 }
1594 
1595 /*
1596 =================
1597 Qcommon_Shutdown
1598 =================
1599 */
1600 void Qcommon_Shutdown (void)
1601 {
1602 }
shutdown_game
static qboolean shutdown_game
Definition: common.c:36
entity_state_s::old_origin
vec3_t old_origin
Definition: q_shared.h:1151
CL_Drop
void CL_Drop(void)
Definition: cl_main.c:399
sv
server_t sv
Definition: sv_init.c:24
usercmd_s::lightlevel
byte lightlevel
Definition: q_shared.h:524
SCR_EndLoadingPlaque
void SCR_EndLoadingPlaque(void)
Definition: cl_scrn.c:590
Z_MAGIC
#define Z_MAGIC
Definition: common.c:1103
usercmd_s::impulse
byte impulse
Definition: q_shared.h:523
dedicated
cvar_t * dedicated
Definition: common.c:47
sizebuf_s
Definition: qcommon.h:92
value
GLfloat value
Definition: qgl_win.c:63
MAX_QPATH
#define MAX_QPATH
Definition: q_shared.h:80
entity_state_s::modelindex4
int modelindex4
Definition: q_shared.h:1153
entity_state_s::solid
int solid
Definition: q_shared.h:1158
Z_TagMalloc
void * Z_TagMalloc(int size, int tag)
Definition: common.c:1172
U_ANGLE2
#define U_ANGLE2
Definition: qcommon.h:317
U_MOREBITS3
#define U_MOREBITS3
Definition: qcommon.h:341
z_chain
zhead_t z_chain
Definition: common.c:1114
MSG_WriteDeltaUsercmd
void MSG_WriteDeltaUsercmd(sizebuf_t *buf, usercmd_t *from, usercmd_t *cmd)
Definition: common.c:387
int
CONST PIXELFORMATDESCRIPTOR int
Definition: qgl_win.c:35
U_ANGLE1
#define U_ANGLE1
Definition: qcommon.h:327
Swap_Init
void Swap_Init(void)
Definition: q_shared.c:1011
entity_state_s::frame
int frame
Definition: q_shared.h:1154
log_stats
cvar_t * log_stats
Definition: common.c:41
CVAR_NOSET
#define CVAR_NOSET
Definition: q_shared.h:319
Com_SetServerState
void Com_SetServerState(int state)
Definition: common.c:266
CM_SIDE
#define CM_SIDE
Definition: qcommon.h:293
chktbl
static byte chktbl[1024]
Definition: common.c:1264
showtrace
cvar_t * showtrace
Definition: common.c:46
entity_state_s::renderfx
int renderfx
Definition: q_shared.h:1157
MSG_ReadShort
int MSG_ReadShort(sizebuf_t *msg_read)
Definition: common.c:716
frand
float frand(void)
Definition: common.c:1375
entity_state_s
Definition: q_shared.h:1145
cvar_s::modified
qboolean modified
Definition: q_shared.h:330
U_ORIGIN1
#define U_ORIGIN1
Definition: qcommon.h:315
entity_state_s::origin
vec3_t origin
Definition: q_shared.h:1149
Cbuf_Init
void Cbuf_Init(void)
Definition: cmd.c:78
sizebuf_s::overflowed
qboolean overflowed
Definition: qcommon.h:95
U_RENDERFX8
#define U_RENDERFX8
Definition: qcommon.h:329
Sys_Error
void Sys_Error(char *error,...)
Definition: sys_win.c:68
sizebuf_s::readcount
int readcount
Definition: qcommon.h:99
U_OLDORIGIN
#define U_OLDORIGIN
Definition: qcommon.h:344
qboolean
qboolean
Definition: q_shared.h:63
x
GLint GLenum GLint x
Definition: qgl_win.c:116
z
GLdouble GLdouble z
Definition: qgl_win.c:283
COM_Argv
char * COM_Argv(int arg)
Definition: common.c:973
z_count
int z_count
Definition: common.c:1115
i
int i
Definition: q_shared.c:305
MSG_WriteCoord
void MSG_WriteCoord(sizebuf_t *sb, float f)
Definition: common.c:364
host_speeds
cvar_t * host_speeds
Definition: common.c:40
MAX_NUM_ARGVS
#define MAX_NUM_ARGVS
Definition: common.c:27
U_MODEL
#define U_MODEL
Definition: qcommon.h:328
COM_InitArgv
void COM_InitArgv(int argc, char **argv)
Definition: common.c:993
buffer
GLenum GLfloat * buffer
Definition: qgl_win.c:151
entity_state_s::event
int event
Definition: q_shared.h:1162
MSG_WriteLong
void MSG_WriteLong(sizebuf_t *sb, int c)
Definition: common.c:330
MAX_TOKEN_CHARS
#define MAX_TOKEN_CHARS
Definition: q_shared.h:78
VERSION
#define VERSION
Definition: qcommon.h:26
argv
char * argv[MAX_NUM_ARGVS]
Definition: sys_win.c:56
time_before_game
int time_before_game
Definition: common.c:54
CopyString
char * CopyString(char *in)
Definition: common.c:1038
SZ_Init
void SZ_Init(sizebuf_t *buf, byte *data, int length)
Definition: common.c:885
zhead_s::prev
struct zhead_s * prev
Definition: common.c:1108
argc
int argc
Definition: sys_win.c:55
Sys_Init
void Sys_Init(void)
Definition: sys_win.c:238
usercmd_s::forwardmove
short forwardmove
Definition: q_shared.h:522
sizebuf_s::data
byte * data
Definition: qcommon.h:96
Cvar_Get
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
Definition: cvar.c:127
U_MODEL2
#define U_MODEL2
Definition: qcommon.h:338
entity_state_s::modelindex3
int modelindex3
Definition: q_shared.h:1153
SZ_Write
void SZ_Write(sizebuf_t *buf, void *data, int length)
Definition: common.c:921
cvar_s
Definition: q_shared.h:324
SZ_Clear
void SZ_Clear(sizebuf_t *buf)
Definition: common.c:892
entity_state_s::effects
unsigned int effects
Definition: q_shared.h:1156
CVAR_SERVERINFO
#define CVAR_SERVERINFO
Definition: q_shared.h:318
Com_Error_f
void Com_Error_f(void)
Definition: common.c:1396
CL_Init
void CL_Init(void)
Definition: cl_main.c:1785
Netchan_Init
void Netchan_Init(void)
Definition: net_chan.c:91
entity_state_s::sound
int sound
Definition: q_shared.h:1161
Sys_ConsoleInput
char * Sys_ConsoleInput(void)
Definition: sys_win.c:289
Cmd_Argv
char * Cmd_Argv(int arg)
Definition: cmd.c:517
U_ANGLE3
#define U_ANGLE3
Definition: qcommon.h:318
va
char * va(char *format,...)
Definition: q_shared.c:1050
msg
cvar_t * msg
Definition: cl_main.c:83
sizebuf_s::maxsize
int maxsize
Definition: qcommon.h:97
U_SOUND
#define U_SOUND
Definition: qcommon.h:346
Qcommon_Frame
void Qcommon_Frame(int msec)
Definition: common.c:1500
RF_BEAM
#define RF_BEAM
Definition: q_shared.h:606
SZ_Print
void SZ_Print(sizebuf_t *buf, char *data)
Definition: common.c:926
Key_Init
void Key_Init(void)
Definition: keys.c:647
CM_ANGLE1
#define CM_ANGLE1
Definition: qcommon.h:289
bytedirs
vec3_t bytedirs[NUMVERTEXNORMALS]
Definition: common.c:281
Com_BeginRedirect
void Com_BeginRedirect(int target, char *buffer, int buffersize, void(*flush))
Definition: common.c:74
Info_Print
void Info_Print(char *s)
Definition: common.c:1049
usercmd_s::sidemove
short sidemove
Definition: q_shared.h:522
LittleFloat
float LittleFloat(float l)
Definition: q_shared.c:950
realtime
int realtime
Definition: common.c:33
U_EVENT
#define U_EVENT
Definition: qcommon.h:320
z_bytes
int z_bytes
Definition: common.c:1115
LittleLong
int LittleLong(int l)
Definition: q_shared.c:948
COM_ClearArgv
void COM_ClearArgv(int arg)
Definition: common.c:980
memsearch
int memsearch(byte *start, int count, int search)
just for debugging
Definition: common.c:1027
U_EFFECTS16
#define U_EFFECTS16
Definition: qcommon.h:337
CRC_Block
unsigned short CRC_Block(byte *start, int count)
Definition: crc.c:82
Qcommon_Shutdown
void Qcommon_Shutdown(void)
Definition: common.c:1600
COM_BlockSequenceCRCByte
byte COM_BlockSequenceCRCByte(byte *base, int length, int sequence)
Definition: common.c:1338
U_ORIGIN2
#define U_ORIGIN2
Definition: qcommon.h:316
com_argc
int com_argc
Definition: common.c:30
MSG_ReadDir
void MSG_ReadDir(sizebuf_t *sb, vec3_t dir)
Definition: common.c:464
CL_Shutdown
void CL_Shutdown(void)
Definition: cl_main.c:1831
U_EFFECTS8
#define U_EFFECTS8
Definition: qcommon.h:330
MSG_WriteDir
void MSG_WriteDir(sizebuf_t *sb, vec3_t dir)
Definition: common.c:438
U_MOREBITS1
#define U_MOREBITS1
Definition: qcommon.h:322
Sys_ConsoleOutput
void Sys_ConsoleOutput(char *string)
Definition: sys_win.c:369
U_MODEL4
#define U_MODEL4
Definition: qcommon.h:340
zhead_s::next
struct zhead_s * next
Definition: common.c:1108
Cmd_AddCommand
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
Definition: cmd.c:691
Com_EndRedirect
void Com_EndRedirect(void)
Definition: common.c:86
zhead_s::magic
short magic
Definition: common.c:1109
DotProduct
#define DotProduct(x, y)
Definition: q_shared.h:162
COM_CheckParm
int COM_CheckParm(char *parm)
Definition: common.c:955
Sys_Quit
void Sys_Quit(void)
Definition: sys_win.c:91
U_FRAME16
#define U_FRAME16
Definition: qcommon.h:335
Cbuf_AddText
void Cbuf_AddText(char *text)
Definition: cmd.c:90
cvar_s::value
float value
Definition: q_shared.h:331
MSG_ReadByte
int MSG_ReadByte(sizebuf_t *msg_read)
Definition: common.c:703
time_before_ref
int time_before_ref
Definition: common.c:56
Con_Print
void Con_Print(char *text)
Definition: console.c:352
U_SKIN8
#define U_SKIN8
Definition: qcommon.h:334
MSG_WritePos
void MSG_WritePos(sizebuf_t *sb, vec3_t pos)
Definition: common.c:369
U_RENDERFX16
#define U_RENDERFX16
Definition: qcommon.h:336
CM_FORWARD
#define CM_FORWARD
Definition: qcommon.h:292
timescale
cvar_t * timescale
Definition: common.c:43
U_MOREBITS2
#define U_MOREBITS2
Definition: qcommon.h:331
MSG_WriteString
void MSG_WriteString(sizebuf_t *sb, char *s)
Definition: common.c:356
entity_state_s::number
int number
Definition: q_shared.h:1147
NULL
#define NULL
Definition: q_shared.h:67
FS_InitFilesystem
void FS_InitFilesystem(void)
Definition: files.c:848
zhead_t
struct zhead_s zhead_t
MSG_WriteShort
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition: common.c:316
COM_Argc
int COM_Argc(void)
Definition: common.c:968
MSG_WriteByte
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition: common.c:303
MSG_ReadStringLine
char * MSG_ReadStringLine(sizebuf_t *msg_read)
Definition: common.c:793
CM_BUTTONS
#define CM_BUTTONS
Definition: qcommon.h:295
Com_Error
void Com_Error(int code, char *fmt,...)
Definition: common.c:181
SV_Init
void SV_Init(void)
Definition: sv_main.c:948
rd_target
static int rd_target
Definition: common.c:67
Z_Malloc
void * Z_Malloc(int size)
Definition: common.c:1200
SZ_GetSpace
void * SZ_GetSpace(sizebuf_t *buf, int length)
Definition: common.c:898
ERR_DROP
#define ERR_DROP
Definition: qcommon.h:744
MSG_ReadCoord
float MSG_ReadCoord(sizebuf_t *msg_read)
Definition: common.c:813
usercmd_s::upmove
short upmove
Definition: q_shared.h:522
MSG_WriteChar
void MSG_WriteChar(sizebuf_t *sb, int c)
Definition: common.c:290
c_brush_traces
int c_brush_traces
Definition: cmodel.c:119
name
cvar_t * name
Definition: cl_main.c:79
MAX_EDICTS
#define MAX_EDICTS
Definition: q_shared.h:87
rd_buffersize
static int rd_buffersize
Definition: common.c:69
ERR_FATAL
#define ERR_FATAL
Definition: qcommon.h:743
Cmd_Init
void Cmd_Init(void)
Definition: cmd.c:881
Z_Stats_f
void Z_Stats_f(void)
Definition: common.c:1145
s
static fixed16_t s
Definition: r_scan.c:30
COM_BlockSequenceCheckByte
byte COM_BlockSequenceCheckByte(byte *base, int length, int sequence, int challenge)
Definition: common.c:1220
SV_Shutdown
void SV_Shutdown(char *finalmsg, qboolean reconnect)
Definition: sv_main.c:1035
NET_Init
void NET_Init(void)
Definition: net_wins.c:767
entity_state_s::skinnum
int skinnum
Definition: q_shared.h:1155
logfile
FILE * logfile
Definition: common.c:49
MSG_ReadFloat
float MSG_ReadFloat(sizebuf_t *msg_read)
Definition: common.c:748
U_SKIN16
#define U_SKIN16
Definition: qcommon.h:345
CM_ANGLE2
#define CM_ANGLE2
Definition: qcommon.h:290
VectorCopy
#define VectorCopy(a, b)
Definition: q_shared.h:165
logfile_active
cvar_t * logfile_active
Definition: common.c:45
Com_BlockChecksum
unsigned Com_BlockChecksum(void *buffer, int length)
Definition: md4.c:213
Cvar_Init
void Cvar_Init(void)
Definition: cvar.c:522
abortframe
jmp_buf abortframe
Definition: common.c:35
qcommon.h
MSG_ReadLong
int MSG_ReadLong(sizebuf_t *msg_read)
Definition: common.c:731
Z_Free
void Z_Free(void *ptr)
Definition: common.c:1122
usercmd_s
Definition: q_shared.h:517
zhead_s::size
int size
Definition: common.c:1111
MSG_WriteAngle
void MSG_WriteAngle(sizebuf_t *sb, float f)
Definition: common.c:376
CM_UP
#define CM_UP
Definition: qcommon.h:294
BUILDSTRING
#define BUILDSTRING
Definition: qcommon.h:85
SV_Frame
void SV_Frame(int msec)
Definition: sv_main.c:760
MSG_ReadString
char * MSG_ReadString(sizebuf_t *msg_read)
Definition: common.c:773
FS_Gamedir
char * FS_Gamedir(void)
Definition: files.c:559
SHORT2ANGLE
#define SHORT2ANGLE(x)
Definition: q_shared.h:1093
time_after_game
int time_after_game
Definition: common.c:55
rd_buffer
static char * rd_buffer
Definition: common.c:68
usercmd_s::angles
short angles[3]
Definition: q_shared.h:521
MSG_ReadDeltaUsercmd
void MSG_ReadDeltaUsercmd(sizebuf_t *msg_read, usercmd_t *from, usercmd_t *move)
Definition: common.c:835
MSG_ReadData
void MSG_ReadData(sizebuf_t *msg_read, void *data, int len)
Definition: common.c:874
MSG_ReadAngle16
float MSG_ReadAngle16(sizebuf_t *msg_read)
Definition: common.c:830
Com_ServerState
int Com_ServerState(void)
Definition: common.c:256
Cbuf_Execute
void Cbuf_Execute(void)
Definition: cmd.c:194
log_stats_file
FILE * log_stats_file
Definition: common.c:38
sizebuf_s::allowoverflow
qboolean allowoverflow
Definition: qcommon.h:94
Com_Quit
void Com_Quit(void)
Definition: common.c:235
entity_state_s::modelindex
int modelindex
Definition: q_shared.h:1152
entity_state_s::modelindex2
int modelindex2
Definition: q_shared.h:1153
time_after_ref
int time_after_ref
Definition: common.c:57
zhead_s::tag
short tag
Definition: common.c:1110
sizebuf_s::cursize
int cursize
Definition: qcommon.h:98
CM_ANGLE3
#define CM_ANGLE3
Definition: qcommon.h:291
Com_DPrintf
void Com_DPrintf(char *fmt,...)
Definition: common.c:157
U_FRAME8
#define U_FRAME8
Definition: qcommon.h:319
usercmd_s::msec
byte msec
Definition: q_shared.h:519
Qcommon_Init
void Qcommon_Init(int argc, char **argv)
Definition: common.c:1407
Cbuf_AddLateCommands
qboolean Cbuf_AddLateCommands(void)
Definition: cmd.c:296
usercmd_s::buttons
byte buttons
Definition: q_shared.h:520
MSG_ReadPos
void MSG_ReadPos(sizebuf_t *msg_read, vec3_t pos)
Definition: common.c:818
COM_AddParm
void COM_AddParm(char *parm)
Definition: common.c:1016
rd_flush
static void(* rd_flush)(int target, char *buffer)
Definition: common.c:70
U_NUMBER16
#define U_NUMBER16
Definition: qcommon.h:325
c_pointcontents
int c_pointcontents
Definition: cmodel.c:118
Cbuf_AddEarlyCommands
void Cbuf_AddEarlyCommands(qboolean clear)
Definition: cmd.c:263
Com_Printf
void Com_Printf(char *fmt,...)
Definition: common.c:104
MSG_WriteFloat
void MSG_WriteFloat(sizebuf_t *sb, float f)
Definition: common.c:341
ANGLE2SHORT
#define ANGLE2SHORT(x)
Definition: q_shared.h:1092
developer
cvar_t * developer
Definition: common.c:42
Sys_Milliseconds
int Sys_Milliseconds(void)
Definition: q_shwin.c:120
SV_ShutdownGameProgs
void SV_ShutdownGameProgs(void)
Definition: sv_game.c:305
MSG_WriteAngle16
void MSG_WriteAngle16(sizebuf_t *sb, float f)
Definition: common.c:381
MSG_ReadAngle
float MSG_ReadAngle(sizebuf_t *msg_read)
Definition: common.c:825
fixedtime
cvar_t * fixedtime
Definition: common.c:44
NUMVERTEXNORMALS
#define NUMVERTEXNORMALS
Definition: qcommon.h:792
server_state
int server_state
Definition: common.c:51
MAXPRINTMSG
#define MAXPRINTMSG
Definition: common.c:25
crand
float crand(void)
Definition: common.c:1380
MSG_WriteDeltaEntity
void MSG_WriteDeltaEntity(entity_state_t *from, entity_state_t *to, sizebuf_t *msg, qboolean force, qboolean newentity)
Definition: common.c:483
entity_state_s::angles
vec3_t angles
Definition: q_shared.h:1150
cl
client_state_t cl
Definition: cl_main.c:91
MSG_ReadChar
int MSG_ReadChar(sizebuf_t *msg_read)
Definition: common.c:690
U_ORIGIN3
#define U_ORIGIN3
Definition: qcommon.h:326
CPUSTRING
#define CPUSTRING
Definition: qcommon.h:86
CM_IMPULSE
#define CM_IMPULSE
Definition: qcommon.h:296
MSG_BeginReading
void MSG_BeginReading(sizebuf_t *msg)
Definition: common.c:684
U_SOLID
#define U_SOLID
Definition: qcommon.h:347
ERR_DISCONNECT
#define ERR_DISCONNECT
Definition: q_shared.h:106
U_MODEL3
#define U_MODEL3
Definition: qcommon.h:339
vec3_t
vec_t vec3_t[3]
Definition: q_shared.h:134
Com_sprintf
void Com_sprintf(char *dest, int size, char *fmt,...)
Definition: q_shared.c:1223
zhead_s
Definition: common.c:1106
CL_Frame
void CL_Frame(int msec)
Definition: cl_main.c:1681
c_traces
int c_traces
Definition: cmodel.c:119
void
void(APIENTRY *qglAccum)(GLenum op
com_argv
char * com_argv[MAX_NUM_ARGVS+1]
Definition: common.c:31
count
GLint GLsizei count
Definition: qgl_win.c:128
Z_FreeTags
void Z_FreeTags(int tag)
Definition: common.c:1155