Skip to content

Commit daa3c14

Browse files
committed
Updated pak file loader for UE4.27+
1 parent a02982f commit daa3c14

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

Unreal/FileSystem/GameFileSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ static void RegisterGameFile(const char* FullName, int64 FileSize = -1)
447447
s++;
448448
else
449449
s = GlobalPath;
450+
// The name of global.utoc file is hardcoded in UE4 code in FPakPlatformFile::Initialize, see
451+
// IoStoreGlobalEnvironment.InitializeFileEnvironment() function call.
450452
strcpy(s, "global.utoc");
451453
FIOStoreFileSystem::LoadGlobalContainer(GlobalPath);
452454
}

Unreal/FileSystem/UnArchivePak.cpp

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,19 @@ void FPakEntry::DecodeFrom(const uint8* Data)
170170
uint32 Bitfield = *(uint32*)Data;
171171
Data += sizeof(uint32);
172172

173+
// CompressionBlockSize
174+
if ((Bitfield & 0x3f) == 0x3f)
175+
{
176+
// UE4.27+
177+
CompressionBlockSize = *(uint32*)Data;
178+
Data += sizeof(uint32);
179+
}
180+
else
181+
{
182+
// UE4.26
183+
CompressionBlockSize = (Bitfield & 0x3f) << 11;
184+
}
185+
173186
CompressionMethod = (Bitfield >> 23) & 0x3f;
174187

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

232245
// Compression information
233246
CompressionBlocks.AddUninitialized(BlockCount);
234-
CompressionBlockSize = 0;
235247
if (BlockCount)
236248
{
237-
// CompressionBlockSize
238-
if (UncompressedSize < 65536)
249+
// Adjust CompressionBlockSize for small blocks
250+
if (UncompressedSize < CompressionBlockSize)
251+
{
239252
CompressionBlockSize = UncompressedSize;
240-
else
241-
CompressionBlockSize = (Bitfield & 0x3f) << 11;
253+
}
242254

243255
// CompressionBlocks
244256
if (BlockCount == 1)

umodel

0 Bytes
Binary file not shown.

umodel.exe

1 KB
Binary file not shown.

0 commit comments

Comments
 (0)