~ubuntu-branches/ubuntu/natty/glbsp/natty

« back to all changes in this revision

Viewing changes to src/wad.h

  • Committer: Bazaar Package Importer
  • Author(s): Darren Salt
  • Date: 2008-01-30 13:33:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130133349-kgojg33vyiu8xbvp
Tags: 2.24-1
* New upstream release.
* Bumped the lib soname and the library package name due to one silly
  little binary incompatibility caused by changes in an exported struct.
  (Safe; nothing else currently in the archive has ever used libglbsp2.)
* Removed my patches since they're all applied upstream.
* Updated the list of documentation files.
* Build-time changes:
  - Switched from dh_movefiles to dh_install.
  - Updated my makefile to cope with upstream changes.
  - Corrected for debian-rules-ignores-make-clean-error.
  - Corrected for substvar-source-version-is-deprecated.
  - Link libglbsp, rather than glbsp, with libm and libz.
* Fixed shlibdeps. (Closes: #460387)
* Bumped standards version to 3.7.3 (no other changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------
 
2
// WAD : WAD read/write functions.
 
3
//------------------------------------------------------------------------
 
4
//
 
5
//  GL-Friendly Node Builder (C) 2000-2007 Andrew Apted
 
6
//
 
7
//  Based on 'BSP 2.3' by Colin Reed, Lee Killough and others.
 
8
//
 
9
//  This program is free software; you can redistribute it and/or
 
10
//  modify it under the terms of the GNU General Public License
 
11
//  as published by the Free Software Foundation; either version 2
 
12
//  of the License, or (at your option) any later version.
 
13
//
 
14
//  This program is distributed in the hope that it will be useful,
 
15
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
//  GNU General Public License for more details.
 
18
//
 
19
//------------------------------------------------------------------------
 
20
 
 
21
#ifndef __GLBSP_WAD_H__
 
22
#define __GLBSP_WAD_H__
 
23
 
 
24
#include "structs.h"
 
25
#include "system.h"
 
26
 
 
27
 
 
28
struct lump_s;
 
29
 
 
30
 
 
31
// wad header
 
32
 
 
33
typedef struct wad_s
 
34
{
 
35
  // kind of wad file
 
36
  enum { IWAD, PWAD } kind;
 
37
 
 
38
  // number of entries in directory
 
39
  int num_entries;
 
40
 
 
41
  // offset to start of directory
 
42
  int dir_start;
 
43
 
 
44
  // current directory entries
 
45
  struct lump_s *dir_head;
 
46
  struct lump_s *dir_tail;
 
47
 
 
48
  // current level
 
49
  struct lump_s *current_level;
 
50
 
 
51
  // array of level names found
 
52
  const char ** level_names;
 
53
  int num_level_names;
 
54
}
 
55
wad_t;
 
56
 
 
57
 
 
58
// level information
 
59
 
 
60
typedef struct level_s
 
61
{
 
62
  // various flags
 
63
  int flags;
 
64
 
 
65
  // the child lump list
 
66
  struct lump_s *children;
 
67
 
 
68
  // for normal levels, this is the associated GL level lump
 
69
  struct lump_s *buddy;
 
70
 
 
71
  // information on overflow
 
72
  int soft_limit;
 
73
  int hard_limit;
 
74
  int v5_switch;
 
75
}
 
76
level_t;
 
77
 
 
78
/* this level information holds GL lumps */
 
79
#define LEVEL_IS_GL      0x0002
 
80
 
 
81
/* limit flags, to show what went wrong */
 
82
#define LIMIT_VERTEXES     0x000001
 
83
#define LIMIT_SECTORS      0x000002
 
84
#define LIMIT_SIDEDEFS     0x000004
 
85
#define LIMIT_LINEDEFS     0x000008
 
86
 
 
87
#define LIMIT_SEGS         0x000010
 
88
#define LIMIT_SSECTORS     0x000020
 
89
#define LIMIT_NODES        0x000040
 
90
 
 
91
#define LIMIT_GL_VERT      0x000100
 
92
#define LIMIT_GL_SEGS      0x000200
 
93
#define LIMIT_GL_SSECT     0x000400
 
94
#define LIMIT_GL_NODES     0x000800
 
95
 
 
96
#define LIMIT_BAD_SIDE     0x001000
 
97
#define LIMIT_BMAP_TRUNC   0x002000
 
98
#define LIMIT_BLOCKMAP     0x004000
 
99
#define LIMIT_ZDBSP        0x008000
 
100
 
 
101
 
 
102
// directory entry
 
103
 
 
104
typedef struct lump_s
 
105
{
 
106
  // link in list
 
107
  struct lump_s *next;
 
108
  struct lump_s *prev;
 
109
 
 
110
  // name of lump
 
111
  char *name;
 
112
 
 
113
  // offset to start of lump
 
114
  int start;
 
115
  int new_start;
 
116
 
 
117
  // length of lump
 
118
  int length;
 
119
  int space;
 
120
 
 
121
  // various flags
 
122
  int flags;
 
123
 
 
124
  // data of lump
 
125
  void *data;
 
126
 
 
127
  // level information, usually NULL
 
128
  level_t *lev_info;
 
129
}
 
130
lump_t;
 
131
 
 
132
/* this lump should be copied from the input wad */
 
133
#define LUMP_COPY_ME       0x0004
 
134
 
 
135
/* this lump shouldn't be written to the output wad */
 
136
#define LUMP_IGNORE_ME     0x0008
 
137
 
 
138
/* this lump needs to be loaded */
 
139
#define LUMP_READ_ME       0x0100
 
140
 
 
141
/* this lump is new (didn't exist in the original) */
 
142
#define LUMP_NEW           0x0200
 
143
 
 
144
 
 
145
/* ----- function prototypes --------------------- */
 
146
 
 
147
// check if the filename has the given extension.  Returns 1 if yes,
 
148
// otherwise zero.
 
149
//
 
150
int CheckExtension(const char *filename, const char *ext);
 
151
 
 
152
// remove any extension from the given filename, and add the given
 
153
// extension, and return the newly creating filename.
 
154
//
 
155
char *ReplaceExtension(const char *filename, const char *ext);
 
156
 
 
157
// open the input wad file and read the contents into memory.  When
 
158
// 'load_all' is false, lumps other than level info will be marked as
 
159
// copyable instead of loaded.
 
160
//
 
161
// Returns GLBSP_E_OK if all went well, otherwise an error code (in
 
162
// which case cur_comms->message has been set and all files/memory
 
163
// have been freed).
 
164
//
 
165
glbsp_ret_e ReadWadFile(const char *filename);
 
166
 
 
167
// open the output wad file and write the contents.  Any lumps marked
 
168
// as copyable will be copied from the input file instead of from
 
169
// memory.  Lumps marked as ignorable will be skipped.
 
170
//
 
171
// Returns GLBSP_E_OK if all went well, otherwise an error code (in
 
172
// which case cur_comms->message has been set -- but no files/memory
 
173
// are freed).
 
174
//
 
175
glbsp_ret_e WriteWadFile(const char *filename);
 
176
 
 
177
// close all wad files and free any memory.
 
178
void CloseWads(void);
 
179
 
 
180
// delete the GWA file that is associated with the given normal
 
181
// wad file.  It doesn't have to exist.
 
182
//
 
183
void DeleteGwaFile(const char *base_wad_name);
 
184
 
 
185
// returns the number of levels found in the wad.
 
186
int CountLevels(void);
 
187
 
 
188
// find the next level lump in the wad directory, and store the
 
189
// reference in 'wad.current_level'.  Call this straight after
 
190
// ReadWadFile() to get the first level.  Returns 1 if found,
 
191
// otherwise 0 if there are no more levels in the wad.
 
192
//
 
193
int FindNextLevel(void);
 
194
 
 
195
// return the current level name
 
196
const char *GetLevelName(void);
 
197
 
 
198
// find the level lump with the given name in the current level, and
 
199
// return a reference to it.  Returns NULL if no such lump exists.
 
200
// Level lumps are always present in memory (i.e. never marked
 
201
// copyable).
 
202
//
 
203
lump_t *FindLevelLump(const char *name);
 
204
 
 
205
// tests if the level lump contains nothing but zeros.
 
206
int CheckLevelLumpZero(lump_t *lump);
 
207
 
 
208
// create a new lump in the current level with the given name.  If
 
209
// such a lump already exists, it is truncated to zero length.
 
210
//
 
211
lump_t *CreateLevelLump(const char *name);
 
212
lump_t *CreateGLLump(const char *name);
 
213
 
 
214
// append some raw data to the end of the given level lump (created
 
215
// with the above function).
 
216
//
 
217
void AppendLevelLump(lump_t *lump, const void *data, int length);
 
218
 
 
219
// for the current GL lump, add a keyword/value pair into the
 
220
// level marker lump.
 
221
void AddGLTextLine(const char *keyword, const char *value);
 
222
 
 
223
// Zlib compression support
 
224
void ZLibBeginLump(lump_t *lump);
 
225
void ZLibAppendLump(const void *data, int length);
 
226
void ZLibFinishLump(void);
 
227
 
 
228
// mark the fact that this level failed to build.
 
229
void MarkSoftFailure(int soft);
 
230
void MarkHardFailure(int hard);
 
231
void MarkV5Switch(int v5);
 
232
void MarkZDSwitch(void);
 
233
 
 
234
// alert the user if any levels failed to build properly.
 
235
void ReportFailedLevels(void);
 
236
 
 
237
 
 
238
/* ----- conversion macros ----------------------- */
 
239
 
 
240
 
 
241
#define UINT8(x)   ((uint8_g) (x))
 
242
#define SINT8(x)   ((sint8_g) (x))
 
243
 
 
244
#define UINT16(x)  Endian_U16(x)
 
245
#define UINT32(x)  Endian_U32(x)
 
246
 
 
247
#define SINT16(x)  ((sint16_g) Endian_U16((uint16_g) (x)))
 
248
#define SINT32(x)  ((sint32_g) Endian_U32((uint32_g) (x)))
 
249
 
 
250
 
 
251
#endif /* __GLBSP_WAD_H__ */