pakstuff.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. ===========================================================================
  3. Copyright (C) 1999-2005 Id Software, Inc.
  4. This file is part of Quake III Arena source code.
  5. Quake III Arena source code is free software; you can redistribute it
  6. and/or modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of the License,
  8. or (at your option) any later version.
  9. Quake III Arena source code is distributed in the hope that it will be
  10. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with Foobar; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. ===========================================================================
  17. */
  18. #ifndef _PAKSTUFF_H_
  19. #define _PAKSTUFF_H_
  20. #include <windows.h>
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. typedef char Int8;
  26. typedef short Int16;
  27. typedef long Int32;
  28. typedef unsigned char UInt8;
  29. typedef unsigned short UInt16;
  30. typedef unsigned long UInt32;
  31. typedef float Float32;
  32. typedef double Float64;
  33. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  34. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  35. #define RANDOM(x) (random() % (x))
  36. #define RANDOMIZE() srand((int) time(NULL))
  37. #define FTYPE_UNKNOWN 0
  38. #define FTYPE_IWAD 1 /* .wad "IWAD" */
  39. #define FTYPE_PWAD 2 /* .wad "PWAD" */
  40. #define FTYPE_PACK 3 /* .pak "PACK" */
  41. #define FTYPE_WAD2 4 /* .wad "WAD2" */
  42. #define FTYPE_BSP 10 /* .bsp (0x17 0x00 0x00 0x00) */
  43. #define FTYPE_MODEL 11 /* .mdl "IDPO" */
  44. #define FTYPE_SPRITE 12 /* .spr "IDSP" */
  45. #define FTYPE_WAV 20 /* .wav "RIFF" */
  46. #define FTYPE_AU 21 /* .au ".snd" */
  47. #define FTYPE_VOC 22 /* .voc ? */
  48. #define FTYPE_PBM_ASC 30 /* .pbm "P1" */
  49. #define FTYPE_PGM_ASC 31 /* .pgm "P2" */
  50. #define FTYPE_PPM_ASC 32 /* .ppm "P3" */
  51. #define FTYPE_PBM_RAW 33 /* .pbm "P4" */
  52. #define FTYPE_PGM_RAW 34 /* .pgm "P5" */
  53. #define FTYPE_PPM_RAW 35 /* .ppm "P6" */
  54. #define FTYPE_BMP 36 /* .bmp "BM" */
  55. #define FTYPE_GIF 37 /* .gif "GIF8" */
  56. #define FTYPE_PCX 38 /* .pcx (0x0a 0x05 0x01 0x08) */
  57. #define FTYPE_ERROR -1
  58. #ifdef FAT_ENDIAN
  59. Bool ReadInt16 (FILE *file, UInt16 huge *x);
  60. Bool ReadInt32 (FILE *file, UInt32 huge *x);
  61. Bool ReadFloat32 (FILE *file, Float32 huge *x);
  62. Bool WriteInt16 (FILE *file, UInt16 huge *x);
  63. Bool WriteInt32 (FILE *file, UInt32 huge *x);
  64. Bool WriteFloat32 (FILE *file, Float32 huge *x);
  65. UInt16 SwapInt16 (UInt16 x);
  66. UInt32 SwapInt32 (UInt32 x);
  67. Float32 SwapFloat32 (Float32 x);
  68. #else
  69. #define ReadInt16(f, p) ReadBytes((f), (p), 2L)
  70. #define ReadInt32(f, p) ReadBytes((f), (p), 4L)
  71. #define ReadFloat32(f, p) ReadBytes((f), (p), 4L)
  72. #define WriteInt16(f, p) WriteBytes((f), (p), 2L)
  73. #define WriteInt32(f, p) WriteBytes((f), (p), 4L)
  74. #define WriteFloat32(f, p) WriteBytes((f), (p), 4L)
  75. #define SwapInt16(x) (x)
  76. #define SwapInt32(x) (x)
  77. #define SwapFloat32(x) (x)
  78. #endif /* FAT_ENDIAN */
  79. #define FROMDISK -1
  80. struct PACKDirectory
  81. {
  82. char name[56]; /* name of file */
  83. UInt32 offset; /* offset to start of data */
  84. UInt32 size; /* byte size of data */
  85. };
  86. typedef struct PACKDirectory *PACKDirPtr;
  87. typedef struct DirListStruct
  88. {
  89. char dirname[1024];
  90. int from;
  91. struct DirListStruct *next;
  92. } DIRLIST;
  93. typedef struct FileListStruct
  94. {
  95. char filename[1024];
  96. UInt32 offset;
  97. UInt32 size;
  98. struct FileListStruct *next;
  99. } FILELIST;
  100. typedef struct DirStruct
  101. {
  102. char name[1024];
  103. FILELIST *files;
  104. struct DirStruct *next;
  105. } DIRECTORY;
  106. extern int m_nPAKIndex;
  107. extern FILE* pakfile[16];
  108. extern boolean pakopen;
  109. extern DIRECTORY *paktextures;
  110. void ClearFileList (FILELIST **);
  111. void ClearDirList (DIRLIST **);
  112. boolean GetPackFileList (FILELIST **, char *);
  113. boolean GetPackTextureDirs (DIRLIST **);
  114. boolean AddToDirListAlphabetized (DIRLIST **, char *, int);
  115. boolean AddToFileListAlphabetized (FILELIST **t, char *, UInt32, UInt32, boolean);
  116. boolean PakLoadFile (const char *, void **);
  117. void OpenPakFile (const char *);
  118. void ClosePakFile (void);
  119. int PakLoadAnyFile(const char *filename, void **bufferptr);
  120. void WINAPI InitPakFile(const char * pBasePath, const char *pName);
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. #endif