Skip to content

Commit d18a75f

Browse files
vpkpp: fix incorrect size calculation when baking PAK files
1 parent dbd9da9 commit d18a75f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vpkpp/format/PAK.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ std::unique_ptr<PackFile> PAK::open(const std::string& path, const EntryCallback
5353

5454
const auto directoryOffset = reader.read<uint32_t>();
5555
// Directory size / file entry size
56-
const auto fileCount = reader.read<uint32_t>() / (pak->type != Type::PAK ? 128 : 64);
56+
const auto fileCount = reader.read<uint32_t>() / (sizeof(uint32_t) * 2 + pak->getFilenameLength());
5757

5858
reader.seek_in(directoryOffset);
5959
for (uint32_t i = 0; i < fileCount; i++) {
@@ -134,7 +134,7 @@ bool PAK::bake(const std::string& outputDir_, BakeOptions options, const EntryCa
134134
// Index and size of directory
135135
static constexpr uint32_t DIRECTORY_INDEX = sizeof(PAK_SIGNATURE) + sizeof(uint32_t) * 2;
136136
stream.write(DIRECTORY_INDEX);
137-
const uint32_t directorySize = entriesToBake.size() * this->getFilenameLength();
137+
const uint32_t directorySize = entriesToBake.size() * (sizeof(uint32_t) * 2 + this->getFilenameLength());
138138
stream.write(directorySize);
139139

140140
// Directory

0 commit comments

Comments
 (0)