1 // Emacs style mode select	 -*- C++ -*-
2 //-----------------------------------------------------------------------------
3 //
4 // $Id:$
5 //
6 // Copyright (C) 1993-1996 by id Software, Inc.
7 //
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
11 //
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
15 // for more details.
16 //
17 // DESCRIPTION:
18 //	all external data is defined here
19 //	most of the data is loaded into different structures at run time
20 //	some internal structures shared by many modules are here
21 //
22 //-----------------------------------------------------------------------------
23 
24 #ifndef __DOOMDATA__
25 #define __DOOMDATA__
26 
27 // The most basic types we use, portability.
28 #include "doomtype.h"
29 
30 // Some global defines, that configure the game.
31 #include "doomdef.h"
32 #include "m_swap.h"
33 
34 //
35 // Map level types.
36 // The following data structures define the persistent format
37 // used in the lumps of the WAD files.
38 //
39 
40 // Lump order in a map WAD: each map needs a couple of lumps
41 // to provide a complete scene geometry description.
42 enum
43 {
44 	ML_LABEL, 			// A separator, name, ExMx or MAPxx
45 	ML_THINGS,			// Monsters, items
46 	ML_LINEDEFS,		// LineDefs, from editing
47 	ML_SIDEDEFS,		// SideDefs, from editing
48 	ML_VERTEXES,		// Vertices, edited and BSP splits generated
49 	ML_SEGS,			// LineSegs, from LineDefs split by BSP
50 	ML_SSECTORS,		// SubSectors, list of LineSegs
51 	ML_NODES, 			// BSP nodes
52 	ML_SECTORS,			// Sectors, from editing
53 	ML_REJECT,			// LUT, sector-sector visibility
54 	ML_BLOCKMAP,		// LUT, motion clipping, walls/grid element
55 	ML_BEHAVIOR,		// [RH] Hexen-style scripts. If present, THINGS
56 						//		and LINEDEFS are also Hexen-style.
57 	ML_CONVERSATION,	// Strife dialog (only for TEXTMAP format)
58 	ML_MAX,
59 
60 	// [RH] These are compressed (and extended) nodes. They combine the data from
61 	// vertexes, segs, ssectors, and nodes into a single lump.
62 	ML_ZNODES = ML_NODES,
63 	ML_GLZNODES = ML_SSECTORS,
64 
65 	// for text map format
66 	ML_TEXTMAP = ML_THINGS,
67 };
68 
69 
70 // A single Vertex.
71 struct mapvertex_t
72 {
73 	short x, y;
74 };
75 
76 // A SideDef, defining the visual appearance of a wall,
77 // by setting textures and offsets.
78 struct mapsidedef_t
79 {
80 	short	textureoffset;
81 	short	rowoffset;
82 	char	toptexture[8];
83 	char	bottomtexture[8];
84 	char	midtexture[8];
85 	short	sector;	// Front sector, towards viewer.
86 };
87 
88 struct intmapsidedef_t
89 {
90 	FString toptexture;
91 	FString bottomtexture;
92 	FString midtexture;
93 };
94 
95 
96 // A LineDef, as used for editing, and as input to the BSP builder.
97 struct maplinedef_t
98 {
99 	WORD	v1;
100 	WORD	v2;
101 	WORD	flags;
102 	short	special;
103 	short	tag;
104 	WORD	sidenum[2];	// sidenum[1] will be -1 if one sided
105 
106 } ;
107 
108 // [RH] Hexen-compatible LineDef.
109 struct maplinedef2_t
110 {
111 	WORD	v1;
112 	WORD	v2;
113 	WORD	flags;
114 	BYTE	special;
115 	BYTE	args[5];
116 	WORD	sidenum[2];
117 } ;
118 
119 
120 //
121 // LineDef attributes.
122 //
123 
124 enum ELineFlags
125 {
126 	ML_BLOCKING					=0x00000001,	// solid, is an obstacle
127 	ML_BLOCKMONSTERS			=0x00000002,	// blocks monsters only
128 	ML_TWOSIDED					=0x00000004,	// backside will not be present at all if not two sided
129 
130 	// If a texture is pegged, the texture will have
131 	// the end exposed to air held constant at the
132 	// top or bottom of the texture (stairs or pulled
133 	// down things) and will move with a height change
134 	// of one of the neighbor sectors.
135 	// Unpegged textures always have the first row of
136 	// the texture at the top pixel of the line for both
137 	// top and bottom textures (use next to windows).
138 
139 	ML_DONTPEGTOP				= 0x00000008,	// upper texture unpegged
140 	ML_DONTPEGBOTTOM			= 0x00000010,	// lower texture unpegged
141 	ML_SECRET					= 0x00000020,	// don't map as two sided: IT'S A SECRET!
142 	ML_SOUNDBLOCK				= 0x00000040,	// don't let sound cross two of these
143 	ML_DONTDRAW 				= 0x00000080,	// don't draw on the automap
144 	ML_MAPPED					= 0x00000100,	// set if already drawn in automap
145 	ML_REPEAT_SPECIAL			= 0x00000200,	// special is repeatable
146 
147 	ML_ADDTRANS					= 0x00000400,	// additive translucency (can only be set internally)
148 
149 	// Extended flags
150 	ML_MONSTERSCANACTIVATE		= 0x00002000,	// [RH] Monsters (as well as players) can activate the line
151 	ML_BLOCK_PLAYERS			= 0x00004000,
152 	ML_BLOCKEVERYTHING			= 0x00008000,	// [RH] Line blocks everything
153 	ML_ZONEBOUNDARY				= 0x00010000,
154 	ML_RAILING					= 0x00020000,
155 	ML_BLOCK_FLOATERS			= 0x00040000,
156 	ML_CLIP_MIDTEX				= 0x00080000,	// Automatic for every Strife line
157 	ML_WRAP_MIDTEX				= 0x00100000,
158 	ML_3DMIDTEX					= 0x00200000,
159 	ML_CHECKSWITCHRANGE			= 0x00400000,
160 	ML_FIRSTSIDEONLY			= 0x00800000,	// activated only when crossed from front side
161 	ML_BLOCKPROJECTILE			= 0x01000000,
162 	ML_BLOCKUSE					= 0x02000000,	// blocks all use actions through this line
163 	ML_BLOCKSIGHT				= 0x04000000,	// blocks monster line of sight
164 	ML_BLOCKHITSCAN				= 0x08000000,	// blocks hitscan attacks
165 	ML_3DMIDTEX_IMPASS			= 0x10000000,	// [TP] if 3D midtex, behaves like a height-restricted ML_BLOCKING
166 };
167 
168 
169 // Special activation types
170 enum SPAC
171 {
172 	SPAC_Cross = 1<<0,		// when player crosses line
173 	SPAC_Use = 1<<1,		// when player uses line
174 	SPAC_MCross = 1<<2,		// when monster crosses line
175 	SPAC_Impact = 1<<3,		// when projectile hits line
176 	SPAC_Push = 1<<4,		// when player pushes line
177 	SPAC_PCross = 1<<5,		// when projectile crosses line
178 	SPAC_UseThrough = 1<<6,	// when player uses line (doesn't block)
179 	// SPAC_PTOUCH is mapped to SPAC_PCross|SPAC_Impact
180 	SPAC_AnyCross = 1<<7,	// when anything without the MF2_TELEPORT flag crosses the line
181 	SPAC_MUse = 1<<8,		// monsters can use
182 	SPAC_MPush = 1<<9,		// monsters can push
183 	SPAC_UseBack = 1<<10,	// Can be used from the backside
184 
185 	SPAC_PlayerActivate = (SPAC_Cross|SPAC_Use|SPAC_Impact|SPAC_Push|SPAC_AnyCross|SPAC_UseThrough|SPAC_UseBack),
186 };
187 
188 enum EMapLineFlags	// These are flags that use different values internally
189 {
190 	// For Hexen format maps
191 	ML_SPAC_SHIFT				= 10,
192 	ML_SPAC_MASK				= 0x1c00,	// Hexen's activator mask.
193 
194 	// [RH] BOOM's ML_PASSUSE flag (conflicts with ML_REPEATSPECIAL)
195 	ML_PASSUSE_BOOM				= 0x0200,
196 	ML_3DMIDTEX_ETERNITY		= 0x0400,
197 
198 	// If this bit is set, then all non-original-Doom bits are cleared when
199 	// translating the line. Only applies when playing Doom with Doom-format maps.
200 	// Hexen format maps and the other games are not affected by this.
201 	ML_RESERVED_ETERNITY		= 0x0800,
202 
203 	// [RH] Extra flags for Strife
204 	ML_RAILING_STRIFE			= 0x0200,
205 	ML_BLOCK_FLOATERS_STRIFE	= 0x0400,
206 	ML_TRANSPARENT_STRIFE		= 0x0800,
207 	ML_TRANSLUCENT_STRIFE		= 0x1000,
208 };
209 
210 
GET_SPAC(int flags)211 static inline int GET_SPAC (int flags)
212 {
213 	return (flags&ML_SPAC_MASK) >> ML_SPAC_SHIFT;
214 }
215 
216 
217 
218 // Sector definition, from editing
219 struct mapsector_t
220 {
221 	short	floorheight;
222 	short	ceilingheight;
223 	char	floorpic[8];
224 	char	ceilingpic[8];
225 	short	lightlevel;
226 	short	special;
227 	short	tag;
228 };
229 
230 // SubSector, as generated by BSP
231 struct mapsubsector_t
232 {
233 	WORD	numsegs;
234 	WORD	firstseg;	// index of first one, segs are stored sequentially
235 };
236 
237 #pragma pack(1)
238 struct mapsubsector4_t
239 {
240 	WORD	numsegs;
241 	DWORD	firstseg;	// index of first one, segs are stored sequentially
242 };
243 #pragma pack()
244 
245 // LineSeg, generated by splitting LineDefs
246 // using partition lines selected by BSP builder.
247 struct mapseg_t
248 {
249 	WORD	v1;
250 	WORD	v2;
251 	SWORD	angle;
252 	WORD	linedef;
253 	SWORD	side;
254 	SWORD	offset;
255 
V1mapseg_t256 	int V1() { return LittleShort(v1); }
V2mapseg_t257 	int V2() { return LittleShort(v2); }
258 };
259 
260 struct mapseg4_t
261 {
262 	SDWORD v1;
263 	SDWORD v2;
264 	SWORD angle;
265 	WORD linedef;
266 	SWORD side;
267 	SWORD offset;
268 
V1mapseg4_t269 	int V1() { return LittleLong(v1); }
V2mapseg4_t270 	int V2() { return LittleLong(v2); }
271 };
272 
273 
274 
275 // BSP node structure.
276 
277 // Indicate a leaf.
278 
279 struct mapnode_t
280 {
281 	enum
282 	{
283 		NF_SUBSECTOR = 0x8000,
284 		NF_LUMPOFFSET = 0
285 	};
286 	SWORD 	x,y,dx,dy;	// partition line
287 	SWORD 	bbox[2][4];	// bounding box for each child
288 	// If NF_SUBSECTOR is or'ed in, it's a subsector,
289 	// else it's a node of another subtree.
290 	WORD 	children[2];
291 
Childmapnode_t292 	DWORD Child(int num) { return LittleShort(children[num]); }
293 };
294 
295 
296 struct mapnode4_t
297 {
298 	enum
299 	{
300 		NF_SUBSECTOR = 0x80000000,
301 		NF_LUMPOFFSET = 8
302 	};
303 	SWORD 	x,y,dx,dy;	// partition line
304 	SWORD 	bbox[2][4];	// bounding box for each child
305 	// If NF_SUBSECTOR is or'ed in, it's a subsector,
306 	// else it's a node of another subtree.
307 	DWORD 	children[2];
308 
Childmapnode4_t309 	DWORD Child(int num) { return LittleLong(children[num]); }
310 };
311 
312 
313 
314 // Thing definition, position, orientation and type,
315 // plus skill/visibility flags and attributes.
316 struct mapthing_t
317 {
318 	SWORD		x;
319 	SWORD		y;
320 	SWORD		angle;
321 	SWORD		type;
322 	SWORD		options;
323 };
324 
325 // [RH] Hexen-compatible MapThing.
326 struct mapthinghexen_t
327 {
328 	SWORD 		thingid;
329 	SWORD		x;
330 	SWORD		y;
331 	SWORD		z;
332 	SWORD		angle;
333 	SWORD		type;
334 	SWORD		flags;
335 	BYTE		special;
336 	BYTE		args[5];
337 };
338 
339 class FArchive;
340 struct FDoomEdEntry;
341 
342 // Internal representation of a mapthing
343 struct FMapThing
344 {
345 	int			thingid;
346 	fixed_t		x;
347 	fixed_t		y;
348 	fixed_t		z;
349 	short		angle;
350 	WORD		SkillFilter;
351 	WORD		ClassFilter;
352 	short		EdNum;
353 	FDoomEdEntry *info;
354 	DWORD		flags;
355 	int			special;
356 	int			args[5];
357 	int			Conversation;
358 	fixed_t		gravity;
359 	fixed_t		alpha;
360 	DWORD		fillcolor;
361 	fixed_t		scaleX;
362 	fixed_t		scaleY;
363 	int			health;
364 	int			score;
365 	short		pitch;
366 	short		roll;
367 	DWORD		RenderStyle;
368 	int			FloatbobPhase;
369 };
370 
371 
372 // [RH] MapThing flags.
373 
374 enum EMapThingFlags
375 {
376 	/*
377 	MTF_EASY			= 0x0001,	// The skill flags are no longer used directly.
378 	MTF_MEDIUM			= 0x0002,
379 	MTF_HARD			= 0x0004,
380 	*/
381 
382 	MTF_SKILLMASK		= 0x0007,
383 	MTF_SKILLSHIFT		= 1,		// Skill bits will be shifted 1 bit to the left to make room
384 									// for a bit representing the lowest skill (sk_baby)
385 
386 	MTF_AMBUSH			= 0x0008,	// Thing is deaf
387 	MTF_DORMANT			= 0x0010,	// Thing is dormant (use Thing_Activate)
388 	/*
389 	MTF_FIGHTER			= 0x0020,	// The class flags are no longer used directly.
390 	MTF_CLERIC			= 0x0040,
391 	MTF_MAGE			= 0x0080,
392 	*/
393 	MTF_CLASS_MASK		= 0x00e0,
394 	MTF_CLASS_SHIFT		= 5,
395 
396 	MTF_SINGLE			= 0x0100,	// Thing appears in single-player games
397 	MTF_COOPERATIVE		= 0x0200,	// Thing appears in cooperative games
398 	MTF_DEATHMATCH		= 0x0400,	// Thing appears in deathmatch games
399 
400 	MTF_SHADOW			= 0x0800,
401 	MTF_ALTSHADOW		= 0x1000,
402 	MTF_FRIENDLY		= 0x2000,
403 	MTF_STANDSTILL		= 0x4000,
404 	MTF_STRIFESOMETHING	= 0x8000,
405 
406 	MTF_SECRET			= 0x080000,	// Secret pickup
407 	MTF_NOINFIGHTING	= 0x100000,
408 
409 	// BOOM and DOOM compatible versions of some of the above
410 
411 	BTF_NOTSINGLE		= 0x0010,	// (TF_COOPERATIVE|TF_DEATHMATCH)
412 	BTF_NOTDEATHMATCH	= 0x0020,	// (TF_SINGLE|TF_COOPERATIVE)
413 	BTF_NOTCOOPERATIVE	= 0x0040,	// (TF_SINGLE|TF_DEATHMATCH)
414 	BTF_FRIENDLY		= 0x0080,	// MBF friendly monsters
415 	BTF_BADEDITORCHECK	= 0x0100,	// for detecting bad (Mac) editors
416 
417 	// Strife thing flags
418 
419 	STF_STANDSTILL		= 0x0008,
420 	STF_AMBUSH			= 0x0020,
421 	STF_FRIENDLY		= 0x0040,
422 	STF_SHADOW			= 0x0100,
423 	STF_ALTSHADOW		= 0x0200,
424 };
425 
426 // A simplified mapthing for player starts
427 struct FPlayerStart
428 {
429 	fixed_t x, y, z;
430 	short angle, type;
431 
FPlayerStartFPlayerStart432 	FPlayerStart() { }
FPlayerStartFPlayerStart433 	FPlayerStart(const FMapThing *mthing, int pnum)
434 	: x(mthing->x), y(mthing->y), z(mthing->z),
435 	  angle(mthing->angle),
436 	  type(pnum)
437 	{ }
438 };
439 // Player spawn spots for deathmatch.
440 extern TArray<FPlayerStart> deathmatchstarts;
441 
442 // Player spawn spots.
443 extern FPlayerStart playerstarts[MAXPLAYERS];
444 extern TArray<FPlayerStart> AllPlayerStarts;
445 
446 
447 #endif					// __DOOMDATA__
448