]> git.xonotic.org Git - xonotic/darkplaces.git/blob - quakedef.h
Fix OpenSolaris build. Add platform ID for a few other platforms
[xonotic/darkplaces.git] / quakedef.h
1 /*
2 Copyright (C) 1996-1997 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 // quakedef.h -- primary header for client
21
22 #ifndef QUAKEDEF_H
23 #define QUAKEDEF_H
24
25 #ifdef __APPLE__
26 # include <TargetConditionals.h>
27 #endif
28
29 #if (__GNUC__ > 2) || defined (__clang__) || (__TINYC__)
30 #define DP_FUNC_PRINTF(n) __attribute__ ((format (printf, n, n+1)))
31 #define DP_FUNC_PURE      __attribute__ ((pure))
32 #define DP_FUNC_NORETURN  __attribute__ ((noreturn))
33 #else
34 #define DP_FUNC_PRINTF(n)
35 #define DP_FUNC_PURE
36 #define DP_FUNC_NORETURN
37 #endif
38
39 #include <sys/types.h>
40 #include <ctype.h>
41 #include <math.h>
42 #include <string.h>
43 #include <stdarg.h>
44 #include <stdio.h>
45 #include <stdlib.h>
46 #include <limits.h>
47 #include <setjmp.h>
48
49 #include "qtypes.h"
50
51 extern const char *buildstring;
52 extern char engineversion[128];
53
54 #define GAMENAME "id1"
55
56 #define MAX_NUM_ARGVS   50
57
58 #ifdef DP_SMALLMEMORY
59 #define MAX_INPUTLINE                   1024
60 #define CON_TEXTSIZE                    16384
61 #define CON_MAXLINES                    256
62 #define HIST_TEXTSIZE                   2048
63 #define HIST_MAXLINES                   16
64 #define MAX_ALIAS_NAME                  32
65 #define CMDBUFSIZE                              131072
66 #define MAX_ARGS                                80
67
68 #define NET_MAXMESSAGE                  65536
69 #define MAX_PACKETFRAGMENT              1024
70 #define MAX_EDICTS                              4096
71 #define MAX_MODELS                              1024
72 #define MAX_SOUNDS                              1024
73 #define MAX_LIGHTSTYLES                 64
74 #define MAX_STYLESTRING                 16
75 #define MAX_SCOREBOARD                  32
76 #define MAX_SCOREBOARDNAME              128
77 #define MAX_USERINFO_STRING             196
78 #define MAX_SERVERINFO_STRING   512
79 #define MAX_LOCALINFO_STRING    1 // not actually used by DP servers
80 #define CL_MAX_USERCMDS                 32
81 #define CVAR_HASHSIZE                   1024
82 #define M_MAX_EDICTS                    4096
83 #define MAX_DEMOS                               8
84 #define MAX_DEMONAME                    16
85 #define MAX_SAVEGAMES                   12
86 #define SAVEGAME_COMMENT_LENGTH 39
87 #define MAX_CLIENTNETWORKEYES   2
88 #define MAX_LEVELNETWORKEYES    0 // no portal support
89 #define MAX_OCCLUSION_QUERIES   256
90
91 #define CRYPTO_HOSTKEY_HASHSIZE 256
92 #define MAX_NETWM_ICON 1026 // one 32x32
93
94 #define MAX_WATERPLANES                 2
95 #define MAX_CUBEMAPS                    1024
96 #define MAX_EXPLOSIONS                  8
97 #define MAX_DLIGHTS                             16
98 #define MAX_CACHED_PICS                 2048 // this is 144 bytes each (or 152 on 64bit)
99 #define CACHEPICHASHSIZE                256
100 #define MAX_PARTICLEEFFECTNAME  256
101 #define MAX_PARTICLEEFFECTINFO  1024
102 #define MAX_PARTICLETEXTURES    256
103 #define MAXCLVIDEOS                             1
104 #define MAX_DYNAMIC_TEXTURE_COUNT       2
105 #define MAX_MAP_LEAFS                   8192
106
107 #define MAXTRACKS                               256
108 #define MAX_DYNAMIC_CHANNELS    64
109 #define MAX_CHANNELS                    260
110 #define MODLIST_TOTALSIZE               32
111 #define MAX_FAVORITESERVERS             32
112 #define MAX_DECALSYSTEM_QUEUE   64
113 #define PAINTBUFFER_SIZE                512
114 #define MAX_BINDMAPS                    8
115 #define MAX_PARTICLES_INITIAL   8192
116 #define MAX_PARTICLES                   8192
117 #define MAX_ENITIES_INITIAL             256
118 #define MAX_STATICENTITIES              256
119 #define MAX_EFFECTS                             16
120 #define MAX_BEAMS                               16
121 #define MAX_TEMPENTITIES                256
122 #define SERVERLIST_TOTALSIZE            1024
123 #define SERVERLIST_ANDMASKCOUNT         5
124 #define SERVERLIST_ORMASKCOUNT          5
125 #else
126 #define MAX_INPUTLINE                   16384 ///< maximum length of console commandline, QuakeC strings, and many other text processing buffers
127 #define CON_TEXTSIZE                    1048576 ///< max scrollback buffer characters in console
128 #define CON_MAXLINES                    16384 ///< max scrollback buffer lines in console
129 #define HIST_TEXTSIZE                   262144 ///< max command history buffer characters in console
130 #define HIST_MAXLINES                   4096 ///< max command history buffer lines in console
131 #define MAX_ALIAS_NAME                  32
132 #define CMDBUFSIZE                              655360 ///< maximum script size that can be loaded by the exec command (8192 in Quake)
133 #define MAX_ARGS                                80 ///< maximum number of parameters to a console command or alias
134
135 #define NET_MAXMESSAGE                  65536 ///< max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT)
136 #define MAX_PACKETFRAGMENT              1024 ///< max length of packet fragment
137 #define MAX_EDICTS                              32768 ///< max number of objects in game world at once (32768 protocol limit)
138 #define MAX_MODELS                              8192 ///< max number of models loaded at once (including during level transitions)
139 #define MAX_SOUNDS                              4096 ///< max number of sounds loaded at once
140 #define MAX_LIGHTSTYLES                 256 ///< max flickering light styles in level (note: affects savegame format)
141 #define MAX_STYLESTRING                 64 ///< max length of flicker pattern for light style
142 #define MAX_SCOREBOARD                  255 ///< max number of players in game at once (255 protocol limit)
143 #define MAX_SCOREBOARDNAME              128 ///< max length of player name in game
144 #define MAX_USERINFO_STRING             1280 ///< max length of infostring for PROTOCOL_QUAKEWORLD (196 in QuakeWorld)
145 #define MAX_SERVERINFO_STRING   1280 ///< max length of server infostring for PROTOCOL_QUAKEWORLD (512 in QuakeWorld)
146 #define MAX_LOCALINFO_STRING    32768 ///< max length of server-local infostring for PROTOCOL_QUAKEWORLD (32768 in QuakeWorld)
147 #define CL_MAX_USERCMDS                 128 ///< max number of predicted input packets in queue
148 #define CVAR_HASHSIZE                   65536 ///< number of hash buckets for accelerating cvar name lookups
149 #define M_MAX_EDICTS                    32768 ///< max objects in menu vm
150 #define MAX_DEMOS                               8 ///< max demos provided to demos command
151 #define MAX_DEMONAME                    16 ///< max demo name length for demos command
152 #define MAX_SAVEGAMES                   12 ///< max savegames listed in savegame menu
153 #define SAVEGAME_COMMENT_LENGTH 39 ///< max comment length of savegame in menu
154 #define MAX_CLIENTNETWORKEYES   16 ///< max number of locations that can be added to pvs when culling network entities (must be at least 2 for prediction)
155 #define MAX_LEVELNETWORKEYES    512 ///< max number of locations that can be added to pvs when culling network entities (must be at least 2 for prediction)
156 #define MAX_OCCLUSION_QUERIES   4096 ///< max number of query objects that can be used in one frame
157
158 #define CRYPTO_HOSTKEY_HASHSIZE 8192 ///< number of hash buckets for accelerating host key lookups
159 #define MAX_NETWM_ICON 352822 // 16x16, 22x22, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512
160
161 #define MAX_WATERPLANES                 16 ///< max number of water planes visible (each one causes additional view renders)
162 #define MAX_CUBEMAPS                    1024 ///< max number of cubemap textures loaded for light filters
163 #define MAX_EXPLOSIONS                  64 ///< max number of explosion shell effects active at once (not particle related)
164 #define MAX_DLIGHTS                             256 ///< max number of dynamic lights (rocket flashes, etc) in scene at once
165 #define MAX_CACHED_PICS                 2048 ///< max number of 2D pics loaded at once
166 #define CACHEPICHASHSIZE                256 ///< number of hash buckets for accelerating 2D pic name lookups
167 #define MAX_PARTICLEEFFECTNAME  4096 ///< maximum number of unique names of particle effects (for particleeffectnum)
168 #define MAX_PARTICLEEFFECTINFO  8192 ///< maximum number of unique particle effects (each name may associate with several of these)
169 #define MAX_PARTICLETEXTURES    256 ///< maximum number of unique particle textures in the particle font
170 #define MAXCLVIDEOS                             65 ///< maximum number of video streams being played back at once (1 is reserved for the playvideo command)
171 #define MAX_DYNAMIC_TEXTURE_COUNT       64 ///< maximum number of dynamic textures (web browsers, playvideo, etc)
172 #define MAX_MAP_LEAFS                   65536 ///< maximum number of BSP leafs in world (8192 in Quake)
173
174 #define MAXTRACKS                               256 ///< max CD track index
175 // 0 to NUM_AMBIENTS - 1 = water, etc
176 // NUM_AMBIENTS to NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS - 1 = normal entity sounds
177 // NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS to total_channels = static sounds
178 #define MAX_DYNAMIC_CHANNELS    512
179 #define MAX_CHANNELS                    (8192 + 4)
180 #define MODLIST_TOTALSIZE               256
181 #define MAX_FAVORITESERVERS             256
182 #define MAX_DECALSYSTEM_QUEUE   1024
183 #define PAINTBUFFER_SIZE                2048
184 #define MAX_BINDMAPS                    8
185 #define MAX_PARTICLES_INITIAL   8192 ///< initial allocation for cl.particles
186 #define MAX_PARTICLES                   1048576 ///< upper limit on cl.particles size
187 #define MAX_ENITIES_INITIAL             256 ///< initial size of cl.entities
188 #define MAX_STATICENTITIES              1024 ///< limit on size of cl.static_entities
189 #define MAX_EFFECTS                             256 ///< limit on size of cl.effects
190 #define MAX_BEAMS                               256 ///< limit on size of cl.beams
191 #define MAX_TEMPENTITIES                4096 ///< max number of temporary models visible per frame (certain sprite effects, certain types of CSQC entities also use this)
192 #define SERVERLIST_TOTALSIZE            2048 ///< max servers in the server list
193 #define SERVERLIST_ANDMASKCOUNT         16 ///< max items in server list AND mask
194 #define SERVERLIST_ORMASKCOUNT          16 ///< max items in server list OR mask
195 #endif
196
197
198 #define CMD_TOKENIZELENGTH (MAX_INPUTLINE + MAX_ARGS) ///< maximum tokenizable commandline length (counting trailing 0)
199
200
201 #define MAX_QPATH               128                     ///< max length of a quake game pathname
202 #ifdef PATH_MAX
203 #define MAX_OSPATH              PATH_MAX
204 #elif MAX_PATH
205 #define MAX_OSPATH              MAX_PATH
206 #else
207 #define MAX_OSPATH              1024            ///< max length of a filesystem pathname
208 #endif
209
210 #define ON_EPSILON              0.1                     ///< point on plane side epsilon
211
212 #define NET_MINRATE             1000 ///< limits "rate" and "sv_maxrate" cvars
213
214 //
215 // stats are integers communicated to the client by the server
216 //
217 #define MAX_CL_STATS            256
218 #define STAT_HEALTH                     0
219 //#define       STAT_FRAGS                      1
220 #define STAT_WEAPON                     2
221 #define STAT_AMMO                       3
222 #define STAT_ARMOR                      4
223 #define STAT_WEAPONFRAME        5
224 #define STAT_SHELLS                     6
225 #define STAT_NAILS                      7
226 #define STAT_ROCKETS            8
227 #define STAT_CELLS                      9
228 #define STAT_ACTIVEWEAPON       10
229 #define STAT_TOTALSECRETS       11
230 #define STAT_TOTALMONSTERS      12
231 #define STAT_SECRETS            13              ///< bumped on client side by svc_foundsecret
232 #define STAT_MONSTERS           14              ///< bumped by svc_killedmonster
233 #define STAT_ITEMS                      15 ///< FTE, DP
234 #define STAT_VIEWHEIGHT         16 ///< FTE, DP
235 //#define STAT_TIME                     17 ///< FTE
236 //#define STAT_VIEW2            20 ///< FTE
237 #define STAT_VIEWZOOM           21 ///< DP
238 #define MIN_VM_STAT         32 ///< stat range available to VM_SV_AddStat
239 #define MAX_VM_STAT         220 ///< stat range available to VM_SV_AddStat
240 #define STAT_MOVEVARS_AIRACCEL_QW_STRETCHFACTOR 220 ///< DP
241 #define STAT_MOVEVARS_AIRCONTROL_PENALTY                                        221 ///< DP
242 #define STAT_MOVEVARS_AIRSPEEDLIMIT_NONQW 222 ///< DP
243 #define STAT_MOVEVARS_AIRSTRAFEACCEL_QW 223 ///< DP
244 #define STAT_MOVEVARS_AIRCONTROL_POWER                                  224 ///< DP
245 #define STAT_MOVEFLAGS                              225 ///< DP
246 #define STAT_MOVEVARS_WARSOWBUNNY_AIRFORWARDACCEL       226 ///< DP
247 #define STAT_MOVEVARS_WARSOWBUNNY_ACCEL                         227 ///< DP
248 #define STAT_MOVEVARS_WARSOWBUNNY_TOPSPEED                      228 ///< DP
249 #define STAT_MOVEVARS_WARSOWBUNNY_TURNACCEL                     229 ///< DP
250 #define STAT_MOVEVARS_WARSOWBUNNY_BACKTOSIDERATIO       230 ///< DP
251 #define STAT_MOVEVARS_AIRSTOPACCELERATE                         231 ///< DP
252 #define STAT_MOVEVARS_AIRSTRAFEACCELERATE                       232 ///< DP
253 #define STAT_MOVEVARS_MAXAIRSTRAFESPEED                         233 ///< DP
254 #define STAT_MOVEVARS_AIRCONTROL                                        234 ///< DP
255 #define STAT_FRAGLIMIT                                                          235 ///< DP
256 #define STAT_TIMELIMIT                                                          236 ///< DP
257 #define STAT_MOVEVARS_WALLFRICTION                                      237 ///< DP
258 #define STAT_MOVEVARS_FRICTION                                          238 ///< DP
259 #define STAT_MOVEVARS_WATERFRICTION                                     239 ///< DP
260 #define STAT_MOVEVARS_TICRATE                                           240 ///< DP
261 #define STAT_MOVEVARS_TIMESCALE                                         241 ///< DP
262 #define STAT_MOVEVARS_GRAVITY                                           242 ///< DP
263 #define STAT_MOVEVARS_STOPSPEED                                         243 ///< DP
264 #define STAT_MOVEVARS_MAXSPEED                                          244 ///< DP
265 #define STAT_MOVEVARS_SPECTATORMAXSPEED                         245 ///< DP
266 #define STAT_MOVEVARS_ACCELERATE                                        246 ///< DP
267 #define STAT_MOVEVARS_AIRACCELERATE                                     247 ///< DP
268 #define STAT_MOVEVARS_WATERACCELERATE                           248 ///< DP
269 #define STAT_MOVEVARS_ENTGRAVITY                                        249 ///< DP
270 #define STAT_MOVEVARS_JUMPVELOCITY                                      250 ///< DP
271 #define STAT_MOVEVARS_EDGEFRICTION                                      251 ///< DP
272 #define STAT_MOVEVARS_MAXAIRSPEED                                       252 ///< DP
273 #define STAT_MOVEVARS_STEPHEIGHT                                        253 ///< DP
274 #define STAT_MOVEVARS_AIRACCEL_QW                                       254 ///< DP
275 #define STAT_MOVEVARS_AIRACCEL_SIDEWAYS_FRICTION        255 ///< DP
276
277 // moveflags values
278 #define MOVEFLAG_VALID 0x80000000
279 #define MOVEFLAG_Q2AIRACCELERATE 0x00000001
280 #define MOVEFLAG_NOGRAVITYONGROUND 0x00000002
281 #define MOVEFLAG_GRAVITYUNAFFECTEDBYTICRATE 0x00000004
282
283 // stock defines
284
285 #define IT_SHOTGUN                              1
286 #define IT_SUPER_SHOTGUN                2
287 #define IT_NAILGUN                              4
288 #define IT_SUPER_NAILGUN                8
289 #define IT_GRENADE_LAUNCHER             16
290 #define IT_ROCKET_LAUNCHER              32
291 #define IT_LIGHTNING                    64
292 #define IT_SUPER_LIGHTNING      128
293 #define IT_SHELLS               256
294 #define IT_NAILS                512
295 #define IT_ROCKETS              1024
296 #define IT_CELLS                2048
297 #define IT_AXE                  4096
298 #define IT_ARMOR1               8192
299 #define IT_ARMOR2               16384
300 #define IT_ARMOR3               32768
301 #define IT_SUPERHEALTH          65536
302 #define IT_KEY1                 131072
303 #define IT_KEY2                 262144
304 #define IT_INVISIBILITY                 524288
305 #define IT_INVULNERABILITY              1048576
306 #define IT_SUIT                                 2097152
307 #define IT_QUAD                                 4194304
308 #define IT_SIGIL1               (1<<28)
309 #define IT_SIGIL2               (1<<29)
310 #define IT_SIGIL3               (1<<30)
311 #define IT_SIGIL4               (1<<31)
312
313 //===========================================
314 // AK nexuiz changed and added defines
315
316 #define NEX_IT_UZI              1
317 #define NEX_IT_SHOTGUN          2
318 #define NEX_IT_GRENADE_LAUNCHER 4
319 #define NEX_IT_ELECTRO          8
320 #define NEX_IT_CRYLINK          16
321 #define NEX_IT_NEX              32
322 #define NEX_IT_HAGAR            64
323 #define NEX_IT_ROCKET_LAUNCHER  128
324 #define NEX_IT_SHELLS           256
325 #define NEX_IT_BULLETS          512
326 #define NEX_IT_ROCKETS          1024
327 #define NEX_IT_CELLS            2048
328 #define NEX_IT_LASER            4094
329 #define NEX_IT_STRENGTH         8192
330 #define NEX_IT_INVINCIBLE       16384
331 #define NEX_IT_SPEED            32768
332 #define NEX_IT_SLOWMO           65536
333
334 //===========================================
335 //rogue changed and added defines
336
337 #define RIT_SHELLS              128
338 #define RIT_NAILS               256
339 #define RIT_ROCKETS             512
340 #define RIT_CELLS               1024
341 #define RIT_AXE                 2048
342 #define RIT_LAVA_NAILGUN        4096
343 #define RIT_LAVA_SUPER_NAILGUN  8192
344 #define RIT_MULTI_GRENADE       16384
345 #define RIT_MULTI_ROCKET        32768
346 #define RIT_PLASMA_GUN          65536
347 #define RIT_ARMOR1              8388608
348 #define RIT_ARMOR2              16777216
349 #define RIT_ARMOR3              33554432
350 #define RIT_LAVA_NAILS          67108864
351 #define RIT_PLASMA_AMMO         134217728
352 #define RIT_MULTI_ROCKETS       268435456
353 #define RIT_SHIELD              536870912
354 #define RIT_ANTIGRAV            1073741824
355 #define RIT_SUPERHEALTH         2147483648
356
357 //MED 01/04/97 added hipnotic defines
358 //===========================================
359 //hipnotic added defines
360 #define HIT_PROXIMITY_GUN_BIT 16
361 #define HIT_MJOLNIR_BIT       7
362 #define HIT_LASER_CANNON_BIT  23
363 #define HIT_PROXIMITY_GUN   (1<<HIT_PROXIMITY_GUN_BIT)
364 #define HIT_MJOLNIR         (1<<HIT_MJOLNIR_BIT)
365 #define HIT_LASER_CANNON    (1<<HIT_LASER_CANNON_BIT)
366 #define HIT_WETSUIT         (1<<(23+2))
367 #define HIT_EMPATHY_SHIELDS (1<<(23+3))
368
369 //===========================================
370
371 #include "zone.h"
372 #include "fs.h"
373 #include "common.h"
374 #include "cvar.h"
375 #include "bspfile.h"
376 #include "sys.h"
377 #include "vid.h"
378 #include "mathlib.h"
379
380 #include "r_textures.h"
381
382 #include "crypto.h"
383 #include "draw.h"
384 #include "screen.h"
385 #include "netconn.h"
386 #include "protocol.h"
387 #include "cmd.h"
388 #include "sbar.h"
389 #include "sound.h"
390 #include "model_shared.h"
391 #include "world.h"
392 #include "client.h"
393 #include "render.h"
394 #include "progs.h"
395 #include "progsvm.h"
396 #include "server.h"
397
398 #include "input.h"
399 #include "keys.h"
400 #include "console.h"
401 #ifdef CONFIG_MENU
402 #include "menu.h"
403 #endif
404 #include "csprogs.h"
405
406 extern qboolean noclip_anglehack;
407
408 extern cvar_t developer;
409 extern cvar_t developer_entityparsing;
410 extern cvar_t developer_extra;
411 extern cvar_t developer_insane;
412 extern cvar_t developer_loadfile;
413 extern cvar_t developer_loading;
414
415 extern cvar_t sessionid;
416
417 #define STARTCONFIGFILENAME "quake.rc"
418 #define CONFIGFILENAME "config.cfg"
419
420 /* Preprocessor macros to identify platform
421     DP_OS_NAME  - "friendly" name of the OS, for humans to read
422     DP_OS_STR   - "identifier" of the OS, more suited for code to use
423     DP_ARCH_STR - "identifier" of the processor architecture
424  */
425 #if defined(__ANDROID__) /* must come first because it also defines linux */
426 # define DP_OS_NAME             "Android"
427 # define DP_OS_STR              "android"
428 # define USE_GLES2              1
429 # define USE_RWOPS              1
430 # define LINK_TO_ZLIB   1
431 # define LINK_TO_LIBVORBIS 1
432 #ifdef USEXMP
433 # define LINK_TO_LIBXMP 1 // nyov: if someone can test with the android NDK compiled libxmp?
434 #endif
435 # define DP_MOBILETOUCH 1
436 # define DP_FREETYPE_STATIC 1
437 #elif TARGET_OS_IPHONE /* must come first because it also defines MACOSX */
438 # define DP_OS_NAME             "iPhoneOS"
439 # define DP_OS_STR              "iphoneos"
440 # define USE_GLES2              1
441 # define LINK_TO_ZLIB   1
442 # define LINK_TO_LIBVORBIS 1
443 # define DP_MOBILETOUCH 1
444 # define DP_FREETYPE_STATIC 1
445 #elif defined(__linux__)
446 # define DP_OS_NAME             "Linux"
447 # define DP_OS_STR              "linux"
448 #elif defined(_WIN64)
449 # define DP_OS_NAME             "Windows64"
450 # define DP_OS_STR              "win64"
451 #elif defined(WIN32)
452 # define DP_OS_NAME             "Windows"
453 # define DP_OS_STR              "win32"
454 #elif defined(__FreeBSD__)
455 # define DP_OS_NAME             "FreeBSD"
456 # define DP_OS_STR              "freebsd"
457 #elif defined(__NetBSD__)
458 # define DP_OS_NAME             "NetBSD"
459 # define DP_OS_STR              "netbsd"
460 #elif defined(__OpenBSD__)
461 # define DP_OS_NAME             "OpenBSD"
462 # define DP_OS_STR              "openbsd"
463 #elif defined(__DragonFly__)
464 # define DP_OS_NAME             "DragonFlyBSD"
465 # define DP_OS_STR              "dragonflybsd"
466 #elif defined(MACOSX)
467 # define DP_OS_NAME             "Mac OS X"
468 # define DP_OS_STR              "osx"
469 #elif defined(__MORPHOS__)
470 # define DP_OS_NAME             "MorphOS"
471 # define DP_OS_STR              "morphos"
472 #elif defined (sun) || defined (__sun)
473 # if defined (__SVR4) || defined (__svr4__)
474 #  define DP_OS_NAME    "Solaris"
475 #  define DP_OS_STR             "solaris"
476 # else
477 #  define DP_OS_NAME    "SunOS"
478 #  define DP_OS_STR             "sunos"
479 # endif
480 #else
481 # define DP_OS_NAME             "Unknown"
482 # define DP_OS_STR              "unknown"
483 #endif
484
485 #if defined(__GNUC__) || (__clang__)
486 # if defined(__i386__)
487 #  define DP_ARCH_STR           "686"
488 #  define SSE_POSSIBLE
489 #  ifdef __SSE__
490 #   define SSE_PRESENT
491 #  endif
492 #  ifdef __SSE2__
493 #   define SSE2_PRESENT
494 #  endif
495 # elif defined(__x86_64__)
496 #  define DP_ARCH_STR           "x86_64"
497 #  define SSE_PRESENT
498 #  define SSE2_PRESENT
499 # elif defined(__powerpc__)
500 #  define DP_ARCH_STR           "ppc"
501 # endif
502 #elif defined(_WIN64)
503 # define DP_ARCH_STR            "x86_64"
504 # define SSE_PRESENT
505 # define SSE2_PRESENT
506 #elif defined(WIN32)
507 # define DP_ARCH_STR            "x86"
508 # define SSE_POSSIBLE
509 #endif
510
511 #ifdef SSE_PRESENT
512 # define SSE_POSSIBLE
513 #endif
514
515 #ifdef NO_SSE
516 # undef SSE_PRESENT
517 # undef SSE_POSSIBLE
518 # undef SSE2_PRESENT
519 #endif
520
521 #ifdef SSE_POSSIBLE
522 // runtime detection of SSE/SSE2 capabilities for x86
523 qboolean Sys_HaveSSE(void);
524 qboolean Sys_HaveSSE2(void);
525 #else
526 #define Sys_HaveSSE() false
527 #define Sys_HaveSSE2() false
528 #endif
529
530 #include "glquake.h"
531
532 #include "palette.h"
533 typedef enum host_state_e
534 {
535         host_shutdown,
536         host_init,
537         host_loading,
538         host_active
539 } host_state_t;
540
541 typedef struct host_s
542 {
543         jmp_buf abortframe;
544         int state;
545         int framecount; // incremented every frame, never reset (checked by Host_Error and Host_SaveConfig_f)
546         double realtime; // the accumulated mainloop time since application started (with filtering), without any slowmo or clamping
547         double dirtytime; // the main loop wall time for this frame, equal to Sys_DirtyTime() at the start of this host frame
548         double sleeptime; // time spent sleeping overall
549         qboolean restless; // don't sleep
550         qboolean paused; // global paused state, pauses both client and server
551 } host_t;
552
553 extern host_t host;
554
555 void Host_InitCommands(void);
556 void Host_Main(void);
557 double Host_Frame(double time);
558 void Host_Shutdown(void);
559 void Host_StartVideo(void);
560 void Host_Error(const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
561 void Host_Quit_f(cmd_state_t *cmd);
562 void SV_ClientCommands(const char *fmt, ...) DP_FUNC_PRINTF(1);
563 double SV_Frame(double time);
564 void SV_Shutdown(void);
565 void CL_Reconnect_f(cmd_state_t *cmd);
566 void Host_NoOperation_f(cmd_state_t *cmd);
567 void Host_LockSession(void);
568 void Host_UnlockSession(void);
569
570 void Host_AbortCurrentFrame(void);
571
572 /// skill level for currently loaded level (in case the user changes the cvar while the level is running, this reflects the level actually in use)
573 extern int current_skill;
574
575 //
576 // chase
577 //
578 extern cvar_t chase_active;
579 extern cvar_t cl_viewmodel_scale;
580
581 void Chase_Init (void);
582 void Chase_Reset (void);
583 void Chase_Update (void);
584
585 void fractalnoise(unsigned char *noise, int size, int startgrid);
586 void fractalnoisequick(unsigned char *noise, int size, int startgrid);
587 float noise4f(float x, float y, float z, float w);
588
589 void Sys_Shared_Init(void);
590
591 // Flag in size field of demos to indicate a client->server packet. Demo
592 // playback will ignore this, but it may be useful to make DP sniff packets to
593 // debug protocol exploits.
594 #define DEMOMSG_CLIENT_TO_SERVER 0x80000000
595
596 // In Quake, any char in 0..32 counts as whitespace
597 //#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
598 #define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
599
600 // This also includes extended characters, and ALL control chars
601 #define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
602
603
604 #ifdef PRVM_64
605 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
606 #define FLOAT_LOSSLESS_FORMAT "%.17g"
607 #define VECTOR_LOSSLESS_FORMAT "%.17g %.17g %.17g"
608 #else
609 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
610 #define FLOAT_LOSSLESS_FORMAT "%.9g"
611 #define VECTOR_LOSSLESS_FORMAT "%.9g %.9g %.9g"
612 #endif
613
614 // originally this was _MSC_VER
615 // but here we want to test the system libc, which on win32 is borked, and NOT the compiler
616 #ifdef WIN32
617 #define INT_LOSSLESS_FORMAT_SIZE "I64"
618 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((__int64)(x))
619 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((unsigned __int64)(x))
620 #else
621 #define INT_LOSSLESS_FORMAT_SIZE "j"
622 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((intmax_t)(x))
623 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((uintmax_t)(x))
624 #endif
625
626 #endif
627