Skip to content

feat(vpkpp): VPK v54 #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "ext/hat-trie"]
path = ext/hat-trie
url = https://github.com/Tessil/hat-trie
[submodule "ext/zstd"]
path = ext/zstd
url = https://github.com/facebook/zstd
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
</tr>
<tr><!-- empty row to disable github striped bg color --></tr>
<tr>
<td><a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2</td>
<td>
<a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2, v54
<br> &bull; <a href="https://www.counter-strike.net/cs2">Counter-Strike: 2</a> modifications
<br> &bull; <a href="https://clientmod.ru">Counter-Strike: Source ClientMod</a> modifications
</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr>
Expand Down
6 changes: 5 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ Several modern C++20 libraries for sanely parsing Valve formats, rolled into one
<td align="center">✅</td>
</tr>
<tr>
<td><a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2</td>
<td>
<a href="https://developer.valvesoftware.com/wiki/VPK">VPK</a> v1-2, v54
<br> &bull; <a href="https://www.counter-strike.net/cs2">Counter-Strike: 2</a> modifications
<br> &bull; <a href="https://clientmod.ru">Counter-Strike: Source ClientMod</a> modifications
</td>
<td align="center">✅</td>
<td align="center">✅</td>
</tr>
Expand Down
22 changes: 15 additions & 7 deletions ext/_ext.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,27 @@ if(NOT TARGET miniz)
endif()


# zstd
if(NOT TARGET zstd::libzstd)
set(ZSTD_BUILD_PROGRAMS OFF CACHE INTERNAL "" FORCE)
set(ZSTD_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/zstd/build/cmake")
# find_package hacks
set(ZSTD_FOUND ON CACHE INTERNAL "" FORCE)
set(ZSTD_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/zstd/lib" CACHE INTERNAL "" FORCE)
set(ZSTD_LIBRARY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/ext/zstd/lib" CACHE INTERNAL "" FORCE)
set(ZSTD_LIBRARIES "libzstd_static" CACHE INTERNAL "" FORCE)
endif()


# minizip-ng
if(NOT TARGET MINIZIP::minizip)
set(MZ_COMPAT OFF CACHE INTERNAL "" FORCE)
set(MZ_ZLIB ON CACHE INTERNAL "")
set(MZ_BZIP2 ON CACHE INTERNAL "")
set(MZ_LZMA ON CACHE INTERNAL "")
set(MZ_ZSTD ON CACHE INTERNAL "")
set(MZ_LIBCOMP OFF CACHE INTERNAL "")
set(MZ_FETCH_LIBS ON CACHE INTERNAL "")
set(MZ_FORCE_FETCH_LIBS OFF CACHE INTERNAL "")
set(MZ_PKCRYPT OFF CACHE INTERNAL "")
set(MZ_WZAES OFF CACHE INTERNAL "")
set(MZ_OPENSSL OFF CACHE INTERNAL "")
set(MZ_FETCH_LIBS ON CACHE INTERNAL "")
set(MZ_FORCE_FETCH_LIBS ON CACHE INTERNAL "")
set(SKIP_INSTALL_ALL ON CACHE INTERNAL "" FORCE)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/minizip-ng")

Expand Down
1 change: 1 addition & 0 deletions ext/zstd
Submodule zstd added at 20707e
4 changes: 2 additions & 2 deletions include/vpkpp/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ struct BakeOptions {
/// BSP/ZIP - Override compression type of all stored entries
EntryCompressionType zip_compressionTypeOverride = EntryCompressionType::NO_OVERRIDE;

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

/// GMA - Write CRCs for files and the overall GMA file when baking
bool gma_writeCRCs = true;
Expand Down
4 changes: 4 additions & 0 deletions include/vpkpp/format/VPK.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class VPK : public PackFile {

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

[[nodiscard]] bool hasExtendedHeader() const;

[[nodiscard]] bool hasCompression() const;

[[nodiscard]] uint32_t getHeaderLength() const;

uint32_t numArchives = -1;
Expand Down
2 changes: 1 addition & 1 deletion src/vpkpp/_vpkpp.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_pretty_parser(vpkpp
DEPS cryptopp::cryptopp MINIZIP::minizip sourcepp::bsppp sourcepp::kvpp
DEPS cryptopp::cryptopp libzstd_static MINIZIP::minizip sourcepp::bsppp sourcepp::kvpp
DEPS_INTERFACE tsl::hat_trie
PRECOMPILED_HEADERS
"${CMAKE_CURRENT_SOURCE_DIR}/include/vpkpp/format/BSP.h"
Expand Down
Loading