Debian Codegraph @

prboom2/src/w_wad.h

raw
1 /* Emacs style mode select -*- C -*-
2 *-----------------------------------------------------------------------------
3 *
4 *
5 * PrBoom: a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11 * Copyright 2005, 2006 by
12 * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 * 02111-1307, USA.
28 *
29 * DESCRIPTION:
30 * WAD I/O functions.
31 *
32 *-----------------------------------------------------------------------------*/
33
34
35 #ifndef __W_WAD__
36 #define __W_WAD__
37
38 #include <stddef.h>
39
40 //
41 // TYPES
42 //
43
44 typedef struct
45 {
46 char identification[4]; // Should be "IWAD" or "PWAD".
47 int numlumps;
48 int infotableofs;
49 } wadinfo_t;
50
51 typedef struct
52 {
53 int filepos;
54 int size;
55 char name[8];
56 } filelump_t;
57
58 #define LUMP_NOT_FOUND -1
59
60 //
61 // WADFILE I/O related stuff.
62 //
63
64 // CPhipps - defined enum in wider scope
65 // Ty 08/29/98 - add source field to identify where this lump came from
66 typedef enum {
67 source_skip = -1,
68 source_iwad=0, // iwad file load
69 source_pre, // predefined lump
70 source_auto_load, // lump auto-loaded by config file
71 source_pwad, // pwad file load
72 source_lmp, // lmp file load
73 source_net // CPhipps
74
75 //e6y
76 // ,source_deh_auto_load
77 ,source_deh
78 ,source_err
79
80 } wad_source_t;
81
82 // CPhipps - changed wad init
83 // We _must_ have the wadfiles[] the same as those actually loaded, so there
84 // is no point having these separate entities. This belongs here.
85 typedef struct {
86 char* name;
87 wad_source_t src;
88 int handle;
89 } wadfile_info_t;
90
91 extern wadfile_info_t *wadfiles;
92
93 extern size_t numwadfiles; // CPhipps - size of the wadfiles array
94
95 extern int MainLumpCache;
96
97 void W_Init(void); // CPhipps - uses the above array
98 void W_InitCache(void);
99 void W_DoneCache(void);
100 void W_Shutdown(void);
101 void dsda_ResetInitLumpCache(void);
102
103 typedef enum
104 {
105 ns_global=0,
106 ns_sprites,
107 ns_flats,
108 ns_colormaps,
109 ns_prboom,
110 ns_demos,
111 ns_hires,
112 } li_namespace_e; // haleyjd 05/21/02: renamed from "namespace"
113
114 typedef struct
115 {
116 // WARNING: order of some fields important (see info.c).
117
118 char name[9];
119 int size;
120
121 // killough 1/31/98: hash table fields, used for ultra-fast hash table lookup
122 int index, next;
123
124 // killough 4/17/98: namespace tags, to prevent conflicts between resources
125 li_namespace_e li_namespace; // haleyjd 05/21/02: renamed from "namespace"
126
127 wadfile_info_t *wadfile;
128 int position;
129 wad_source_t source;
130 int flags; //e6y
131 } lumpinfo_t;
132
133 // e6y: lump flags
134 #define LUMP_STATIC 0x00000001 /* assigned gltexture should be static */
135 #define LUMP_PRBOOM 0x00000002 /* from internal resource */
136
137 extern lumpinfo_t *lumpinfo;
138 extern int numlumps;
139
140 int W_FindNumFromName2(const char *name, int ns, int lump);
141
142 static inline
143 int W_FindNumFromName(const char *name, int lump)
144 { return W_FindNumFromName2(name, ns_global, lump); }
145
146 static inline
147 int W_CheckNumForName2(const char *name, int ns)
148 { return W_FindNumFromName2(name, ns, LUMP_NOT_FOUND); }
149
150 static inline
151 int W_CheckNumForName(const char *name)
152 { return W_CheckNumForName2(name, ns_global); }
153
154 int W_CheckNumForNameInternal(const char *name);
155 int W_ListNumFromName(const char *name, int lump);
156 int W_GetNumForName (const char* name);
157 const lumpinfo_t* W_GetLumpInfoByNum(int lump);
158 int W_LumpLength (int lump);
159 int W_SafeLumpLength (int lump);
160 const char *W_LumpName(int lump);
161 void W_ReadLump (int lump, void *dest);
162 char* W_ReadLumpToString (int lump);
163 // CPhipps - modified for 'new' lump locking
164 const void* W_SafeLumpByNum (int lump);
165 const void* W_LumpByNum (int lump);
166 const void* W_LockLumpNum(int lump);
167 void *W_GetModifiableLumpData(int lump);
168
169 int W_LumpNumExists(int lump);
170 int W_LumpNameExists(const char *name);
171 int W_LumpNameExists2(const char *name, int ns);
172 int W_PWADLumpNumExists(int lump);
173 int W_PWADLumpNameExists(const char *name);
174 int W_PWADMapExists(void);
175
176 // CPhipps - convenience macros
177 //#define W_LumpByNum(num) (W_LumpByNum)((num),1)
178 #define W_LumpByName(name) W_LumpByNum (W_GetNumForName(name))
179
180 char *AddDefaultExtension(char *, const char *); // killough 1/18/98
181 void ExtractFileBase(const char *, char *); // killough
182 unsigned W_LumpNameHash(const char *s); // killough 1/31/98
183 void W_HashLumps(void); // cph 2001/07/07 - made public
184 int W_LumpNumInPortWad(int lump);
185
186 #endif