1 /**
2  * @file
3  * @brief Defined CONSTANTS (Macros are elsewhere)
4  */
5 
6 /*
7 All original material Copyright (C) 2002-2013 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25 
26 */
27 
28 #pragma once
29 
30 /**
31  * @note The comment line specifying files has the following syntax:
32  *   [parent dir/filename]     OR
33  *   [parent dir]              OR
34  *   {project name}
35  */
36 
37 /* if a brush just barely pokes onto the other side, let it slide by without chopping */
38 #define	PLANESIDE_EPSILON	0.001
39 
40 /* if you increase this, you also have to change the aircraft buy/sell menu scripts */
41 #define MAX_ACTIVETEAM	12
42 
43 /** @sa CONTENTS_NODE - @todo replace this with CONTENTS_NODE? */
44 #define LEAFNODE -1
45 #define	PLANENUM_LEAF -1
46 
47 /* bsp constants */
48 #define	TEXINFO_NODE		-1		/* side is already on a node */
49 #define	MAXEDGES		20
50 
51 #define	TEAM_DEFAULT 1
52 
53 /** @sa Com_DeveloperSet_f */
54 #define	DEBUG_ALL		0x07FE
55 #define	DEBUG_SHARED	0x02
56 #define	DEBUG_ENGINE	0x04
57 #define	DEBUG_SYSTEM	0x08
58 #define	DEBUG_COMMANDS	0x10
59 #define	DEBUG_CLIENT	0x20
60 #define	DEBUG_SERVER	0x40
61 #define	DEBUG_GAME		0x80
62 #define	DEBUG_RENDERER	0x0100
63 #define	DEBUG_SOUND		0x0200
64 #define DEBUG_EVENTSYS	0x0400
65 /* note that routing is not included in DEBUG_ALL (too much output) */
66 #define DEBUG_ROUTING	0x1000
67 
68 #define	NONE		-1
69 #define	NONE_AMMO	0
70 
71 /* Timeunits for the various actions. */
72 #define	TU_CROUCH			3	/**< Time units for crouching and standing up */
73 #define	TU_TURN				1	/**< Time units for turning (no matter how far). */
74 #define	TU_MOVE_STRAIGHT	2	/**< Time units used to move straight to the next field/square. */
75 #define	TU_MOVE_DIAGONAL	3	/**< Time units used to move to a diagonal field/square. */
76 #define	TU_MOVE_CLIMB		4	/**< Time units used to climb a ladder. */
77 #define	TU_MOVE_FALL		0	/**< Time units used to fall. */
78 #define	TU_DOOR_ACTION		1	/**< Time units used to interact with doors */
79 #define	TU_CROUCH_MOVING_FACTOR	1.5	/**< The factor the normal movement is multiplied when in crouching mode */
80 #define	TU_FLYING_MOVING_FACTOR	2	/**< The factor the normal movement is multiplied when flying */
81 
82 /* Move/Routing values */
83 #define MAX_ROUTE			32
84 #define	MAX_ROUTE_TUS		50
85 
86 /* door states */
87 #define	STATE_OPENED		0
88 #define	STATE_CLOSED		1
89 
90 #define	MAX_STRING_CHARS    1024    /* max length of a string passed to Cmd_TokenizeString */
91 /* common/cmd.c */
92 #define	MAX_STRING_TOKENS   80  /* max tokens resulting from Cmd_TokenizeString */
93 
94 /* ALL */
95 #define MAX_TEXPATH         32  /**< max length of filename relative to gamedir, any longer makes the bsp files unnecessarily long */
96 
97 /* per-level limits */
98 /* 25 - bases are 5*5 - see BASE_SIZE*/
99 #define	MAX_TILESTRINGS     25
100 #define	MAX_TEAMS           8
101 #define	MAX_CLIENTS         256 /* absolute limit */
102 #define	MAX_EDICTS          1024    /* must change protocol to increase more */
103 #define	MAX_MODELS          256 /* these are sent over the net as bytes */
104 #define	MAX_GENERAL         (MAX_CLIENTS*2) /* general config strings */
105 
106 #define	INITIAL_HP 100
107 
108 /* game print flags */
109 #define	PRINT_NONE		-1  /* suppress printing */
110 #define	PRINT_CHAT		0   /* chat messages */
111 #define	PRINT_HUD		1   /* translated hud strings */
112 #define	PRINT_CONSOLE	2   /* critical messages goes to the game console */
113 
114 #define ERR_FATAL           0   /* exit the entire game with a popup window */
115 #define ERR_DROP            1   /* print to console and disconnect from game */
116 #define ERR_DISCONNECT      2   /* don't kill server */
117 
118 /* substract this from the ent->pos[z] to get the ground position */
119 #define	GROUND_DELTA	28
120 
121 /* substract this from the ent->pos[z] to get the selection circles' z position */
122 #define	SELECTION_DELTA	30
123 
124 /* important units */
125 #define UNIT_SIZE   32
126 #define UNIT_HEIGHT 64
127 /* player height - 12 to be able to walk trough doors
128  * UNIT_HEIGHT is the height of one level */
129 #define PLAYER_HEIGHT		(UNIT_HEIGHT - 16)
130 #define QUANT	4
131 /* WALL_SIZE is the distance a wall may protrude from the edge of a cell without interfeeting with an actor entering the cell */
132 #define WALL_SIZE 5
133 
134 /** upper design bounds
135  * leafbrushes, planes, and verts are still bounded by
136  * 16 bit short limits
137  */
138 #define	MAX_MAP_MODELS		1024
139 #define	MAX_MAP_BRUSHES		16384
140 #define	MAX_MAP_ENTITIES	2048
141 #define	MAX_MAP_ENTSTRING	0x40000
142 #define	MAX_MAP_TEXINFO		16384
143 #define	MAX_MAP_PLANES		65536
144 #define	MAX_MAP_NODES		65536
145 #define	MAX_MAP_BRUSHSIDES	65536
146 #define	MAX_MAP_LEAFS		65536
147 #define	MAX_MAP_VERTS		65536
148 #define	MAX_MAP_FACES		65536
149 #define	MAX_MAP_LEAFBRUSHES	65536
150 #define	MAX_MAP_EDGES		128000
151 #define	MAX_MAP_SURFEDGES	256000
152 #define	MAX_MAP_LIGHTING	0x1000000
153 /* WIDTH * WIDTH * 4 */
154 #define	MAX_MAP_ROUTING		0x100000
155 
156 #define	MAX_LEAFS		1024
157 
158 #if defined(COMPILE_MAP)
159   #define MAX_MAPTILES	1
160 #elif defined(COMPILE_UFO)
161   #define MAX_MAPTILES	64
162 #endif
163 
164 #define MAX_MOD_KNOWN   512
165 
166 /** key / value pair sizes */
167 #define	MAX_KEY		32
168 #define	MAX_VALUE	1024
169 
170 /** Lump ID constants (directory in the bsp header) */
171 #define LUMP_ENTITIES		0
172 #define LUMP_PLANES			1
173 #define LUMP_VERTEXES		2
174 #define LUMP_ROUTING		3
175 #define LUMP_NODES			4
176 #define LUMP_TEXINFO		5
177 #define LUMP_FACES			6
178 #define LUMP_LIGHTING_NIGHT	7
179 #define LUMP_LIGHTING_DAY	8
180 #define LUMP_LEAFS			9
181 #define LUMP_LEAFBRUSHES	10
182 #define LUMP_EDGES			11
183 #define LUMP_SURFEDGES		12
184 #define LUMP_MODELS			13
185 #define LUMP_BRUSHES		14
186 #define LUMP_BRUSHSIDES		15
187 #define LUMP_NORMALS		16
188 #define HEADER_LUMPS		17
189 
190 #define	SIDE_FRONT		0
191 #define	SIDE_ON			2
192 #define	SIDE_BACK		1
193 
194 /** 0-2 are axial planes */
195 #define	PLANE_X			0
196 #define	PLANE_Y			1
197 #define	PLANE_Z			2
198 
199 /** 3-5 are non-axial planes snapped to the nearest */
200 #define	PLANE_ANYX		3
201 #define	PLANE_ANYY		4
202 #define	PLANE_ANYZ		5
203 #define	PLANE_NONE		6
204 
205 #define AXIAL(p) ((p)->type < PLANE_ANYX)
206 
207 /** planes (x & ~1) and (x & ~1) + 1 are always opposites */
208 
209 #define	ANGLE_UP	-1
210 #define	ANGLE_DOWN	-2
211 
212 /*
213 ==============================================================
214 COLLISION DETECTION
215 ==============================================================
216 */
217 
218 /**
219  * @note contents flags are separate bits
220  * a given brush can contribute multiple content bits
221  * multiple brushes can be in a single leaf.
222  * Please update DisplayContentFlags, if these are updated.
223  * @sa DisplayContentFlags
224  */
225 
226 /** lower bits are stronger, and will eat weaker brushes completely */
227 #define	CONTENTS_SOLID	0x0001 /**< an eye is never valid in a solid */
228 #define	CONTENTS_WINDOW	0x0002 /**< translucent, but not watery */
229 #define	CONTENTS_LADDER	0x0004
230 #define	CONTENTS_WATER	0x0020
231 /** max 16 bit please - otherwise change EV_ACTOR_MOVE to send a long and not a short */
232 
233 /* ufo2map/map.c, ufo2map/portals.c */
234 #define	LAST_VISIBLE_CONTENTS	0x80
235 
236 #define	CONTENTS_LEVEL_ALL	0xFF00
237 #define	CONTENTS_LEVEL_1	0x0100
238 #define	CONTENTS_LEVEL_2	0x0200
239 #define	CONTENTS_LEVEL_3	0x0400
240 #define	CONTENTS_LEVEL_4	0x0800
241 #define	CONTENTS_LEVEL_5	0x1000
242 #define	CONTENTS_LEVEL_6	0x2000
243 #define	CONTENTS_LEVEL_7	0x4000
244 #define	CONTENTS_LEVEL_8	0x8000
245 
246 /** remaining contents are non-visible, and don't eat brushes */
247 #define	CONTENTS_ACTORCLIP		0x00010000
248 #define	CONTENTS_PASSABLE		0x00020000
249 #define CONTENTS_TERRAIN		0x00040000 /**<  */
250 #define CONTENTS_LIGHTCLIP		0x00080000 /**< used for special brushes to cast shade */
251 #define	CONTENTS_ACTOR			0x00800000 /**< should never be on a brush, only in game */
252 #define	CONTENTS_ORIGIN			0x01000000 /**< removed before bsping an entity */
253 #define	CONTENTS_WEAPONCLIP		0x02000000 /**< stop bullets */
254 #define	CONTENTS_DEADACTOR		0x04000000
255 #define	CONTENTS_DETAIL			0x08000000 /**< brushes to be added after vis leafs also used for debugging local entities */
256 #define	CONTENTS_TRANSLUCENT	0x10000000 /**< auto set if any surface has trans */
257 
258 #define	SURF_LIGHT		0x00000001 /**< value will hold the light strength */
259 #define	SURF_SLICK		0x00000002 /**< effects game physics */
260 #define	SURF_WARP		0x00000008 /**< turbulent water warp */
261 #define	SURF_BLEND33	0x00000010 /**< 0.33 alpha blending */
262 #define	SURF_BLEND66	0x00000020 /**< 0.66 alpha blending */
263 #define	SURF_FLOWING	0x00000040 /**< scroll towards angle */
264 #define	SURF_NODRAW		0x00000080 /**< don't bother referencing the texture */
265 #define	SURF_HINT		0x00000100 /**< make a primary bsp splitter */
266 #define	SURF_SKIP		0x00000200 /**< completely ignored, allowing non-closed brushes */
267 #define	SURF_PHONG		0x00000400 /**< phong interpolated lighting at compile time */
268 #define	SURF_BURN		0x00000800 /**< will keep burning when flamed */
269 #define	SURF_FOOTSTEP	0x00001000 /**< only for grabbing footsteps textures */
270 #define	SURF_ORIGIN		0x00002000 /**< use this to identity those submodel surfaces that must not be translated in case of rma */
271 #define	SURF_FOLIAGE		0x00004000 /**< will have foliage over this surface */
272 #define	SURF_ALPHATEST	0x02000000 /**< alpha test for transparent textures */
273 
274 /* content masks */
275 #define	MASK_ALL			(-1)
276 #define	MASK_SOLID			(CONTENTS_SOLID | CONTENTS_WINDOW)
277 #define	MASK_IMPASSABLE		(MASK_SOLID | CONTENTS_ACTORCLIP)
278 #define MASK_PASSABLE		(CONTENTS_PASSABLE | CONTENTS_WATER)
279 #define	MASK_SHOT			(CONTENTS_SOLID | CONTENTS_ACTOR | CONTENTS_WEAPONCLIP | CONTENTS_WINDOW)
280 #define MASK_SMOKE_AND_FIRE	(MASK_SOLID | CONTENTS_WATER | CONTENTS_WEAPONCLIP)
281 #define	MASK_VISIBILILITY	(CONTENTS_SOLID | CONTENTS_WATER)
282 #define	MASK_CLIP			(CONTENTS_ACTORCLIP | CONTENTS_WEAPONCLIP | CONTENTS_LIGHTCLIP)
283 
284 /*============================================================== */
285 
286 #define	ROUTING_NOT_REACHABLE	0xFF	/**< (byte) Indicates a cell that is not reachable.  A TU value. */
287 #define	ROUTING_UNREACHABLE		-1		/**< (int) Indicates that a cell is not reachable.  A DV value. */
288 
289 /* Battlescape map dimensions (WIDTH*WIDTH*HEIGHT) */
290 /** @brief -MAX_WORLD_WIDTH up tp +MAX_WORLD_WIDTH */
291 #define MAX_WORLD_WIDTH 4096
292 /** @brief absolute max - -GRID_WIDTH up tp +GRID_WIDTH @sa PATHFINDING_WIDTH */
293 #define GRID_WIDTH (MAX_WORLD_WIDTH / UNIT_SIZE)
294 /** @brief absolute max */
295 #define PATHFINDING_WIDTH (GRID_WIDTH * 2)
296 /** @brief 15 max, adjusting above 8 will require a rewrite to the DV code */
297 #define PATHFINDING_HEIGHT 8
298 /** @brief A cell's height in QUANT sized units */
299 #define CELL_HEIGHT (UNIT_HEIGHT / QUANT)
300 /** @brief The tallest actor's height in QUANT sized units */
301 #define ACTOR_MAX_HEIGHT (PLAYER_HEIGHT / QUANT)
302 
303 /* NOTE: this only allows quadratic units */
304 #define ACTOR_SIZE_INVALID 0
305 #define ACTOR_SIZE_NORMAL 1
306 #define ACTOR_SIZE_2x2 2
307 #define ACTOR_SIZE_3x3 3
308 #define	ACTOR_MAX_SIZE	(ACTOR_SIZE_2x2)
309 //#define	ACTOR_MAX_SIZE	(ACTOR_SIZE_3x3)
310 
311 /* Maximum falling distance in QUANT units (model units / QUANT) */
312 #define	PATHFINDING_MAX_FALL	16
313 /* The height of the box where we don't need the full actor's torso width */
314 #define	PATHFINDING_LEGROOMHEIGHT	4
315 /* Minimum step-up height in QUANT units (model units/QUANT)
316  * Note that 4 is the minimum to rise one cell every 4 moved horizontally. */
317 #define	PATHFINDING_MIN_STEPUP		2
318 /* Minimum step-up height in QUANT units (model units/QUANT)
319  * Note that 4 is the minimum to rise one cell every 4 moved horizontally. */
320 #define	PATHFINDING_MAX_STEPUP		4
321 /* A stepup value indicating that there is no way to enter the cell. */
322 #define	PATHFINDING_NO_STEPUP		(2 * CELL_HEIGHT)
323 /* Minimum height for an opening to be an opening in step units (model units/QUANT)
324  * Must be larger than PATHFINDING_MAX_STEPUP!!
325  */
326 #define	PATHFINDING_MIN_OPENING	6
327 /** @brief The size (in model units) of a microstep.  Must be a power of 2 and less than UNIT_SIZE. */
328 #define PATHFINDING_MICROSTEP_SIZE	4
329 /** @brief The number of microsteps that can be stepped over by an actor.
330  *  Used to allow an actor to stepup when the floor is not level or consitent. */
331 #define PATHFINDING_MICROSTEP_SKIP	2
332 
333 /* DIRECTION constants- define "odd" directions */
334 #define DIRECTION_CLIMB_UP		8
335 #define DIRECTION_CLIMB_DOWN	9
336 #define DIRECTION_STAND_UP		10
337 #define DIRECTION_CROUCH		11
338 #define DIRECTION_FALL			13
339 
340 
341 #define	ACTOR_MAX_STATES		2
342 
343 /**
344  * @note The bsp trees are generated based on the levels that a given brush is supposed to be in.
345  * So a brush that is tagged for viewing in levels 1, 2, and 3 will be in bsp tree 7 (1 + 2 + 4)
346  * a brush that is viewable in all levels will be in bsp tree level 255, and a bush that is not
347  * tagged for viewing by level will be in tree 0.
348  * Also, a brush will only be in one bsp tree - the brush tagged for levels 1, 2, and 3 will only
349  * be in tree 7, saving memory
350  */
351 #define	LEVEL_LASTVISIBLE		255
352 #define	LEVEL_LIGHTCLIP			256
353 #define	LEVEL_LASTLIGHTBLOCKING	256
354 #define	LEVEL_WEAPONCLIP		257
355 #define	LEVEL_ACTORCLIP			258
356 #define	LEVEL_MAX				259
357 #define	NUM_REGULAR_MODELS		(LEVEL_ACTORCLIP + 1)
358 
359 /* TestLine level masks */
360 #define	TL_FLAG_NONE			0x0000
361 #define	TL_FLAG_REGULAR_LEVELS	0x00FF
362 #define	TL_FLAG_ACTORCLIP		0x0100
363 #define	TL_FLAG_WEAPONCLIP		0x0200
364 #define	TL_FLAG_ALL				0x0300
365 
366 #define	LIGHTMAP_NIGHT	0
367 #define	LIGHTMAP_DAY	1
368 #define	LIGHTMAP_MAX	2
369 
370 #define	PSIDE_FRONT			1
371 #define	PSIDE_BACK			2
372 #define	PSIDE_BOTH			(PSIDE_FRONT|PSIDE_BACK)
373 #define	PSIDE_FACING		4
374 
375 #define	MAX_TOKEN_CHARS		256 /* max length of an individual token */
376 
377 #define	ON_EPSILON	0.1
378 
379 /* 1/32 epsilon to keep floating point happy */
380 #define	DIST_EPSILON	(0.03125)
381 #define	DIST_EPSILON2	(0.0625125) /* DIST_EPSILON * 2 + small bit more */
382 
383 #define	MAP_DIST_EPSILON	0.01
384 #define	NORMAL_EPSILON	0.00001
385 
386 #define	MAX_MAP_SIDES (MAX_MAP_BRUSHES*6)
387 #define	MAX_MAP_TEXTURES	1024
388 
389 #define MAX_MAP_LIGHTMAP	(512 * 512)
390 
391 #define MAP_SIZE_OFFSET 100
392