-
Notifications
You must be signed in to change notification settings - Fork 0
/
pakfile.h
133 lines (98 loc) · 3.13 KB
/
pakfile.h
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
//------------------------------------------------------------------------
// LEVEL building - Quake1/2 PAK files
//------------------------------------------------------------------------
//
// Copyright (C) 2021-2022 The OBSIDIAN Team
// Copyright (c) 2008-2017 Andrew J Apted
//
// 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.
//
//------------------------------------------------------------------------
#include "u_type.h"
#include <vector>
#ifndef __PAK_FILES_H__
#define __PAK_FILES_H__
/* PAK reading */
bool PAK_OpenRead(const char *filename);
void PAK_CloseRead(void);
int PAK_NumEntries(void);
int PAK_FindEntry(const char *name);
void PAK_FindMaps(std::vector<int> &entries);
int PAK_EntryLen(int entry);
const char *PAK_EntryName(int entry);
bool PAK_ReadData(int entry, int offset, int length, void *buffer);
void PAK_ListEntries(void);
/* PAK writing */
bool PAK_OpenWrite(const char *filename);
void PAK_CloseWrite(void);
void PAK_NewLump(const char *name);
void PAK_AppendData(const void *data, int length);
void PAK_FinishLump(void);
/* WAD2 reading */
bool WAD2_OpenRead(const char *filename);
void WAD2_CloseRead(void);
int WAD2_NumEntries(void);
int WAD2_FindEntry(const char *name);
int WAD2_EntryLen(int entry);
int WAD2_EntryType(int entry);
const char *WAD2_EntryName(int entry);
bool WAD2_ReadData(int entry, int offset, int length, void *buffer);
void WAD2_ListEntries(void);
/* WAD2 writing */
bool WAD2_OpenWrite(const char *filename);
void WAD2_CloseWrite(void);
void WAD2_NewLump(const char *name, int type = 0);
void WAD2_AppendData(const void *data, int length);
void WAD2_FinishLump(void);
/* ----- PAK structures ---------------------- */
typedef struct {
char magic[4];
u32_t dir_start;
u32_t entry_num;
} raw_pak_header_t;
#define PAK_MAGIC "PACK"
typedef struct {
char name[56];
u32_t offset;
u32_t length;
} raw_pak_entry_t;
/* ----- WAD2 structures ---------------------- */
typedef struct {
char magic[4];
u32_t num_lumps;
u32_t dir_start;
} raw_wad2_header_t;
#define WAD2_MAGIC "WAD2"
typedef struct {
u32_t start;
u32_t length; // compressed
u32_t u_len; // uncompressed
u8_t type;
u8_t compression;
u8_t _pad[2];
char name[16]; // must be null terminated
} raw_wad2_lump_t;
// compression method (from Quake1 source)
#define CMP_NONE 0
#define CMP_LZSS 1
// lump types (from Quake1 source)
#define TYP_NONE 0
#define TYP_LABEL 1
#define TYP_PALETTE 64
#define TYP_QTEX 65
#define TYP_QPIC 66
#define TYP_SOUND 67
#define TYP_MIPTEX 68
// this value is only returned from WAD2_EntryType()
#define TYP_COMPRESSED 256
#endif /* __PAK_FILES_H__ */
//--- editor settings ---
// vi:ts=2:sw=2:expandtab