1 /*
2  *	wstructs.h
3  *	Wad files data structures.
4  *	BW & RQ sometime in 1993 or 1994.
5  *	FIXME this file should also contain the definitions for
6  *	the wad header and directory entry which are currently
7  *	in yadex.h.
8  */
9 
10 
11 /*
12 This file is part of Yadex.
13 
14 Yadex incorporates code from DEU 5.21 that was put in the public domain in
15 1994 by Rapha�l Quinet and Brendon Wyber.
16 
17 The rest of Yadex is Copyright � 1997-2003 Andr� Majorel and others.
18 
19 This program is free software; you can redistribute it and/or modify it under
20 the terms of the GNU General Public License as published by the Free Software
21 Foundation; either version 2 of the License, or (at your option) any later
22 version.
23 
24 This program is distributed in the hope that it will be useful, but WITHOUT
25 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
26 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
27 
28 You should have received a copy of the GNU General Public License along with
29 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
30 Place, Suite 330, Boston, MA 02111-1307, USA.
31 */
32 
33 
34 #ifndef YH_WSTRUCTS	// To prevent multiple inclusion
35 #define YH_WSTRUCTS	// To prevent multiple inclusion
36 
37 
38 // FIXME: all identifiers should start with wad_ or WAD_...
39 
40 
41 // Directory
42 const size_t WAD_NAME = 8;		// Length of a directory entry name
43 typedef char wad_name_t[WAD_NAME];
44 typedef struct Directory huge *DirPtr;
45 struct Directory
46 {
47   i32        start;			// Offset to start of data
48   i32        size;			// Byte size of data
49   wad_name_t name;			// Name of data block
50 };
51 
52 
53 // Textures
54 const size_t WAD_TEX_NAME = 8;
55 typedef char wad_tex_name_t[WAD_TEX_NAME];
56 
57 
58 // Flats
59 const size_t WAD_FLAT_NAME = WAD_NAME;
60 typedef char wad_flat_name_t[WAD_FLAT_NAME];
61 
62 
63 // Pictures (sprites and patches)
64 const size_t WAD_PIC_NAME = WAD_NAME;
65 typedef char wad_pic_name_t[WAD_TEX_NAME];
66 
67 
68 // Level objects properties
69 typedef i16 wad_coord_t;		// Map (X,Y) coordinates
70 typedef i16 wad_ldn_t;			// Linedef#
71 typedef i16 wad_sdn_t;			// Sidedef#
72 typedef i16 wad_sn_t;			// Sector#
73 typedef i16 wad_tag_t;			// Tag
74 typedef i16 wad_tn_t;			// Thing# (theor. there might be more)
75 typedef i16 wad_vn_t;			// Vertex#
76 typedef i16 wad_z_t;			// Map Z coordinate
77 
78 
79 // Things
80 const size_t WAD_THING_BYTES       = 10;  // Size in the wad file
81 const size_t WAD_HEXEN_THING_BYTES = 20;  // Size in the wad file
82 typedef i16 wad_ttype_t;
83 typedef i16 wad_tangle_t;
84 typedef i16 wad_tflags_t;
85 struct Thing
86 {
87   wad_coord_t      xpos;		// FIXME rename to "x"
88   wad_coord_t      ypos;		// FIXME rename to "y"
89   wad_tangle_t     angle;
90   wad_ttype_t      type;
91   wad_tflags_t     when;		// FIXME rename to "flags"
92 };
93 typedef struct
94 {
95   i16              tid;
96   wad_coord_t      x;
97   wad_coord_t      y;
98   wad_z_t          height;
99   wad_tangle_t     angle;
100   wad_ttype_t      type;
101   i16              options;
102   u8               special;
103   u8               arg1;
104   u8               arg2;
105   u8               arg3;
106   u8               arg4;
107   u8               arg5;
108 } wad_hexen_thing_t;
109 typedef struct Thing huge *TPtr;
110 
111 
112 // Linedefs
113 const size_t WAD_LINEDEF_BYTES       = 14;  // Size in the wad file
114 const size_t WAD_HEXEN_LINEDEF_BYTES = 16;  // Size in the wad file
115 typedef i16 wad_ldflags_t;
116 typedef i16 wad_ldtype_t;
117 struct LineDef
118 {
119   wad_vn_t      start;			// # of start vertex
120   wad_vn_t      end;			// # of end vertex
121   wad_ldflags_t flags;
122   wad_ldtype_t  type;
123   wad_tag_t     tag;
124   wad_sdn_t     sidedef1;		// # of first (right) sidedef
125   wad_sdn_t     sidedef2;		// # of second (left) sidedef or 0xffff
126 };
127 typedef struct
128 {
129   wad_vn_t      start;
130   wad_vn_t      end;
131   wad_ldflags_t flags;
132   u8            type;
133   u8            arg1;
134   u8            arg2;
135   u8            arg3;
136   u8            arg4;
137   u8            arg5;
138   wad_sdn_t     sidedef1;
139   wad_sdn_t     sidedef2;
140 } wad_hexen_linedef_t;
141 typedef struct LineDef huge *LDPtr;
142 
143 
144 // Sidedefs
145 const size_t WAD_SIDEDEF_BYTES = 30;	// Size in the wad file
146 struct SideDef
147 {
148   wad_coord_t    xoff;			// FIXME rename to "xofs"
149   wad_coord_t    yoff;			// FIXME rename to "yofs"
150   wad_tex_name_t tex1;			// Name of upper texture
151   wad_tex_name_t tex2;			// Name of lower texture
152   wad_tex_name_t tex3;			// Name of middle texture
153   wad_sn_t       sector;		// # of adjacent sector
154 };
155 // (it's the same for Hexen)
156 typedef struct SideDef huge *SDPtr;
157 
158 
159 // Vertices
160 const size_t WAD_VERTEX_BYTES = 4;	// Size in the wad file
161 struct Vertex
162 {
163   wad_coord_t x;
164   wad_coord_t y;
165 };
166 // (it's the same for Hexen)
167 typedef struct Vertex huge *VPtr;
168 
169 
170 // Sectors
171 const size_t WAD_SECTOR_BYTES = 26;	// Size in the wad file
172 typedef i16 wad_stype_t;
173 struct Sector
174 {
175   wad_z_t         floorh;		// Floor height
176   wad_z_t         ceilh;		// Ceiling height
177   wad_flat_name_t floort;		// Name of floor texture
178   wad_flat_name_t ceilt;		// Name of ceiling texture
179   i16             light;		// Light level (0-255)
180   wad_stype_t     special;		// FIXME rename to "type"
181   wad_tag_t       tag;
182 };
183 typedef struct Sector huge *SPtr;
184 
185 
186 // The 11 lumps that constitute a Doom/Heretic/Strife level
187 typedef enum
188 {
189   WAD_LL_LABEL,
190   WAD_LL_THINGS,
191   WAD_LL_LINEDEFS,
192   WAD_LL_SIDEDEFS,
193   WAD_LL_VERTEXES,
194   WAD_LL_SEGS,
195   WAD_LL_SSECTORS,
196   WAD_LL_NODES,
197   WAD_LL_SECTORS,
198   WAD_LL_REJECT,
199   WAD_LL_BLOCKMAP,
200 		      // Hexen has a BEHAVIOR lump here
201   WAD_LL__
202 } wad_level_lump_no_t;
203 
204 typedef struct
205 {
206   const char *const name;
207   size_t item_size;
208 } wad_level_lump_def_t;
209 
210 const wad_level_lump_def_t wad_level_lump[WAD_LL__] =
211 {
212   { 0,          0                 },  // Label -- no fixed name
213   { "THINGS",   WAD_THING_BYTES   },
214   { "LINEDEFS", WAD_LINEDEF_BYTES },
215   { "SIDEDEFS", WAD_SIDEDEF_BYTES },
216   { "VERTEXES", WAD_VERTEX_BYTES  },
217   { "SEGS",     0                 },
218   { "SSECTORS", 0                 },
219   { "NODES",    0                 },
220   { "SECTORS",  WAD_SECTOR_BYTES  },
221   { "REJECT",   0                 },
222   { "BLOCKMAP", 0                 }
223 				      // Hexen has a BEHAVIOR lump here
224 };
225 
226 
227 #endif  /* DO NOT ADD ANYTHING AFTER THIS LINE */
228