Odamex
Setting the Standard in Multiplayer Doom
common/w_wad.h
Go to the documentation of this file.
00001 // Emacs style mode select   -*- C++ -*- 
00002 //-----------------------------------------------------------------------------
00003 //
00004 // $Id: w_wad.h 1859 2010-09-05 21:54:58Z mike $
00005 //
00006 // Copyright (C) 1993-1996 by id Software, Inc.
00007 // Copyright (C) 2006-2010 by The Odamex Team.
00008 //
00009 // This program is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU General Public License
00011 // as published by the Free Software Foundation; either version 2
00012 // of the License, or (at your option) any later version.
00013 //
00014 // This program is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // DESCRIPTION:
00020 //      WAD I/O functions.
00021 //
00022 //-----------------------------------------------------------------------------
00023 
00024 
00025 #ifndef __W_WAD__
00026 #define __W_WAD__
00027 
00028 #include "doomtype.h"
00029 #include "z_zone.h"
00030 #include "r_defs.h"
00031 
00032 #include <string>
00033 #include <vector>
00034 
00035 // [RH] Compare wad header as ints instead of chars
00036 #define IWAD_ID (('I')|('W'<<8)|('A'<<16)|('D'<<24))
00037 #define PWAD_ID (('P')|('W'<<8)|('A'<<16)|('D'<<24))
00038 
00039 // [RH] Remove limit on number of WAD files
00040 extern std::vector<std::string> wadfiles, wadhashes;
00041 
00042 //
00043 // TYPES
00044 //
00045 typedef struct
00046 {
00047         // Should be "IWAD" or "PWAD".
00048         unsigned        identification;
00049         int                     numlumps;
00050         int                     infotableofs;
00051 
00052 } wadinfo_t;
00053 
00054 
00055 typedef struct
00056 {
00057         int                     filepos;
00058         int                     size;
00059         char            name[8]; // denis - todo - string
00060 
00061 } filelump_t;
00062 
00063 //
00064 // WADFILE I/O related stuff.
00065 //
00066 typedef struct lumpinfo_s
00067 {
00068         char            name[8]; // denis - todo - string
00069         FILE            *handle;
00070         int                     position;
00071         int                     size;
00072 
00073         // [RH] Hashing stuff
00074         int                     next;
00075         int                     index;
00076 
00077         int                     namespc;
00078 } lumpinfo_t;
00079 
00080 // [RH] Namespaces from BOOM.
00081 typedef enum {
00082         ns_global = 0,
00083         ns_sprites,
00084         ns_flats,
00085         ns_colormaps,
00086         ns_skinbase = 0x80000000        // Each skin's status bar face gets own namespace
00087 } namespace_t;
00088 
00089 extern  void**          lumpcache;
00090 extern  lumpinfo_t*     lumpinfo;
00091 extern  size_t  numlumps;
00092 
00093 std::string W_MD5(std::string filename);
00094 std::vector<std::string> W_InitMultipleFiles (std::vector<std::string> &filenames);
00095 
00096 int             W_CheckNumForName (const char *name, int ns = ns_global);
00097 int             W_GetNumForName (const char *name);
00098 
00099 unsigned        W_LumpLength (unsigned lump);
00100 void            W_ReadLump (unsigned lump, void *dest);
00101 unsigned        W_ReadChunk (const char *file, unsigned offs, unsigned len, void *dest, unsigned &filelen);
00102 
00103 void *W_CacheLumpNum (unsigned lump, int tag);
00104 void *W_CacheLumpName (const char *name, int tag);
00105 patch_t* W_CachePatch (unsigned lump, int tag = PU_CACHE);
00106 patch_t* W_CachePatch (const char *name, int tag = PU_CACHE);
00107 
00108 void    W_Profile (const char *fname);
00109 
00110 void    W_Close ();
00111 
00112 int             W_FindLump (const char *name, int *lastlump);   // [RH] Find lumps with duplication
00113 bool    W_CheckLumpName (unsigned lump, const char *name);      // [RH] True if lump's name == name // denis - todo - replace with map<>
00114 
00115 //unsigned W_LumpNameHash (const char *name);                           // [RH] Create hash key from an 8-char name
00116 
00117 // [RH] Combine multiple marked ranges of lumps into one.
00118 void    W_MergeLumps (const char *start, const char *end, int);
00119 
00120 // [RH] Copy an 8-char string and uppercase it.
00121 void uppercopy (char *to, const char *from);
00122 
00123 // [RH] Copies the lump name to to using uppercopy
00124 void W_GetLumpName (char *to, unsigned lump);
00125 
00126 // [RH] Returns file handle for specified lump
00127 int W_GetLumpFile (unsigned lump);
00128 
00129 // [Russell] Simple function to check whether the given string is an iwad name
00130 BOOL W_IsIWAD(std::string filename, std::string hash = "");
00131 
00132 // [RH] Put a lump in a certain namespace
00133 //void W_SetLumpNamespace (unsigned lump, int nmspace);
00134 
00135 #endif
00136 
00137 
00138 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends