w_wad.h.svn-base 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. #ifndef __W_WAD__
  34. #define __W_WAD__
  35. #ifdef __GNUG__
  36. #pragma interface
  37. #endif
  38. //
  39. // TYPES
  40. //
  41. typedef struct
  42. {
  43. char identification[4]; // Should be "IWAD" or "PWAD".
  44. int numlumps;
  45. int infotableofs;
  46. } wadinfo_t;
  47. typedef struct
  48. {
  49. int filepos;
  50. int size;
  51. char name[8];
  52. } filelump_t;
  53. //
  54. // WADFILE I/O related stuff.
  55. //
  56. // CPhipps - defined enum in wider scope
  57. // Ty 08/29/98 - add source field to identify where this lump came from
  58. typedef enum {
  59. // CPhipps - define elements in order of 'how new/unusual'
  60. source_iwad=0, // iwad file load
  61. source_pre, // predefined lump
  62. source_auto_load, // lump auto-loaded by config file
  63. source_pwad, // pwad file load
  64. source_lmp, // lmp file load
  65. source_net // CPhipps
  66. } wad_source_t;
  67. // CPhipps - changed wad init
  68. // We _must_ have the wadfiles[] the same as those actually loaded, so there
  69. // is no point having these separate entities. This belongs here.
  70. typedef struct {
  71. const char* name;
  72. wad_source_t src;
  73. int handle;
  74. } wadfile_info_t;
  75. extern wadfile_info_t *wadfiles;
  76. extern size_t numwadfiles; // CPhipps - size of the wadfiles array
  77. void W_Init(void); // CPhipps - uses the above array
  78. void W_ReleaseAllWads(void); // Proff - Added for iwad switching
  79. void W_InitCache(void);
  80. void W_DoneCache(void);
  81. typedef struct
  82. {
  83. // WARNING: order of some fields important (see info.c).
  84. char name[9];
  85. int size;
  86. // killough 1/31/98: hash table fields, used for ultra-fast hash table lookup
  87. int index, next;
  88. // killough 4/17/98: namespace tags, to prevent conflicts between resources
  89. enum {
  90. ns_global=0,
  91. ns_sprites,
  92. ns_flats,
  93. ns_colormaps,
  94. ns_prboom
  95. } li_namespace; // haleyjd 05/21/02: renamed from "namespace"
  96. wadfile_info_t *wadfile;
  97. int position;
  98. wad_source_t source;
  99. } lumpinfo_t;
  100. extern lumpinfo_t *lumpinfo;
  101. extern int numlumps;
  102. // killough 4/17/98: if W_CheckNumForName() called with only
  103. // one argument, pass ns_global as the default namespace
  104. #define W_CheckNumForName(name) (W_CheckNumForName)(name, ns_global)
  105. int (W_CheckNumForName)(const char* name, int); // killough 4/17/98
  106. int W_GetNumForName (const char* name);
  107. int W_LumpLength (int lump);
  108. void W_ReadLump (int lump, void *dest);
  109. // CPhipps - modified for 'new' lump locking
  110. const void* W_CacheLumpNum (int lump);
  111. const void* W_LockLumpNum(int lump);
  112. void W_UnlockLumpNum(int lump);
  113. // CPhipps - convenience macros
  114. //#define W_CacheLumpNum(num) (W_CacheLumpNum)((num),1)
  115. #define W_CacheLumpName(name) W_CacheLumpNum (W_GetNumForName(name))
  116. //#define W_UnlockLumpNum(num) (W_UnlockLumpNum)((num),1)
  117. #define W_UnlockLumpName(name) W_UnlockLumpNum (W_GetNumForName(name))
  118. char *AddDefaultExtension(char *, const char *); // killough 1/18/98
  119. void ExtractFileBase(const char *, char *); // killough
  120. unsigned W_LumpNameHash(const char *s); // killough 1/31/98
  121. void W_HashLumps(void); // cph 2001/07/07 - made public
  122. #endif