From 272d09ca6db876d01bf524c390c93f463c8a728f Mon Sep 17 00:00:00 2001 From: craftablescience Date: Tue, 29 Oct 2024 22:57:10 -0400 Subject: [PATCH] fix(vpkpp): it was trying to load empty VTMB VPKs as pre-v1 Valve VPKs --- src/vpkpp/format/VPK.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/vpkpp/format/VPK.cpp b/src/vpkpp/format/VPK.cpp index aa4c18df0..60865f6af 100644 --- a/src/vpkpp/format/VPK.cpp +++ b/src/vpkpp/format/VPK.cpp @@ -109,6 +109,12 @@ std::unique_ptr VPK::openInternal(const std::string& path, const Entry if (vpk->header1.signature != VPK_SIGNATURE) { reader.seek_in(3, std::ios::end); if (reader.read() == '\0' && reader.read() == '\0' && reader.read() == '\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;