]> git.xonotic.org Git - xonotic/darkplaces.git/blob - qdefs.h
qdefs: Set NET_MAXMESSAGE back to 65536 since the higher value broke Xonotic demos.
[xonotic/darkplaces.git] / qdefs.h
1 #ifndef QDEFS_H
2 #define QDEFS_H
3
4 #if (__GNUC__ > 2) || defined (__clang__) || (__TINYC__)
5 #define DP_FUNC_PRINTF(n) __attribute__ ((format (printf, n, n+1)))
6 #define DP_FUNC_PURE      __attribute__ ((pure))
7 #define DP_FUNC_NORETURN  __attribute__ ((noreturn))
8 #else
9 #define DP_FUNC_PRINTF(n)
10 #define DP_FUNC_PURE
11 #define DP_FUNC_NORETURN
12 #endif
13
14 #define MAX_NUM_ARGVS   50
15
16 #ifdef DP_SMALLMEMORY
17 #define MAX_INPUTLINE                   1024
18 #define CON_TEXTSIZE                    16384
19 #define CON_MAXLINES                    256
20 #define HIST_TEXTSIZE                   2048
21 #define HIST_MAXLINES                   16
22 #define MAX_ALIAS_NAME                  32
23 #define CMDBUFSIZE                              131072
24 #define MAX_ARGS                                80
25
26 #define NET_MAXMESSAGE                  65536
27 #define MAX_PACKETFRAGMENT              1024
28 #define MAX_EDICTS                              4096
29 #define MAX_MODELS                              1024
30 #define MAX_SOUNDS                              1024
31 #define MAX_LIGHTSTYLES                 64
32 #define MAX_STYLESTRING                 16
33 #define MAX_SCOREBOARD                  32
34 #define MAX_SCOREBOARDNAME              128
35 #define MAX_USERINFO_STRING             196
36 #define MAX_SERVERINFO_STRING   512
37 #define MAX_LOCALINFO_STRING    1 // not actually used by DP servers
38 #define CL_MAX_USERCMDS                 32
39 #define CVAR_HASHSIZE                   1024
40 #define M_MAX_EDICTS                    4096
41 #define MAX_DEMOS                               8
42 #define MAX_DEMONAME                    16
43 #define MAX_SAVEGAMES                   12
44 #define SAVEGAME_COMMENT_LENGTH 39
45 #define MAX_CLIENTNETWORKEYES   2
46 #define MAX_LEVELNETWORKEYES    0 // no portal support
47 #define MAX_OCCLUSION_QUERIES   256
48
49 #define CRYPTO_HOSTKEY_HASHSIZE 256
50 #define MAX_NETWM_ICON 1026 // one 32x32
51
52 #define MAX_WATERPLANES                 2
53 #define MAX_CUBEMAPS                    1024
54 #define MAX_EXPLOSIONS                  8
55 #define MAX_DLIGHTS                             16
56 #define MAX_CACHED_PICS                 2048 // this is 144 bytes each (or 152 on 64bit)
57 #define CACHEPICHASHSIZE                256
58 #define MAX_PARTICLEEFFECTNAME  256
59 #define MAX_PARTICLEEFFECTINFO  1024
60 #define MAX_PARTICLETEXTURES    256
61 #define MAXCLVIDEOS                             1
62 #define MAX_DYNAMIC_TEXTURE_COUNT       2
63 #define MAX_MAP_LEAFS                   8192
64
65 #define MAXTRACKS                               256
66 #define MAX_DYNAMIC_CHANNELS    64
67 #define MAX_CHANNELS                    260
68 #define MODLIST_TOTALSIZE               32
69 #define MAX_FAVORITESERVERS             32
70 #define MAX_DECALSYSTEM_QUEUE   64
71 #define PAINTBUFFER_SIZE                512
72 #define MAX_BINDMAPS                    8
73 #define MAX_PARTICLES_INITIAL   8192
74 #define MAX_PARTICLES                   8192
75 #define MAX_ENTITIES_INITIAL    256
76 #define MAX_STATICENTITIES              256
77 #define MAX_EFFECTS                             16
78 #define MAX_BEAMS                               16
79 #define MAX_TEMPENTITIES                256
80 #define SERVERLIST_TOTALSIZE            1024
81 #define SERVERLIST_ANDMASKCOUNT         5
82 #define SERVERLIST_ORMASKCOUNT          5
83 #else
84 #define MAX_INPUTLINE                   16384 ///< maximum length of console commandline, QuakeC strings, and many other text processing buffers
85 #define CON_TEXTSIZE                    1048576 ///< max scrollback buffer characters in console
86 #define CON_MAXLINES                    16384 ///< max scrollback buffer lines in console
87 #define HIST_TEXTSIZE                   262144 ///< max command history buffer characters in console
88 #define HIST_MAXLINES                   4096 ///< max command history buffer lines in console
89 #define MAX_ALIAS_NAME                  32
90 #define CMDBUFSIZE                              655360 ///< maximum script size that can be loaded by the exec command (8192 in Quake)
91 #define MAX_ARGS                                80 ///< maximum number of parameters to a console command or alias
92
93 #define NET_MAXMESSAGE                  65536 ///< max reliable packet size (sent as multiple fragments of MAX_PACKETFRAGMENT)
94 #define MAX_PACKETFRAGMENT              1024 ///< max length of packet fragment
95 #define MAX_EDICTS                              32768 ///< max number of objects in game world at once (32768 protocol limit)
96 #define MAX_MODELS                              8192 ///< max number of models loaded at once (including during level transitions)
97 #define MAX_SOUNDS                              4096 ///< max number of sounds loaded at once
98 #define MAX_LIGHTSTYLES                 256 ///< max flickering light styles in level (note: affects savegame format)
99 #define MAX_STYLESTRING                 64 ///< max length of flicker pattern for light style
100 #define MAX_SCOREBOARD                  255 ///< max number of players in game at once (255 protocol limit)
101 #define MAX_SCOREBOARDNAME              128 ///< max length of player name in game
102 #define MAX_USERINFO_STRING             1280 ///< max length of infostring for PROTOCOL_QUAKEWORLD (196 in QuakeWorld)
103 #define MAX_SERVERINFO_STRING   1280 ///< max length of server infostring for PROTOCOL_QUAKEWORLD (512 in QuakeWorld)
104 #define MAX_LOCALINFO_STRING    32768 ///< max length of server-local infostring for PROTOCOL_QUAKEWORLD (32768 in QuakeWorld)
105 #define CL_MAX_USERCMDS                 128 ///< max number of predicted input packets in queue
106 #define CVAR_HASHSIZE                   65536 ///< number of hash buckets for accelerating cvar name lookups
107 #define M_MAX_EDICTS                    32768 ///< max objects in menu vm
108 #define MAX_DEMOS                               8 ///< max demos provided to demos command
109 #define MAX_DEMONAME                    16 ///< max demo name length for demos command
110 #define MAX_SAVEGAMES                   12 ///< max savegames listed in savegame menu
111 #define SAVEGAME_COMMENT_LENGTH 39 ///< max comment length of savegame in menu
112 #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)
113 #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)
114 #define MAX_OCCLUSION_QUERIES   4096 ///< max number of query objects that can be used in one frame
115
116 #define CRYPTO_HOSTKEY_HASHSIZE 8192 ///< number of hash buckets for accelerating host key lookups
117 #define MAX_NETWM_ICON 352822 // 16x16, 22x22, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512
118
119 #define MAX_WATERPLANES                 16 ///< max number of water planes visible (each one causes additional view renders)
120 #define MAX_CUBEMAPS                    1024 ///< max number of cubemap textures loaded for light filters
121 #define MAX_EXPLOSIONS                  64 ///< max number of explosion shell effects active at once (not particle related)
122 #define MAX_DLIGHTS                             256 ///< max number of dynamic lights (rocket flashes, etc) in scene at once
123 #define MAX_CACHED_PICS                 2048 ///< max number of 2D pics loaded at once
124 #define CACHEPICHASHSIZE                256 ///< number of hash buckets for accelerating 2D pic name lookups
125 #define MAX_PARTICLEEFFECTNAME  4096 ///< maximum number of unique names of particle effects (for particleeffectnum)
126 #define MAX_PARTICLEEFFECTINFO  8192 ///< maximum number of unique particle effects (each name may associate with several of these)
127 #define MAX_PARTICLETEXTURES    256 ///< maximum number of unique particle textures in the particle font
128 #define MAXCLVIDEOS                             65 ///< maximum number of video streams being played back at once (1 is reserved for the playvideo command)
129 #define MAX_DYNAMIC_TEXTURE_COUNT       64 ///< maximum number of dynamic textures (web browsers, playvideo, etc)
130 #define MAX_MAP_LEAFS                   65536 ///< maximum number of BSP leafs in world (8192 in Quake)
131
132 #define MAXTRACKS                               256 ///< max CD track index
133 // 0 to NUM_AMBIENTS - 1 = water, etc
134 // NUM_AMBIENTS to NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS - 1 = normal entity sounds
135 // NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS to total_channels = static sounds
136 #define MAX_DYNAMIC_CHANNELS    512
137 #define MAX_CHANNELS                    (8192 + 4)
138 #define MODLIST_TOTALSIZE               256
139 #define MAX_FAVORITESERVERS             256
140 #define MAX_DECALSYSTEM_QUEUE   1024
141 #define PAINTBUFFER_SIZE                2048
142 #define MAX_BINDMAPS                    8
143 #define MAX_PARTICLES_INITIAL   8192 ///< initial allocation for cl.particles
144 #define MAX_PARTICLES                   1048576 ///< upper limit on cl.particles size
145 #define MAX_ENTITIES_INITIAL            256 ///< initial size of cl.entities
146 #define MAX_STATICENTITIES              4096 ///< limit on size of cl.static_entities
147 #define MAX_EFFECTS                             256 ///< limit on size of cl.effects
148 #define MAX_BEAMS                               256 ///< limit on size of cl.beams
149 #define MAX_TEMPENTITIES                4096 ///< max number of temporary models visible per frame (certain sprite effects, certain types of CSQC entities also use this)
150 #define SERVERLIST_TOTALSIZE            2048 ///< max servers in the server list
151 #define SERVERLIST_ANDMASKCOUNT         16 ///< max items in server list AND mask
152 #define SERVERLIST_ORMASKCOUNT          16 ///< max items in server list OR mask
153 #endif
154
155
156 #define CMD_TOKENIZELENGTH (MAX_INPUTLINE + MAX_ARGS) ///< maximum tokenizable commandline length (counting trailing 0)
157
158
159 #define MAX_QPATH               128                     ///< max length of a quake game pathname
160 #ifdef PATH_MAX
161 #define MAX_OSPATH              PATH_MAX
162 #elif MAX_PATH
163 #define MAX_OSPATH              MAX_PATH
164 #else
165 #define MAX_OSPATH              1024            ///< max length of a filesystem pathname
166 #endif
167
168 #define ON_EPSILON              0.1                     ///< point on plane side epsilon
169
170 #define NET_MINRATE             1000 ///< limits "rate" and "sv_maxrate" cvars
171
172 // In Quake, any char in 0..32 counts as whitespace
173 //#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
174 #define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
175 #define ISCOMMENT(ch, pos) ch[pos] == '/' && ch[pos + 1] == '/' && (pos == 0 || ISWHITESPACE(ch[pos - 1]))
176 // This also includes extended characters, and ALL control chars
177 #define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
178
179 #ifdef PRVM_64
180 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFFFFFFFFFF) // also match "negative zero" doubles of value 0x8000000000000000
181 #define FLOAT_LOSSLESS_FORMAT "%.17g"
182 #define VECTOR_LOSSLESS_FORMAT "%.17g %.17g %.17g"
183 #else
184 #define FLOAT_IS_TRUE_FOR_INT(x) ((x) & 0x7FFFFFFF) // also match "negative zero" floats of value 0x80000000
185 #define FLOAT_LOSSLESS_FORMAT "%.9g"
186 #define VECTOR_LOSSLESS_FORMAT "%.9g %.9g %.9g"
187 #endif
188
189 // originally this was _MSC_VER
190 // but here we want to test the system libc, which on win32 is borked, and NOT the compiler
191 #ifdef WIN32
192 #define INT_LOSSLESS_FORMAT_SIZE "I64"
193 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((__int64)(x))
194 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((unsigned __int64)(x))
195 #else
196 #define INT_LOSSLESS_FORMAT_SIZE "j"
197 #define INT_LOSSLESS_FORMAT_CONVERT_S(x) ((intmax_t)(x))
198 #define INT_LOSSLESS_FORMAT_CONVERT_U(x) ((uintmax_t)(x))
199 #endif
200
201 #endif