]> icculus.org git repositories - divverent/darkplaces.git/blob - sys_shared.c
split out RecursiveHullCheck and related code into collision.c (shared by client...
[divverent/darkplaces.git] / sys_shared.c
1
2 #include "quakedef.h"
3 #include <time.h>
4 #ifndef WIN32
5 #include <unistd.h>
6 #include <fcntl.h>
7 #endif
8
9 extern cvar_t   timestamps;
10 extern cvar_t   timeformat;
11
12 static int sys_nostdout = false;
13
14 /* The translation table between the graphical font and plain ASCII  --KB */
15 static char qfont_table[256] = {
16         '\0', '#',  '#',  '#',  '#',  '.',  '#',  '#',
17         '#',  9,    10,   '#',  ' ',  13,   '.',  '.',
18         '[',  ']',  '0',  '1',  '2',  '3',  '4',  '5',
19         '6',  '7',  '8',  '9',  '.',  '<',  '=',  '>',
20         ' ',  '!',  '"',  '#',  '$',  '%',  '&',  '\'',
21         '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
22         '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
23         '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
24         '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
25         'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
26         'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
27         'X',  'Y',  'Z',  '[',  '\\', ']',  '^',  '_',
28         '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
29         'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o',
30         'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
31         'x',  'y',  'z',  '{',  '|',  '}',  '~',  '<',
32
33         '<',  '=',  '>',  '#',  '#',  '.',  '#',  '#',
34         '#',  '#',  ' ',  '#',  ' ',  '>',  '.',  '.',
35         '[',  ']',  '0',  '1',  '2',  '3',  '4',  '5',
36         '6',  '7',  '8',  '9',  '.',  '<',  '=',  '>',
37         ' ',  '!',  '"',  '#',  '$',  '%',  '&',  '\'',
38         '(',  ')',  '*',  '+',  ',',  '-',  '.',  '/',
39         '0',  '1',  '2',  '3',  '4',  '5',  '6',  '7',
40         '8',  '9',  ':',  ';',  '<',  '=',  '>',  '?',
41         '@',  'A',  'B',  'C',  'D',  'E',  'F',  'G',
42         'H',  'I',  'J',  'K',  'L',  'M',  'N',  'O',
43         'P',  'Q',  'R',  'S',  'T',  'U',  'V',  'W',
44         'X',  'Y',  'Z',  '[',  '\\', ']',  '^',  '_',
45         '`',  'a',  'b',  'c',  'd',  'e',  'f',  'g',
46         'h',  'i',  'j',  'k',  'l',  'm',  'n',  'o', 
47         'p',  'q',  'r',  's',  't',  'u',  'v',  'w',
48         'x',  'y',  'z',  '{',  '|',  '}',  '~',  '<'
49 };
50
51 #ifdef WIN32
52 extern HANDLE hinput, houtput;
53 #endif
54
55 #define MAX_PRINT_MSG   16384
56 void Sys_Printf (char *fmt, ...)
57 {
58         va_list         argptr;
59         char            start[MAX_PRINT_MSG];   // String we started with
60         char            stamp[MAX_PRINT_MSG];   // Time stamp
61         char            final[MAX_PRINT_MSG];   // String we print
62
63         time_t          mytime = 0;
64         struct tm       *local = NULL;
65
66         unsigned char           *p;
67 #ifdef WIN32
68         DWORD           dummy;
69 #endif
70
71         va_start (argptr, fmt);
72 #ifdef HAVE_VSNPRINTF
73         vsnprintf (start, sizeof(start), fmt, argptr);
74 #else
75         vsprintf (start, fmt, argptr);
76 #endif
77         va_end (argptr);
78
79         if (sys_nostdout)
80                 return;
81
82         if (timestamps.integer)
83         {
84                 mytime = time (NULL);
85                 local = localtime (&mytime);
86                 strftime (stamp, sizeof (stamp), timeformat.string, local);
87
88                 snprintf (final, sizeof (final), "%s%s", stamp, start);
89         }
90         else
91                 snprintf (final, sizeof (final), "%s", start);
92
93         // LordHavoc: make sure the string is terminated
94         final[MAX_PRINT_MSG - 1] = 0;
95         for (p = (unsigned char *) final;*p; p++)
96                 *p = qfont_table[*p];
97 #ifdef WIN32
98         if (cls.state == ca_dedicated)
99                 WriteFile(houtput, final, strlen (final), &dummy, NULL);
100 #else
101         printf("%s", final);
102 #endif
103 //      for (p = (unsigned char *) final; *p; p++)
104 //              putc (qfont_table[*p], stdout);
105 //#ifndef WIN32
106 //      fflush (stdout);
107 //#endif
108 }
109
110 char engineversion[40];
111
112 void Sys_Shared_EarlyInit(void)
113 {
114 #if defined(__linux__)
115         sprintf (engineversion, "%s Linux GL build %s", gamename, buildstring);
116 #elif defined(WIN32)
117         sprintf (engineversion, "%s Windows GL build %s", gamename, buildstring);
118 #else
119         sprintf (engineversion, "%s Unknown GL build %s", gamename, buildstring);
120 #endif
121
122         if (COM_CheckParm("-nostdout"))
123                 sys_nostdout = 1;
124         else
125                 printf("%s\n", engineversion);
126 }
127
128 void Sys_Shared_LateInit(void)
129 {
130 }