Skip to content

Commit 7260f39

Browse files
feat(vpkpp): add support for VPK v54
1 parent 514a708 commit 7260f39

File tree

9 files changed

+211
-80
lines changed

9 files changed

+211
-80
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616
[submodule "ext/hat-trie"]
1717
path = ext/hat-trie
1818
url = https://github.com/Tessil/hat-trie
19+
[submodule "ext/zstd"]
20+
path = ext/zstd
21+
url = https://github.com/facebook/zstd

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,11 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
185185
</tr>
186186
<tr><!-- empty row to disable github striped bg color --></tr>
187187
<tr>
188-
<td><a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2</td>
188+
<td>
189+
<a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2, v54
190+
<br> &bull; <a href="https://www.counter-strike.net/cs2">Counter-Strike: 2</a> modifications
191+
<br> &bull; <a href="https://clientmod.ru">Counter-Strike: Source ClientMod</a> modifications
192+
</td>
189193
<td align="center">✅</td>
190194
<td align="center">✅</td>
191195
</tr>

docs/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
162162
<td align="center">✅</td>
163163
</tr>
164164
<tr>
165-
<td><a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2</td>
165+
<td>
166+
<a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2, v54
167+
<br> &bull; <a href="https://www.counter-strike.net/cs2">Counter-Strike: 2</a> modifications
168+
<br> &bull; <a href="https://clientmod.ru">Counter-Strike: Source ClientMod</a> modifications
169+
</td>
166170
<td align="center">✅</td>
167171
<td align="center">✅</td>
168172
</tr>

ext/_ext.cmake

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,27 @@ if(NOT TARGET miniz)
3737
endif()
3838

3939

40+
# zstd
41+
if(NOT TARGET zstd::libzstd)
42+
set(ZSTD_BUILD_PROGRAMS OFF CACHE INTERNAL "" FORCE)
43+
set(ZSTD_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
44+
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/zstd/build/cmake")
45+
# find_package hacks
46+
set(ZSTD_FOUND ON CACHE INTERNAL "" FORCE)
47+
set(ZSTD_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/zstd/lib" CACHE INTERNAL "" FORCE)
48+
set(ZSTD_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/zstd/lib" CACHE INTERNAL "" FORCE)
49+
set(ZSTD_LIBRARIES "libzstd_static" CACHE INTERNAL "" FORCE)
50+
endif()
51+
52+
4053
# minizip-ng
4154
if(NOT TARGET MINIZIP::minizip)
4255
set(MZ_COMPAT OFF CACHE INTERNAL "" FORCE)
43-
set(MZ_ZLIB ON CACHE INTERNAL "")
44-
set(MZ_BZIP2 ON CACHE INTERNAL "")
45-
set(MZ_LZMA ON CACHE INTERNAL "")
46-
set(MZ_ZSTD ON CACHE INTERNAL "")
47-
set(MZ_LIBCOMP OFF CACHE INTERNAL "")
56+
set(MZ_FETCH_LIBS ON CACHE INTERNAL "")
57+
set(MZ_FORCE_FETCH_LIBS OFF CACHE INTERNAL "")
4858
set(MZ_PKCRYPT OFF CACHE INTERNAL "")
4959
set(MZ_WZAES OFF CACHE INTERNAL "")
5060
set(MZ_OPENSSL OFF CACHE INTERNAL "")
51-
set(MZ_FETCH_LIBS ON CACHE INTERNAL "")
52-
set(MZ_FORCE_FETCH_LIBS ON CACHE INTERNAL "")
5361
set(SKIP_INSTALL_ALL ON CACHE INTERNAL "" FORCE)
5462
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/minizip-ng")
5563

ext/zstd

Submodule zstd added at 20707e3

include/vpkpp/Options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ struct BakeOptions {
2020
/// BSP/ZIP - Override compression type of all stored entries
2121
EntryCompressionType zip_compressionTypeOverride = EntryCompressionType::NO_OVERRIDE;
2222

23-
/// BSP/ZIP - Compression strength (use -1 for the compression type's default)
24-
int8_t zip_compressionStrength = -1;
23+
/// BSP/VPK/ZIP - Compression strength
24+
int8_t zip_compressionStrength = 0;
2525

2626
/// GMA - Write CRCs for files and the overall GMA file when baking
2727
bool gma_writeCRCs = true;

include/vpkpp/format/VPK.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ class VPK : public PackFile {
129129

130130
void addEntryInternal(Entry& entry, const std::string& path, std::vector<std::byte>& buffer, EntryOptions options) override;
131131

132+
[[nodiscard]] bool hasExtendedHeader() const;
133+
134+
[[nodiscard]] bool hasCompression() const;
135+
132136
[[nodiscard]] uint32_t getHeaderLength() const;
133137

134138
uint32_t numArchives = -1;

src/vpkpp/_vpkpp.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_pretty_parser(vpkpp
2-
DEPS cryptopp::cryptopp MINIZIP::minizip sourcepp::bsppp sourcepp::kvpp
2+
DEPS cryptopp::cryptopp libzstd_static MINIZIP::minizip sourcepp::bsppp sourcepp::kvpp
33
DEPS_INTERFACE tsl::hat_trie
44
PRECOMPILED_HEADERS
55
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/BSP.h"

0 commit comments

Comments
 (0)