added Dead By Daylight game support

This commit is contained in:
iAmAsval 2020-06-01 15:39:55 +02:00
parent c9aee79f43
commit b1ff8917da
13 changed files with 53 additions and 37 deletions

View File

@ -4,7 +4,8 @@
{
Unknown,
Fortnite,
Valorant
Valorant,
DeadByDaylight
}
public enum EFModel

View File

@ -1,4 +1,5 @@
using PakReader.Pak;
using PakReader.Parsers.Objects;
using System;
using System.Collections.Generic;
using System.Windows;
@ -23,7 +24,7 @@ namespace FModel
});
public static bool bSearch = false; // trigger the event to select a file thank to the search window
public static string sSearch = string.Empty; // this will be the file name triggered
public static EGame Game = EGame.Unknown;
public static FGame Game = new FGame(EGame.Unknown, EPakVersion.LATEST);
public const EFModel Build =
#if RELEASE
EFModel.Release;
@ -34,6 +35,18 @@ namespace FModel
#endif
}
public class FGame
{
public EGame ActualGame;
public EPakVersion Version;
public FGame(EGame game, EPakVersion version)
{
ActualGame = game;
Version = version;
}
}
static class FColors
{
public const string Red = "#E06C75";

View File

@ -12,7 +12,7 @@ namespace FModel.Grabber.Aes
{
public static async Task<bool> Load(bool forceReload = false)
{
if (Globals.Game == EGame.Fortnite && MenuItems.pakFiles.AtLeastOnePak())
if (Globals.Game.ActualGame == EGame.Fortnite && MenuItems.pakFiles.AtLeastOnePak())
{
if (forceReload)
{
@ -31,7 +31,7 @@ namespace FModel.Grabber.Aes
{
string mainKey = $"0x{benResponse.MainKey.Substring(2).ToUpper()}";
DebugHelper.WriteLine("{0} {1} {2}", "[FModel]", "[AES]", $"BenBot Main key is {mainKey}");
staticKeys[Globals.Game.ToString()] = mainKey;
staticKeys[Globals.Game.ActualGame.ToString()] = mainKey;
Properties.Settings.Default.StaticAesKeys = JsonConvert.SerializeObject(staticKeys, Formatting.None);
}

View File

@ -69,7 +69,7 @@ namespace FModel.Grabber.Cdn
if (_data != null)
{
return JsonConvert.DeserializeObject<List<BackupMenuItemViewModel>>(JsonConvert.SerializeObject(_data.Backups[Globals.Game.ToString()]));
return JsonConvert.DeserializeObject<List<BackupMenuItemViewModel>>(JsonConvert.SerializeObject(_data.Backups[Globals.Game.ActualGame.ToString()]));
}
return new List<BackupMenuItemViewModel>();
}

View File

@ -42,6 +42,7 @@ namespace FModel.Grabber.Paks
if (!Utils.Paks.IsFileReadLocked(new FileInfo(pak)))
{
PakFileReader pakFile = new PakFileReader(pak);
Globals.Game.Version = pakFile.Info.Version;
DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[PAK]", "[Registering]", $"{pakFile.FileName} with GUID {pakFile.Info.EncryptionKeyGuid.Hex}");
Application.Current.Dispatcher.Invoke(delegate
@ -103,21 +104,17 @@ namespace FModel.Grabber.Paks
StaysOpenOnClick = true
}
};
MenuItems.pakFiles.Add(parent);
Application.Current.Dispatcher.Invoke(delegate
// Load All
MenuItems.pakFiles.Add(new PakMenuItemViewModel
{
MenuItems.pakFiles.Add(parent);
// Load All
MenuItems.pakFiles.Add(new PakMenuItemViewModel
{
Header = Properties.Resources.LoadAll,
Icon = new Image { Source = new BitmapImage(new Uri("Resources/folder-download.png", UriKind.Relative)) }
});
// Separator
MenuItems.pakFiles.Add(new Separator { });
Header = Properties.Resources.LoadAll,
Icon = new Image { Source = new BitmapImage(new Uri("Resources/folder-download.png", UriKind.Relative)) }
});
// Separator
MenuItems.pakFiles.Add(new Separator { });
}
}
}

View File

@ -67,7 +67,10 @@ namespace PakReader.Parsers.Objects
}
else
{
CompressionMethodIndex = reader.ReadUInt32();
if (FModel.Globals.Game.ActualGame != FModel.EGame.Valorant && Version == EPakVersion.FNAME_BASED_COMPRESSION_METHOD)
CompressionMethodIndex = reader.ReadByte();
else
CompressionMethodIndex = reader.ReadUInt32();
}
if (Version <= EPakVersion.INITIAL)
{

View File

@ -23,9 +23,9 @@ namespace PakReader.Parsers.Objects
Mips = reader.ReadTArray(() => new FTexture2DMipMap(reader, ubulk, bulkOffset));
if (reader.ReadInt32() != 0)
if (FModel.Globals.Game.ActualGame == FModel.EGame.Valorant || FModel.Globals.Game.Version > EPakVersion.FNAME_BASED_COMPRESSION_METHOD)
{
throw new FileLoadException("Too lazy to add virtual textures right now");
if (reader.ReadInt32() != 0) throw new FileLoadException("Too lazy to add virtual textures right now");
}
}
}

