Skip to content

Commit

Permalink
Updated pak file loader for UE4.27+
Browse files Browse the repository at this point in the history
  • Loading branch information
gildor2 committed Oct 3, 2021
1 parent a02982f commit daa3c14
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Unreal/FileSystem/GameFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ static void RegisterGameFile(const char* FullName, int64 FileSize = -1)
s++;
else
s = GlobalPath;
// The name of global.utoc file is hardcoded in UE4 code in FPakPlatformFile::Initialize, see
// IoStoreGlobalEnvironment.InitializeFileEnvironment() function call.
strcpy(s, "global.utoc");
FIOStoreFileSystem::LoadGlobalContainer(GlobalPath);
}
Expand Down
22 changes: 17 additions & 5 deletions Unreal/FileSystem/UnArchivePak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ void FPakEntry::DecodeFrom(const uint8* Data)
uint32 Bitfield = *(uint32*)Data;
Data += sizeof(uint32);

// CompressionBlockSize
if ((Bitfield & 0x3f) == 0x3f)
{
// UE4.27+
CompressionBlockSize = *(uint32*)Data;
Data += sizeof(uint32);
}
else
{
// UE4.26
CompressionBlockSize = (Bitfield & 0x3f) << 11;
}

CompressionMethod = (Bitfield >> 23) & 0x3f;

// Offset follows - either 32 or 64 bit value
Expand Down Expand Up @@ -231,14 +244,13 @@ void FPakEntry::DecodeFrom(const uint8* Data)

// Compression information
CompressionBlocks.AddUninitialized(BlockCount);
CompressionBlockSize = 0;
if (BlockCount)
{
// CompressionBlockSize
if (UncompressedSize < 65536)
// Adjust CompressionBlockSize for small blocks
if (UncompressedSize < CompressionBlockSize)
{
CompressionBlockSize = UncompressedSize;
else
CompressionBlockSize = (Bitfield & 0x3f) << 11;
}

// CompressionBlocks
if (BlockCount == 1)
Expand Down
Binary file modified umodel
Binary file not shown.
Binary file modified umodel.exe
Binary file not shown.

0 comments on commit daa3c14

Please sign in to comment.