diff --git a/src/dumper/dumper.cs b/src/dumper/dumper.cs index 0c6dd9c..e5dfca2 100644 --- a/src/dumper/dumper.cs +++ b/src/dumper/dumper.cs @@ -2,6 +2,7 @@ using CUE4Parse.Compression; using CUE4Parse.Encryption.Aes; using CUE4Parse.FileProvider; using CUE4Parse.MappingsProvider.Usmap; +using CUE4Parse.UE4.Assets; using CUE4Parse.UE4.Assets.Exports.Engine; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse.UE4.Assets.Objects; @@ -64,10 +65,10 @@ class Dumper /* * game path */ - var gamePath = Utils.GetGamePath(); + string? gamePath = Utils.GetGamePath(); if (gamePath == null) return false; - var pakDir = Path.Combine(gamePath, "DeadByDaylight", "Content", "Paks"); + string pakDir = Path.Combine(gamePath, "DeadByDaylight", "Content", "Paks"); if (!Directory.Exists(pakDir)) { Console.WriteLine("PAK dir does not exist. (Invalid install?)"); @@ -77,7 +78,7 @@ class Dumper /* * file provider */ - var version = new VersionContainer(EGame.GAME_DeadByDaylight, ETexturePlatform.DesktopMobile); + VersionContainer? version = new VersionContainer(EGame.GAME_DeadByDaylight, ETexturePlatform.DesktopMobile); _provider = new DefaultFileProvider(pakDir, SearchOption.TopDirectoryOnly, version) { MappingsContainer = new FileUsmapTypeMappingsProvider(mappingPath) @@ -88,12 +89,6 @@ class Dumper _provider.Mount(); _provider.PostMount(); - if (!_provider.TryGetArchive("pakchunk3-WinGDK.utoc", out _iconPak)) // icons - { - Console.WriteLine("Failed to load pakchunk3-WinGDK.utoc"); - return false; - } - if (!_provider.TryGetArchive("pakchunk4-WinGDK.utoc", out _dataPak)) // data { Console.WriteLine("Failed to load pakchunk4-WinGDK.utoc"); @@ -119,13 +114,13 @@ class Dumper foreach (string path in charDbPaths) { - var cleanPath = path.Contains('.') ? path[..path.LastIndexOf('.')] : path; + string cleanPath = path.Contains('.') ? path[..path.LastIndexOf('.')] : path; - if (_provider.TryLoadPackageObject(cleanPath, out var dataTable)) + if (_provider.TryLoadPackageObject(cleanPath, out UDataTable? dataTable)) { - foreach (var row in dataTable.RowMap) + foreach (KeyValuePair row in dataTable.RowMap) { - var props = row.Value.Properties; + List props = row.Value.Properties; /* * props @@ -174,10 +169,10 @@ class Dumper */ private bool TryGetProp(IEnumerable properties, string propName, out T value) { - var prop = properties.FirstOrDefault(p => p.Name.Text == propName); + FPropertyTag? prop = properties.FirstOrDefault(p => p.Name.Text == propName); if (prop?.Tag != null) { - var val = prop.Tag.GetValue(); + T? val = prop.Tag.GetValue(); if (val != null) { value = val; @@ -190,7 +185,7 @@ class Dumper } private bool TryGetStringProp(IEnumerable properties, string propName, out string value) { - if (TryGetProp(properties, propName, out var rawValue) && rawValue != null) + if (TryGetProp(properties, propName, out T? rawValue) && rawValue != null) { string? strVal = rawValue.ToString(); @@ -227,28 +222,28 @@ class Dumper if (_provider == null) return; - if (_provider.TryLoadPackage(cleanPath, out var package)) + if (_provider.TryLoadPackage(cleanPath, out IPackage? package)) { - var texture = package.GetExports().OfType().FirstOrDefault(); + UTexture2D? texture = package.GetExports().OfType().FirstOrDefault(); if (texture != null) { - var bitmap = texture.Decode(ETexturePlatform.DesktopMobile); + CTexture? bitmap = texture.Decode(ETexturePlatform.DesktopMobile); if (bitmap != null) { - var bytes = bitmap.Encode(ETextureFormat.Png, false, out _); + byte[] bytes = bitmap.Encode(ETextureFormat.Png, false, out _); string? parentFolder = Path.GetDirectoryName(fullPath); if (!string.IsNullOrEmpty(parentFolder)) Directory.CreateDirectory(parentFolder); File.WriteAllBytes(fullPath, bytes); - Console.WriteLine($"Exported icon: {fileName}"); + _log.Verbose("Exported icon: {0}", fileName); } } else - Console.WriteLine($"Failed to find a UTexture2D export in package: {cleanPath}"); + throw new FileNotFoundException("Failed to find texture"); } } }