1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
/*
viDOOM - level editor for DOOM
Copyright (C) 2000 Ian Cowburn (ianc@noddybox.demon.co.uk)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-------------------------------------------------------------------------
WAD file definitions and readers
These things should be noted about the handling of mutiple entries
from different wad files:
- Entries in later WADs overwrite earlier loaded WADs.
- New entries for MAPxy and ExMy automatically overwrite the
following entries from the previous map:
THINGS
LINEDEFS
SIDEDEFS
VERTEXES
SEGS
SSECTORS
NODES
SECTORS
REJECT
BLOCKMAP
If these entries don't appear in the new map they are
replaced by dummy entries of zero length.
$Id$
*/
#ifndef _WAD_H
#define _WAD_H
#include "map.h"
#include "list.h"
/* Basic WAD types
*/
#define DIRNAME_LEN 8
typedef char DirName[DIRNAME_LEN+1];
/* Directory types
*/
typedef struct WadDir
{
char *wad; /* WAD the entry is from */
DirName name; /* Lump name */
Long off; /* Lump offset */
Long size; /* Lump size */
} WadDir;
/* Base level types and their sizes in the WAD
*/
#define THING_SIZE (sizeof(Short)*5)
typedef struct Thing
{
Short x;
Short y;
Short ang;
Short type;
Short opt;
} Thing;
#define VERTEX_SIZE (sizeof(Short)*2)
typedef struct Vertex
{
Short x;
Short y;
} Vertex;
#define SIDEDEF_SIZE (sizeof(Short)*3+DIRNAME_LEN*3)
typedef struct Sidedef
{
Short x;
Short y;
DirName upper;
DirName lower;
DirName middle;
Short sector;
} Sidedef;
#define LINEDEF_SIZE (sizeof(Short)*7)
typedef struct
{
Short from;
Short to;
Short flags;
Short type;
Short tag;
Short right;
Short left;
} Linedef;
#define SECTOR_SIZE (sizeof(Short)*5+DIRNAME_LEN*2)
typedef struct Sector
{
Short floor;
Short ceiling;
DirName floor_t;
DirName ceiling_t;
Short light;
Short special;
Short tag;
} Sector;
typedef struct WadMap
{
Map thing;
Map vertex;
Map linedef;
Map sidedef;
Map sector;
} WadMap;
/* Error codes
*/
#define WAD_OK 0
#define WAD_FILE_NOT_FOUND 1
#define WAD_NOT_WAD 2
#define WAD_NOT_IWAD 3
#define WAD_NOT_PWAD 4
#define WAD_MAP_NOT_FOUND 5
#define WAD_LUMP_NOT_FOUND 6
#define WAD_COULD_NOT_CREATE 7
#define WAD_BROKEN 8 /* Must be last error code */
#define WAD_NOERROR (WAD_BROKEN+1)
/* Add the named IWAD to the list of open WADs. Returns non-zero on error.
*/
int AddIWAD(char *wad);
/* Add the named PWAD to the list of open WADs. Returns non-zero on error.
AddPWAD() and AddIWAD() are by and large identical - they just include
different checking so that the initial loading of IWAD will not allow it
be a PWAD, and also do shareware checking.
*/
int AddPWAD(char *wad);
/* Close a wad from the open list. Removes entries for this wad fom the
global directory, replacing entries from prevous WADs (if any).
Returns non-zero on error.
*/
int CloseWad(char *wad);
/* Returns a list of open WADS as a string like "<wad>|<wad>|..". The return
must be Release()ed after use.
*/
char *OpenWads(void);
/* If you wish access to the directory of all the open wads, this allows
them to retrieved as a List of WadDir. Returns NULL if none.
Note the directory is organised with the last loaded WAD files first.
This is the quickest (though hungriest) method for ensuring that later
WAD resources override earlier ones.
*/
Iterator GetWadDir(void);
/* No of entries in WadDir list
*/
int GetWadDirSize(void);
/* Retrieves the named lump from the WADs. Return is a pointer to size
bytes. If size is NULL it is not set.
The pointer must be Release()'ed by the user afterwards.
NULL indicates the lump could not be found.
*/
void *GetLump(char *name, Long *size);
/* Load a MAPxx or ExMy map from the open wads. Returns NULL on error.
*/
WadMap *LoadMap(char *name);
/* Create a new empty map
*/
WadMap *NewMap(void);
/* Release the memory for a WadMap
*/
WadMap *ClearMap(WadMap *map);
/* Save the passed WadMap as a MAPxx or ExMy PWAD. Note that this PWAD is
overwritten and the map is the sole object written to the PWAD. Returns
non-zero on error.
*/
int SaveMap(WadMap *map, char *name, char *wad);
/* Return the current error code
*/
int WadError(void);
/* Return a string for the error code
*/
const char *WadErrorString(void);
#endif
/* END OF FILE */
|