Skip to content

Commit

Permalink
fix(vpkpp): it was trying to load empty VTMB VPKs as pre-v1 Valve VPKs
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Oct 30, 2024
1 parent cf6e204 commit 272d09c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vpkpp/format/VPK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ std::unique_ptr<PackFile> VPK::openInternal(const std::string& path, const Entry
if (vpk->header1.signature != VPK_SIGNATURE) {
reader.seek_in(3, std::ios::end);
if (reader.read<char>() == '\0' && reader.read<char>() == '\0' && reader.read<char>() == '\0') {
// hack: if file is 9 bytes long it's probably an empty VTMB VPK and we should bail so that code can pick it up
// either way a 9 byte long VPK should not have any files in it
if (std::filesystem::file_size(vpk->fullFilePath) == 9) {
return nullptr;
}

// File is one of those shitty ancient VPKs
vpk->header1.signature = VPK_SIGNATURE;
vpk->header1.version = 0;
Expand Down

0 comments on commit 272d09c

Please sign in to comment.