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