View File

@ -21,22 +21,24 @@ namespace FModel.Utils
{
string p = pakPath.Substring(0, index);
string game = p.Substring(p.LastIndexOf("\\") + 1);
Globals.Game = game switch
Globals.Game.ActualGame = game switch
{
"FortniteGame" => EGame.Fortnite,
"ShooterGame" => EGame.Valorant,
"DeadByDaylight" => EGame.DeadByDaylight,
_ => EGame.Unknown,
};
}
}
public static string GetGameName() => GetGameName(Globals.Game);
public static string GetGameName() => GetGameName(Globals.Game.ActualGame);
public static string GetGameName(EGame game) =>
game switch
{
EGame.Unknown => string.Empty,
EGame.Fortnite => "FortniteGame",
EGame.Valorant => "ShooterGame",
EGame.DeadByDaylight => "DeadByDaylight",
_ => string.Empty,
};

View File

@ -32,7 +32,7 @@ namespace FModel.Utils
if (!string.IsNullOrEmpty(Properties.Settings.Default.DynamicAesKeys))
dynamicKeys = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Settings.Default.DynamicAesKeys);
bool isMainKey = staticKeys.TryGetValue(Globals.Game.ToString(), out var _);
bool isMainKey = staticKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var _);
bool mainError = false; // used to avoid notifications about all static paks not working with the key
StatusBarVm.statusBarViewModel.Reset();
@ -44,7 +44,7 @@ namespace FModel.Utils
if (!mainError && isMainKey)
{
if (menuItem.PakFile.Info.EncryptionKeyGuid.Equals(new FGuid(0u, 0u, 0u, 0u)) &&
staticKeys.TryGetValue(Globals.Game.ToString(), out var sKey))
staticKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var sKey))
{
sKey = sKey.StartsWith("0x") ? sKey.Substring(2).ToUpperInvariant() : sKey.ToUpperInvariant();
try

View File

@ -44,12 +44,12 @@ namespace FModel.Utils
{
Match m = null;
string mount = fileReader.MountPoint;
if (Globals.Game == EGame.Fortnite)
if (Globals.Game.ActualGame == EGame.Fortnite)
m = Regex.Match(mount + KvP.Value.Name, $"{Folders.GetGameName()}/Content/Localization/Fortnite.*?/{langCode}/Fortnite.*", RegexOptions.IgnoreCase);
else if (Globals.Game == EGame.Valorant)
else if (Globals.Game.ActualGame == EGame.Valorant)
m = Regex.Match(mount + KvP.Value.Name, $"{Folders.GetGameName()}/Content/Localization/Game/{langCode}/Game.locres", RegexOptions.IgnoreCase);
if (m.Success)
if (m != null && m.Success)
{
DebugHelper.WriteLine("{0} {1} {2} {3}", "[FModel]", "[Localizations]", "[GameDict]", $"Feeding with {KvP.Value.Name} from {KvP.Value.PakFileName} Miam Miam!");
@ -70,7 +70,7 @@ namespace FModel.Utils
// online
if (_hotfixLocalizationDict.Count <= 0)
{
if (Globals.Game == EGame.Fortnite && NetworkInterface.GetIsNetworkAvailable())
if (Globals.Game.ActualGame == EGame.Fortnite && NetworkInterface.GetIsNetworkAvailable())
{
var hotfix = await Endpoints.GetJsonEndpoint<Dictionary<string, Dictionary<string, string>>>(Endpoints.BENBOT_HOTFIXES, GetLanguageCode()).ConfigureAwait(false);
if (hotfix?.Count > 0)
@ -115,7 +115,7 @@ namespace FModel.Utils
private static string GetLanguageCode() => GetLanguageCode((ELanguage)Properties.Settings.Default.AssetsLanguage);
private static string GetLanguageCode(ELanguage lang)
{
if (Globals.Game == EGame.Fortnite)
if (Globals.Game.ActualGame == EGame.Fortnite)
return lang switch
{
ELanguage.English => "en",
@ -135,7 +135,7 @@ namespace FModel.Utils
ELanguage.TraditionalChinese => "zh-Hant",
_ => "en",
};
else if (Globals.Game == EGame.Valorant)
else if (Globals.Game.ActualGame == EGame.Valorant)
return lang switch
{
//Indonesian id-ID

View File

@ -193,7 +193,7 @@ namespace FModel.ViewModels.MenuItem
foreach (PakFileReader pakFile in MenuItems.pakFiles.GetPakFileReaders())
{
if (pakFile.AesKey == null)
if (pakFile.Info.bEncryptedIndex && pakFile.AesKey == null)
continue;
if (!Globals.CachedPakFiles.ContainsKey(pakFile.FileName))
@ -218,7 +218,7 @@ namespace FModel.ViewModels.MenuItem
mode == EPakLoader.New ? Properties.Resources.NewFiles :
mode == EPakLoader.Modified ? Properties.Resources.ModifiedFiles :
mode == EPakLoader.NewModified ? Properties.Resources.NewModifiedFiles :
mode == EPakLoader.Single ? Header.Substring(0, Header.LastIndexOf("-WindowsClient.pak")) :
mode == EPakLoader.Single ? Header :
string.Empty
));

View File

@ -16,7 +16,7 @@ namespace FModel.ViewModels.TabControl
vm.PakName = pakFileReader.FileName;
vm.Version = ((int)pakFileReader.Info.Version).ToString();
vm.MountPoint = pakFileReader.MountPoint;
vm.AesKey = pakFileReader.AesKey.ToStringKey();
vm.AesKey = pakFileReader.AesKey?.ToStringKey();
vm.Guid = pakFileReader.Info.EncryptionKeyGuid.Hex;
vm.FileCount = (pakFileReader as IReadOnlyDictionary<string, FPakEntry>).Count.ToString();
});

View File

@ -39,7 +39,7 @@ namespace FModel.Windows.AESManager
if (!string.IsNullOrEmpty(Properties.Settings.Default.DynamicAesKeys))
dynamicAesKeys = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Settings.Default.DynamicAesKeys);
if (staticKeys.TryGetValue(Globals.Game.ToString(), out var sKey))
if (staticKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var sKey))
{
StaticKey_TxtBox.Text = sKey;
DebugHelper.WriteLine("{0} {1} {2} {3} {4}", "[FModel]", "[Window]", "[AES Manager]", "[GET]", $"Main PAKs with key: {sKey}");
@ -94,7 +94,7 @@ namespace FModel.Windows.AESManager
if (!string.IsNullOrEmpty(Properties.Settings.Default.StaticAesKeys))
staticKeys = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Settings.Default.StaticAesKeys);
staticKeys[Globals.Game.ToString()] = StaticKey_TxtBox.Text;
staticKeys[Globals.Game.ActualGame.ToString()] = StaticKey_TxtBox.Text;
DebugHelper.WriteLine("{0} {1} {2} {3} {4}", "[FModel]", "[Window]", "[AES Manager]", "[SET]", $"Main PAKs with key: {StaticKey_TxtBox.Text}");
Dictionary<string, string> dynamicKeys = new Dictionary<string, string>();
@ -119,7 +119,7 @@ namespace FModel.Windows.AESManager
private async void RefreshOnClick(object sender, RoutedEventArgs e)
{
if (Globals.Game == EGame.Fortnite)
if (Globals.Game.ActualGame == EGame.Fortnite)
{
bool success = await AesGrabber.Load(true).ConfigureAwait(false);
if (success)
@ -134,7 +134,7 @@ namespace FModel.Windows.AESManager
if (!string.IsNullOrEmpty(Properties.Settings.Default.DynamicAesKeys))
dynamicAesKeys = JsonConvert.DeserializeObject<Dictionary<string, string>>(Properties.Settings.Default.DynamicAesKeys);
if (staticKeys.TryGetValue(Globals.Game.ToString(), out var sKey))
if (staticKeys.TryGetValue(Globals.Game.ActualGame.ToString(), out var sKey))
{
StaticKey_TxtBox.Text = sKey;
DebugHelper.WriteLine("{0} {1} {2} {3} {4}", "[FModel]", "[Window]", "[AES Manager]", "[UPDATE]", $"Main PAKs with key: {sKey}");