auto detection of pak8 UE4.22 or UE4.23 (hopefully)

This commit is contained in:
iAmAsval 2020-07-07 22:07:24 +02:00
parent 2c3a05684e
commit f05293187a
5 changed files with 30 additions and 6 deletions

View File

@ -161,7 +161,7 @@ namespace PakReader.Pak
else
{
// https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/PakFile/Private/IPlatformFilePak.cpp#L4509
MountPoint = IndexReader.ReadFString();
MountPoint = IndexReader.ReadFString() ?? "";
if (MountPoint.StartsWith("../../.."))
{
MountPoint = MountPoint.Substring(8);
@ -180,7 +180,7 @@ namespace PakReader.Pak
tempFiles = new Dictionary<string, FPakEntry>(NumEntries);
for (int i = 0; i < NumEntries; i++)
{
var entry = new FPakEntry(IndexReader, Info.Version, CaseSensitive, FileName);
var entry = new FPakEntry(IndexReader, Info.Version, Info.SubVersion, CaseSensitive, FileName);
// if there is no filter OR the filter passes
if (filter == null || filter.CheckFilter(MountPoint + entry.Name, CaseSensitive))
{

View File

@ -24,7 +24,7 @@ namespace PakReader.Parsers.Objects
public readonly int StructSize;
internal FPakEntry(BinaryReader reader, EPakVersion Version, bool caseSensitive, string pakName)
internal FPakEntry(BinaryReader reader, EPakVersion Version, int SubVersion, bool caseSensitive, string pakName)
{
CompressionBlocks = null;
CompressionBlockSize = 0;
@ -66,7 +66,7 @@ namespace PakReader.Parsers.Objects
}
else
{
if (FModel.Globals.Game.ActualGame != FModel.EGame.Valorant && Version == EPakVersion.FNAME_BASED_COMPRESSION_METHOD)
if (Version == EPakVersion.FNAME_BASED_COMPRESSION_METHOD && SubVersion == 0)
CompressionMethodIndex = reader.ReadByte();
else
CompressionMethodIndex = reader.ReadUInt32();

View File

@ -11,6 +11,7 @@ namespace PakReader.Parsers.Objects
// Magic // 4 bytes
public readonly EPakVersion Version; // 4 bytes
public readonly int SubVersion;
public readonly long IndexOffset; // 8 bytes
public readonly long IndexSize; // 8 bytes
public readonly FSHAHash IndexHash; // 20 bytes
@ -46,10 +47,11 @@ namespace PakReader.Parsers.Objects
// Serialize if version is at least EPakVersion.ENCRYPTION_KEY_GUID
EncryptionKeyGuid = new FGuid(reader);
bEncryptedIndex = reader.ReadByte() != 0;
if (reader.ReadUInt32() != PAK_FILE_MAGIC)
{
Version = EPakVersion.INVALID;
SubVersion = 0;
IndexOffset = 0;
IndexSize = 0;
IndexHash = default;
@ -60,6 +62,12 @@ namespace PakReader.Parsers.Objects
}
Version = (EPakVersion)reader.ReadInt32();
int b;
if (maxNumCompressionMethods == 5 && Version == EPakVersion.FNAME_BASED_COMPRESSION_METHOD) // UE4.23
b = (((int)Version) << 4) | (1);
else
b = (((int)Version) << 4) | (0);
SubVersion = b & 15;
IndexOffset = reader.ReadInt64();
IndexSize = reader.ReadInt64();
IndexHash = new FSHAHash(reader);

View File

@ -257,6 +257,17 @@ namespace FModel.Utils
}
return p;
}
else if (s != null && (s.AudioFormat.String.Equals("OPUS") || s.AudioFormat.String.Equals("ADPCM")))
{
Application.Current.Dispatcher.Invoke(delegate
{
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[Window]", $"Opening Audio Player for {entry.GetNameWithExtension()}");
if (!FWindows.IsWindowOpen<Window>(Properties.Resources.AudioPlayer))
new AudioPlayer().LoadFiles(new Dictionary<string, byte[]>(1) {{ entry.GetNameWithoutExtension() + "." + s.AudioFormat.String.ToLowerInvariant(), s.Sound }}, entry.GetPathWithoutFile());
else
((AudioPlayer)FWindows.GetOpenedWindow<Window>(Properties.Resources.AudioPlayer)).LoadFiles(new Dictionary<string, byte[]>(1) { { entry.GetNameWithoutExtension() + "." + s.AudioFormat.String.ToLowerInvariant(), s.Sound } }, entry.GetPathWithoutFile());
});
}
else if (s != null) // ADPCM and others
{
string path = Properties.Settings.Default.OutputPath + "\\Sounds\\" + mount + entry.GetPathWithoutExtension() + "." + s.AudioFormat.String.ToLowerInvariant();

View File

@ -80,7 +80,12 @@ namespace FModel.Windows.SoundPlayer
{
Focus();
ListBoxVm.soundFiles.Clear();
if (files.Count > 5)
{
ListBoxVm.soundFiles.Clear();
if (output.HasMedia) output.Stop();
}
foreach (var (key, value) in files)
{
ListBoxVm.soundFiles.Add(new ListBoxViewModel2