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 #ifdef __GNUG__ 39 #pragma interface 40 #endif 41 42 // 43 // TYPES 44 // 45 46 typedef struct 47 { 48 char identification[4]; // Should be "IWAD" or "PWAD". 49 int numlumps; 50 int infotableofs; 51 } wadinfo_t; 52 53 typedef struct 54 { 55 int filepos; 56 int size; 57 char name[8]; 58 } filelump_t; 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 // CPhipps - define elements in order of 'how new/unusual' 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 void W_Init(void); // CPhipps - uses the above array 96 void W_ReleaseAllWads(void); // Proff - Added for iwad switching 97 void W_InitCache(void); 98 void W_DoneCache(void); 99 100 typedef enum 101 { 102 ns_global=0, 103 ns_sprites, 104 ns_flats, 105 ns_colormaps, 106 ns_prboom, 107 ns_demos, 108 ns_hires //e6y 109 } li_namespace_e; // haleyjd 05/21/02: renamed from "namespace" 110 111 typedef struct 112 { 113 // WARNING: order of some fields important (see info.c). 114 115 char name[9]; 116 int size; 117 118 // killough 1/31/98: hash table fields, used for ultra-fast hash table lookup 119 int index, next; 120 121 // killough 4/17/98: namespace tags, to prevent conflicts between resources 122 li_namespace_e li_namespace; // haleyjd 05/21/02: renamed from "namespace" 123 124 wadfile_info_t *wadfile; 125 int position; 126 wad_source_t source; 127 int flags; //e6y 128 } lumpinfo_t; 129 130 // e6y: lump flags 131 #define LUMP_STATIC 0x00000001 /* assigned gltexture should be static */ 132 #define LUMP_CM2RGB 0x00000002 /* for fake colormap for hires patches */ 133 134 extern lumpinfo_t *lumpinfo; 135 extern int numlumps; 136 137 // killough 4/17/98: if W_CheckNumForName() called with only 138 // one argument, pass ns_global as the default namespace 139 140 #define W_CheckNumForName(name) (W_CheckNumForName)(name, ns_global) 141 int (W_CheckNumForName)(const char* name, li_namespace_e); // killough 4/17/98 142 int W_GetNumForName (const char* name); 143 const lumpinfo_t* W_GetLumpInfoByNum(int lump); 144 int W_SafeGetNumForName (const char* name); //e6y 145 int W_LumpLength (int lump); 146 void W_ReadLump (int lump, void *dest); 147 // CPhipps - modified for 'new' lump locking 148 const void* W_CacheLumpNum (int lump); 149 const void* W_LockLumpNum(int lump); 150 void W_UnlockLumpNum(int lump); 151 152 // CPhipps - convenience macros 153 //#define W_CacheLumpNum(num) (W_CacheLumpNum)((num),1) 154 #define W_CacheLumpName(name) W_CacheLumpNum (W_GetNumForName(name)) 155 156 //#define W_UnlockLumpNum(num) (W_UnlockLumpNum)((num),1) 157 #define W_UnlockLumpName(name) W_UnlockLumpNum (W_GetNumForName(name)) 158 159 char *AddDefaultExtension(char *, const char *); // killough 1/18/98 160 void ExtractFileBase(const char *, char *); // killough 161 unsigned W_LumpNameHash(const char *s); // killough 1/31/98 162 void W_HashLumps(void); // cph 2001/07/07 - made public 163 164 #endif 165