-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVBSPFile.h
155 lines (130 loc) · 5.47 KB
/
VBSPFile.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* HLLib
* Copyright (C) 2006-2010 Ryan Gregg
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later
* version.
*/
#ifndef VBSPFILE_H
#define VBSPFILE_H
#include "stdafx.h"
#include "Package.h"
#define HL_VBSP_LUMP_COUNT 64
namespace HLLib
{
class HLLIB_API CVBSPFile : public CPackage
{
private:
#pragma pack(1)
struct VBSPLump
{
hlUInt uiOffset;
hlUInt uiLength;
hlUInt uiVersion; // Default to zero.
hlChar lpFourCC[4]; // Default to ( char )0, ( char )0, ( char )0, ( char )0.
};
struct VBSPHeader
{
hlChar lpSignature[4]; // BSP file signature.
hlInt iVersion; // BSP file version.
VBSPLump lpLumps[HL_VBSP_LUMP_COUNT]; // Lumps.
hlInt iMapRevision; // The map's revision (iteration, version) number.
};
struct ZIPEndOfCentralDirectoryRecord
{
hlUInt uiSignature; // 4 bytes (0x06054b50)
hlUInt16 uiNumberOfThisDisk; // 2 bytes
hlUInt16 uiNumberOfTheDiskWithStartOfCentralDirectory; // 2 bytes
hlUInt16 uiCentralDirectoryEntriesThisDisk; // 2 bytes
hlUInt16 uiCentralDirectoryEntriesTotal; // 2 bytes
hlUInt uiCentralDirectorySize; // 4 bytes
hlUInt uiStartOfCentralDirOffset; // 4 bytes
hlUInt16 uiCommentLength; // 2 bytes
// zip file comment follows
};
struct ZIPFileHeader
{
hlUInt uiSignature; // 4 bytes (0x02014b50)
hlUInt16 uiVersionMadeBy; // version made by 2 bytes
hlUInt16 uiVersionNeededToExtract; // version needed to extract 2 bytes
hlUInt16 uiFlags; // general purpose bit flag 2 bytes
hlUInt16 uiCompressionMethod; // compression method 2 bytes
hlUInt16 uiLastModifiedTime; // last mod file time 2 bytes
hlUInt16 uiLastModifiedDate; // last mod file date 2 bytes
hlUInt uiCRC32; // crc-32 4 bytes
hlUInt uiCompressedSize; // compressed size 4 bytes
hlUInt uiUncompressedSize; // uncompressed size 4 bytes
hlUInt16 uiFileNameLength; // file name length 2 bytes
hlUInt16 uiExtraFieldLength; // extra field length 2 bytes
hlUInt16 uiFileCommentLength; // file comment length 2 bytes
hlUInt16 uiDiskNumberStart; // disk number start 2 bytes
hlUInt16 uiInternalFileAttribs; // internal file attributes 2 bytes
hlUInt uiExternalFileAttribs; // external file attributes 4 bytes
hlUInt uiRelativeOffsetOfLocalHeader; // relative offset of local header 4 bytes
// file name (variable size)
// extra field (variable size)
// file comment (variable size)
};
struct ZIPLocalFileHeader
{
hlUInt uiSignature; //local file header signature 4 bytes (0x04034b50)
hlUInt16 uiVersionNeededToExtract; // version needed to extract 2 bytes
hlUInt16 uiFlags; // general purpose bit flag 2 bytes
hlUInt16 uiCompressionMethod; // compression method 2 bytes
hlUInt16 uiLastModifiedTime; // last mod file time 2 bytes
hlUInt16 uiLastModifiedDate; // last mod file date 2 bytes
hlUInt uiCRC32; // crc-32 4 bytes
hlUInt uiCompressedSize; // compressed size 4 bytes
hlUInt uiUncompressedSize; // uncompressed size 4 bytes
hlUInt16 uiFileNameLength; // file name length 2 bytes
hlUInt16 uiExtraFieldLength; // extra field length 2 bytes
// file name (variable size)
// extra field (variable size)
// file data (variable size)
};
struct LMPHeader
{
hlInt iLumpOffset;
hlInt iLumpID;
hlInt iLumpVersion;
hlInt iLumpLength;
hlInt iMapRevision;
};
#pragma pack()
private:
static const char *lpAttributeNames[];
static const char *lpItemAttributeNames[];
Mapping::CView *pHeaderView;
Mapping::CView *pFileHeaderView;
Mapping::CView *pEndOfCentralDirectoryRecordView;
const VBSPHeader *pHeader;
const ZIPEndOfCentralDirectoryRecord *pEndOfCentralDirectoryRecord;
public:
CVBSPFile();
virtual ~CVBSPFile();
virtual HLPackageType GetType() const;
virtual const hlChar *GetExtension() const;
virtual const hlChar *GetDescription() const;
protected:
virtual hlBool MapDataStructures();
virtual hlVoid UnmapDataStructures();
virtual CDirectoryFolder *CreateRoot();
virtual hlUInt GetAttributeCountInternal() const;
virtual const hlChar *GetAttributeNameInternal(HLPackageAttribute eAttribute) const;
virtual hlBool GetAttributeInternal(HLPackageAttribute eAttribute, HLAttribute &Attribute) const;
virtual hlUInt GetItemAttributeCountInternal() const;
virtual const hlChar *GetItemAttributeNameInternal(HLPackageAttribute eAttribute) const;
virtual hlBool GetItemAttributeInternal(const CDirectoryItem *pItem, HLPackageAttribute eAttribute, HLAttribute &Attribute) const;
virtual hlBool GetFileExtractableInternal(const CDirectoryFile *pFile, hlBool &bExtractable) const;
virtual hlBool GetFileValidationInternal(const CDirectoryFile *pFile, HLValidation &eValidation) const;
virtual hlBool GetFileSizeInternal(const CDirectoryFile *pFile, hlUInt &uiSize) const;
virtual hlBool GetFileSizeOnDiskInternal(const CDirectoryFile *pFile, hlUInt &uiSize) const;
virtual hlBool CreateStreamInternal(const CDirectoryFile *pFile, Streams::IStream *&pStream) const;
virtual hlVoid ReleaseStreamInternal(Streams::IStream &Stream) const;
private:
hlVoid GetFileName(hlChar *lpBuffer, hlUInt uiBufferSize);
};
}
#endif