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
|
/* Emacs style mode select -*- C++ -*-
*-----------------------------------------------------------------------------
*
*
* PrBoom a Doom port merged with LxDoom and LSDLDoom
* based on BOOM, a modified and improved DOOM engine
* Copyright (C) 1999 by
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
* Copyright (C) 1999-2000 by
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
*
* 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.
*
* DESCRIPTION:
* WAD I/O functions.
*
*-----------------------------------------------------------------------------*/
#ifndef __W_WAD__
#define __W_WAD__
#ifdef __GNUG__
#pragma interface
#endif
#include "m_fixed.h"
//
// TYPES
//
typedef struct
{
char identification[4]; // Should be "IWAD" or "PWAD".
int numlumps;
int infotableofs;
} wadinfo_t;
typedef struct
{
int filepos;
int size;
char name[8];
} filelump_t;
#ifndef ALL_IN_ONE
// NO_PREDEFINED_LUMPS causes none of the predefined lumps in info.c to be
// included, and removes all extra code which is only there for them
// Saves a little memory normally, lots if any were overridden, and makes
// the executable smaller
#define NO_PREDEFINED_LUMPS
#endif
//
// WADFILE I/O related stuff.
//
// CPhipps - defined enum in wider scope
// Ty 08/29/98 - add source field to identify where this lump came from
typedef enum {
// CPhipps - define elements in order of 'how new/unusual'
source_iwad=0, // iwad file load
source_pre, // predefined lump
source_auto_load, // lump auto-loaded by config file
source_pwad, // pwad file load
source_lmp, // lmp file load
source_net // CPhipps
} wad_source_t;
typedef struct
{
// WARNING: order of some fields important (see info.c).
char name[8];
int size;
#ifndef NO_PREDEFINED_LUMPS
const void *data; // killough 1/31/98: points to predefined lump data
#endif
// killough 1/31/98: hash table fields, used for ultra-fast hash table lookup
int index, next;
// killough 4/17/98: namespace tags, to prevent conflicts between resources
enum {
ns_global=0,
ns_sprites,
ns_flats,
ns_colormaps
} namespace;
int handle;
int position;
unsigned int locks; // CPhipps - wad lump locking
wad_source_t source;
} lumpinfo_t;
// killough 1/31/98: predefined lumps
extern const size_t num_predefined_lumps;
extern const lumpinfo_t predefined_lumps[];
extern void **lumpcache;
extern lumpinfo_t *lumpinfo;
extern int numlumps;
// CPhipps - changed wad init
// We _must_ have the wadfiles[] the same as those actually loaded, so there
// is no point having these separate entities. This belongs here.
struct wadfile_info {
const char* name;
wad_source_t src;
};
extern struct wadfile_info *wadfiles;
extern size_t numwadfiles; // CPhipps - size of the wadfiles array
void W_Init(void); // CPhipps - uses the above array
// killough 4/17/98: if W_CheckNumForName() called with only
// one argument, pass ns_global as the default namespace
#define W_CheckNumForName(name) (W_CheckNumForName)(name, ns_global)
int (W_CheckNumForName)(const char* name, int); // killough 4/17/98
int W_GetNumForName (const char* name);
int W_LumpLength (int lump);
void W_ReadLump (int lump, void *dest);
// CPhipps - modified for 'new' lump locking
void* W_CacheLumpNum (int lump, unsigned short locks);
void W_UnlockLumpNum(int lump, signed short unlocks);
/* cph - special version to return lump with padding, for sound lumps */
void * W_CacheLumpNumPadded(int lump, size_t len, unsigned char pad);
// CPhipps - convenience macros
#define W_CacheLumpNum(num) (W_CacheLumpNum)((num),1)
#define W_CacheLumpName(name) W_CacheLumpNum (W_GetNumForName(name))
#define W_UnlockLumpNum(num) (W_UnlockLumpNum)((num),1)
#define W_UnlockLumpName(name) W_UnlockLumpNum (W_GetNumForName(name))
char *AddDefaultExtension(char *, const char *); // killough 1/18/98
void ExtractFileBase(const char *, char *); // killough
unsigned W_LumpNameHash(const char *s); // killough 1/31/98
// Function to write all predefined lumps to a PWAD if requested
extern void WritePredefinedLumpWad(const char *filename); // jff 5/6/98
#endif
|