diff --git a/README.md b/README.md index a46dcf2..9bbccf2 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ SPT.Debugging | Debug utilities (disabled in release builds) SPT.Reflection | Reflection utilities used across the project SPT.SinglePlayer | Simulating online game while offline + ## Privacy SPT is an open source project. Your commit credentials as author of a commit will be visible by anyone. Please make sure you understand this before submitting a PR. Feel free to use a "fake" username and email on your commits by using the following commands: @@ -21,6 +22,7 @@ git config --local user.name "USERNAME" git config --local user.email "USERNAME@SOMETHING.com" ``` + ## Requirements - Escape From Tarkov 33420 - Visual Studio Code -OR- Visual Studio 2022 diff --git a/project/SPT.Core/Utils/ValidationUtil.cs b/project/SPT.Core/Utils/ValidationUtil.cs index 279ce06..caca179 100644 --- a/project/SPT.Core/Utils/ValidationUtil.cs +++ b/project/SPT.Core/Utils/ValidationUtil.cs @@ -7,7 +7,8 @@ namespace SPT.Core.Utils public static class ValidationUtil { public static string _crashHandler = "0"; - + private static bool _hasRun = false; + public static bool Validate() { const string c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov"; @@ -29,11 +30,15 @@ namespace SPT.Core.Utils new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe")) }; - _crashHandler = Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0"; - ServerLog.Debug("SPT.Core", _crashHandler); - ServerLog.Debug("SPT.Core", Gfs(v2, "Uninstall.exe")?.Length.ToString() ?? "0"); - ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0"); - + if (!_hasRun) + { + _crashHandler = Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0"; + ServerLog.Debug("SPT.Core", _crashHandler); + ServerLog.Debug("SPT.Core", Gfs(v2, "Uninstall.exe")?.Length.ToString() ?? "0"); + ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0"); + _hasRun = true; + } + v0 = v4.Length - 1; foreach (var value in v4) diff --git a/project/SPT.Custom/CustomAI/AiHelpers.cs b/project/SPT.Custom/CustomAI/AiHelpers.cs index 5226e09..f0c724c 100644 --- a/project/SPT.Custom/CustomAI/AiHelpers.cs +++ b/project/SPT.Custom/CustomAI/AiHelpers.cs @@ -1,4 +1,5 @@ using EFT; +using System.Collections.Generic; namespace SPT.Custom.CustomAI { @@ -33,5 +34,44 @@ namespace SPT.Custom.CustomAI var nicknameContainsPScvCharacter = botOwner.Profile.Info.Nickname?.Contains("("); return nicknameContainsPScvCharacter.HasValue && nicknameContainsPScvCharacter.Value && role == WildSpawnType.assault; } + + public static List GetAllMembers(this BotsGroup group) + { + List members = new List(); + + if (group != null) + { + for (int m = 0; m < group.MembersCount; m++) + { + members.Add(group.Member(m)); + } + } + + return members; + } + + /// + /// Returns true if the player is found in the collection by searching for matching player Id's + /// + /// + /// + /// + public static bool ContainsPlayer(this IEnumerable players, IPlayer playerToCheck) + { + if (playerToCheck == null) + { + return false; + } + + foreach (IPlayer player in players) + { + if (player != null && player.Id == playerToCheck.Id) + { + return true; + } + } + + return false; + } } } diff --git a/project/SPT.Custom/Patches/EasyAssetsPatch.cs b/project/SPT.Custom/Patches/EasyAssetsPatch.cs index 25ca265..72e8b05 100644 --- a/project/SPT.Custom/Patches/EasyAssetsPatch.cs +++ b/project/SPT.Custom/Patches/EasyAssetsPatch.cs @@ -95,9 +95,12 @@ namespace SPT.Custom.Patches path = BundleManager.GetBundlePath(bundleInfo); // only download when connected externally - if (await BundleManager.ShouldReaquire(bundleInfo)) + if (await BundleManager.ShouldAcquire(bundleInfo)) { - VFS.DeleteFile(BundleManager.GetBundleFilePath(bundleInfo)); + if (VFS.Exists(BundleManager.GetBundleFilePath(bundleInfo))) + { + VFS.DeleteFile(BundleManager.GetBundleFilePath(bundleInfo)); + } await BundleManager.DownloadBundle(bundleInfo); } diff --git a/project/SPT.Custom/Utils/BundleManager.cs b/project/SPT.Custom/Utils/BundleManager.cs index 93f443b..ba0f749 100644 --- a/project/SPT.Custom/Utils/BundleManager.cs +++ b/project/SPT.Custom/Utils/BundleManager.cs @@ -51,7 +51,8 @@ namespace SPT.Custom.Utils await VFS.WriteFileAsync(filepath, data); } - public static async Task ShouldReaquire(BundleItem bundle) + // Handles both the check for initially acquiring and also re-acquiring a file. + public static async Task ShouldAcquire(BundleItem bundle) { // read cache var filepath = GetBundleFilePath(bundle);