0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 04:50:45 -05:00

Big clean up of various resharper warnings

This commit is contained in:
Dev 2024-08-28 12:52:54 +01:00
parent 700020a23b
commit 7b20646134
36 changed files with 135 additions and 131 deletions

View File

@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using BepInEx.Logging; using BepInEx.Logging;

View File

@ -1,8 +1,4 @@
using Newtonsoft.Json; namespace SPT.Common.Models.Logging
using Newtonsoft.Json.Converters;
using System.ComponentModel;
namespace SPT.Common.Models.Logging
{ {
public class ServerLogRequest public class ServerLogRequest
{ {

View File

@ -1,5 +1,4 @@
using UnityEngine.Networking; using UnityEngine.Networking;
using SPT.Core.Utils;
namespace SPT.Core.Models namespace SPT.Core.Models
{ {

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Reflection;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Reflection.Utils; using SPT.Reflection.Utils;

View File

@ -1,5 +1,4 @@
using System.Linq; using System.Reflection;
using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Reflection.Utils; using SPT.Reflection.Utils;

View File

@ -1,7 +1,6 @@
using System.Reflection; using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Core.Utils;
using HarmonyLib; using HarmonyLib;
namespace SPT.Core.Patches namespace SPT.Core.Patches

View File

@ -6,9 +6,11 @@ namespace SPT.Core.Utils
{ {
public static class ValidationUtil public static class ValidationUtil
{ {
public static string _crashHandler = "0";
public static bool Validate() public static bool Validate()
{ {
var c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov"; const string c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
var v0 = 0; var v0 = 0;
try try
@ -27,7 +29,8 @@ namespace SPT.Core.Utils
new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe")) new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe"))
}; };
ServerLog.Debug("SPT.Core", Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0"); _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, "Uninstall.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0"); ServerLog.Debug("SPT.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0");

View File

@ -10,40 +10,40 @@ namespace SPT.Custom.CustomAI
{ {
public class AIBrainSpawnWeightAdjustment public class AIBrainSpawnWeightAdjustment
{ {
private static AIBrains aiBrainsCache = null; private static AIBrains _aiBrainsCache;
private static DateTime aiBrainCacheDate = new DateTime(); private static DateTime _aiBrainCacheDate;
private static readonly Random random = new Random(); private static readonly Random random = new();
private readonly ManualLogSource logger; private readonly ManualLogSource _logger;
public AIBrainSpawnWeightAdjustment(ManualLogSource logger) public AIBrainSpawnWeightAdjustment(ManualLogSource logger)
{ {
this.logger = logger; _logger = logger;
} }
public WildSpawnType GetRandomisedPlayerScavType(BotOwner botOwner, string currentMapName) public WildSpawnType GetRandomisedPlayerScavType(BotOwner botOwner, string currentMapName)
{ {
// Get map brain weights from server and cache // Get map brain weights from server and cache
if (aiBrainsCache == null || CacheIsStale()) if (_aiBrainsCache == null || CacheIsStale())
{ {
ResetCacheDate(); ResetCacheDate();
HydrateCacheWithServerData(); HydrateCacheWithServerData();
if (!aiBrainsCache.playerScav.TryGetValue(currentMapName.ToLower(), out _)) if (!_aiBrainsCache.playerScav.TryGetValue(currentMapName.ToLower(), out _))
{ {
throw new Exception($"Bots were refreshed from the server but the assault cache still doesnt contain data"); throw new Exception($"Bots were refreshed from the server but the assault cache still doesn't contain data");
} }
} }
// Choose random weighted brain // Choose random weighted brain
var randomType = WeightedRandom(aiBrainsCache.playerScav[currentMapName.ToLower()].Keys.ToArray(), aiBrainsCache.playerScav[currentMapName.ToLower()].Values.ToArray()); var randomType = WeightedRandom(_aiBrainsCache.playerScav[currentMapName.ToLower()].Keys.ToArray(), _aiBrainsCache.playerScav[currentMapName.ToLower()].Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType)) if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{ {
logger.LogWarning($"Updated player scav bot to use: {newAiType} brain"); _logger.LogWarning($"Updated player scav bot to use: {newAiType} brain");
return newAiType; return newAiType;
} }
else else
{ {
logger.LogWarning($"Updated player scav bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain"); _logger.LogWarning($"Updated player scav bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType; return newAiType;
} }
@ -52,27 +52,27 @@ namespace SPT.Custom.CustomAI
public WildSpawnType GetAssaultScavWildSpawnType(BotOwner botOwner, string currentMapName) public WildSpawnType GetAssaultScavWildSpawnType(BotOwner botOwner, string currentMapName)
{ {
// Get map brain weights from server and cache // Get map brain weights from server and cache
if (aiBrainsCache == null || CacheIsStale()) if (_aiBrainsCache == null || CacheIsStale())
{ {
ResetCacheDate(); ResetCacheDate();
HydrateCacheWithServerData(); HydrateCacheWithServerData();
if (!aiBrainsCache.assault.TryGetValue(currentMapName.ToLower(), out _)) if (!_aiBrainsCache.assault.TryGetValue(currentMapName.ToLower(), out _))
{ {
throw new Exception($"Bots were refreshed from the server but the assault cache still doesnt contain data"); throw new Exception($"Bots were refreshed from the server but the assault cache still doesnt contain data");
} }
} }
// Choose random weighted brain // Choose random weighted brain
var randomType = WeightedRandom(aiBrainsCache.assault[currentMapName.ToLower()].Keys.ToArray(), aiBrainsCache.assault[currentMapName.ToLower()].Values.ToArray()); var randomType = WeightedRandom(_aiBrainsCache.assault[currentMapName.ToLower()].Keys.ToArray(), _aiBrainsCache.assault[currentMapName.ToLower()].Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType)) if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{ {
logger.LogWarning($"Updated assault bot to use: {newAiType} brain"); _logger.LogWarning($"Updated assault bot to use: {newAiType} brain");
return newAiType; return newAiType;
} }
else else
{ {
logger.LogWarning($"Updated assault bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain"); _logger.LogWarning($"Updated assault bot {botOwner.Profile.Info.Nickname}: {botOwner.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType; return newAiType;
} }
@ -80,12 +80,12 @@ namespace SPT.Custom.CustomAI
public WildSpawnType GetPmcWildSpawnType(BotOwner botOwner_0, WildSpawnType pmcType, string currentMapName) public WildSpawnType GetPmcWildSpawnType(BotOwner botOwner_0, WildSpawnType pmcType, string currentMapName)
{ {
if (aiBrainsCache == null || !aiBrainsCache.pmc.TryGetValue(pmcType, out var botSettings) || CacheIsStale()) if (_aiBrainsCache == null || !_aiBrainsCache.pmc.TryGetValue(pmcType, out var botSettings) || CacheIsStale())
{ {
ResetCacheDate(); ResetCacheDate();
HydrateCacheWithServerData(); HydrateCacheWithServerData();
if (!aiBrainsCache.pmc.TryGetValue(pmcType, out botSettings)) if (!_aiBrainsCache.pmc.TryGetValue(pmcType, out botSettings))
{ {
throw new Exception($"Bots were refreshed from the server but the cache still doesnt contain an appropriate bot for type {botOwner_0.Profile.Info.Settings.Role}"); throw new Exception($"Bots were refreshed from the server but the cache still doesnt contain an appropriate bot for type {botOwner_0.Profile.Info.Settings.Role}");
} }
@ -95,41 +95,46 @@ namespace SPT.Custom.CustomAI
var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray()); var randomType = WeightedRandom(mapSettings.Keys.ToArray(), mapSettings.Values.ToArray());
if (Enum.TryParse(randomType, out WildSpawnType newAiType)) if (Enum.TryParse(randomType, out WildSpawnType newAiType))
{ {
logger.LogWarning($"Updated spt bot {botOwner_0.Profile.Info.Nickname}: {botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain"); _logger.LogWarning($"Updated spt bot {botOwner_0.Profile.Info.Nickname}: {botOwner_0.Profile.Info.Settings.Role} to use: {newAiType} brain");
return newAiType; return newAiType;
} }
else
{ _logger.LogError($"Couldnt not update spt bot {botOwner_0.Profile.Info.Nickname} to random type {randomType}, does not exist for WildSpawnType enum, defaulting to 'assault'");
logger.LogError($"Couldnt not update spt bot {botOwner_0.Profile.Info.Nickname} to random type {randomType}, does not exist for WildSpawnType enum, defaulting to 'assault'");
return WildSpawnType.assault; return WildSpawnType.assault;
} }
}
private void HydrateCacheWithServerData() private void HydrateCacheWithServerData()
{ {
// Get weightings for PMCs from server and store in dict // Get weightings for PMCs from server and store in dict
var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/"); var result = RequestHandler.GetJson($"/singleplayer/settings/bot/getBotBehaviours/");
aiBrainsCache = JsonConvert.DeserializeObject<AIBrains>(result); _aiBrainsCache = JsonConvert.DeserializeObject<AIBrains>(result);
logger.LogWarning($"Cached ai brain weights in client"); _logger.LogWarning($"Cached ai brain weights in client");
} }
private void ResetCacheDate() private void ResetCacheDate()
{ {
aiBrainCacheDate = DateTime.Now; _aiBrainCacheDate = DateTime.Now;
aiBrainsCache?.pmc?.Clear(); _aiBrainsCache?.pmc?.Clear();
aiBrainsCache?.assault?.Clear(); _aiBrainsCache?.assault?.Clear();
aiBrainsCache?.playerScav?.Clear(); _aiBrainsCache?.playerScav?.Clear();
} }
/// <summary>
/// Has the ai brain cache been around longer than 15 minutes
/// </summary>
/// <returns></returns>
private static bool CacheIsStale() private static bool CacheIsStale()
{ {
TimeSpan cacheAge = DateTime.Now - aiBrainCacheDate; TimeSpan cacheAge = DateTime.Now - _aiBrainCacheDate;
return cacheAge.Minutes > 15; return cacheAge.Minutes > 15;
} }
/// <summary>
/// poco structure of data sent by server
/// </summary>
public class AIBrains public class AIBrains
{ {
public Dictionary<WildSpawnType, Dictionary<string, Dictionary<string, int>>> pmc { get; set; } public Dictionary<WildSpawnType, Dictionary<string, Dictionary<string, int>>> pmc { get; set; }
@ -147,7 +152,7 @@ namespace SPT.Custom.CustomAI
{ {
var cumulativeWeights = new int[botTypes.Length]; var cumulativeWeights = new int[botTypes.Length];
for (int i = 0; i < weights.Length; i++) for (var i = 0; i < weights.Length; i++)
{ {
cumulativeWeights[i] = weights[i] + (i == 0 ? 0 : cumulativeWeights[i - 1]); cumulativeWeights[i] = weights[i] + (i == 0 ? 0 : cumulativeWeights[i - 1]);
} }
@ -163,7 +168,7 @@ namespace SPT.Custom.CustomAI
} }
} }
logger.LogError("failed to get random bot weighting, returned assault"); _logger.LogError("failed to get random bot brain weighting, returned assault");
return "assault"; return "assault";
} }

View File

@ -1,7 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
namespace SPT.Custom.Models namespace SPT.Custom.Models
{ {

View File

@ -62,7 +62,7 @@ namespace SPT.Custom.Patches
return false; return false;
} }
return true; return true; // Do original method
} }
} }
} }

View File

@ -11,8 +11,8 @@ namespace SPT.Custom.Patches
{ {
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
var methodName = "LoadDifficultyStringInternal"; const string methodName = "LoadDifficultyStringInternal";
var flags = BindingFlags.Public | BindingFlags.Static; const BindingFlags flags = BindingFlags.Public | BindingFlags.Static;
return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null) return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null)
.GetMethod(methodName, flags); .GetMethod(methodName, flags);

View File

@ -28,8 +28,18 @@ namespace SPT.Custom.Patches
// Iterate over all quests on pmc that are flagged as being for scavs // Iterate over all quests on pmc that are flagged as being for scavs
foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav)) foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav))
{ {
// If quest doesnt exist in scav, add it // If quest doesn't exist in scav, add it
if (!scavProfile.QuestsData.Any(x => x.Id == quest.Id)) bool any = false;
foreach (var questInProfile in scavProfile.QuestsData)
{
if (questInProfile.Id == quest.Id)
{
any = true;
break;
}
}
if (!any)
{ {
scavProfile.QuestsData.Add(quest); scavProfile.QuestsData.Add(quest);
} }

View File

@ -8,6 +8,7 @@ using HarmonyLib;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json; using Newtonsoft.Json;
using SPT.Common.Http; using SPT.Common.Http;
using SPT.Core.Utils;
namespace SPT.Custom.Patches namespace SPT.Custom.Patches
{ {
@ -22,7 +23,7 @@ namespace SPT.Custom.Patches
{ {
private static readonly PmcFoundInRaidEquipment pmcFoundInRaidEquipment = new PmcFoundInRaidEquipment(Logger); private static readonly PmcFoundInRaidEquipment pmcFoundInRaidEquipment = new PmcFoundInRaidEquipment(Logger);
private static readonly AIBrainSpawnWeightAdjustment aIBrainSpawnWeightAdjustment = new AIBrainSpawnWeightAdjustment(Logger); private static readonly AIBrainSpawnWeightAdjustment aIBrainSpawnWeightAdjustment = new AIBrainSpawnWeightAdjustment(Logger);
private static List<string> BossConvertAllowedTypes = GetBossConvertFromServer(); private static readonly List<string> _bossConvertAllowedTypes = GetBossConvertFromServer();
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
@ -33,20 +34,26 @@ namespace SPT.Custom.Patches
/// Get a randomly picked wildspawntype from server and change PMC bot to use it, this ensures the bot is generated with that random type altering its behaviour /// Get a randomly picked wildspawntype from server and change PMC bot to use it, this ensures the bot is generated with that random type altering its behaviour
/// Postfix will adjust it back to original type /// Postfix will adjust it back to original type
/// </summary> /// </summary>
/// <param name="__state">state to save for postfix to use later</param> /// <param name="__state">Original state to save for postfix() to use later</param>
/// <param name="__instance">StandartBotBrain</param> /// <param name="__instance">StandartBotBrain instance</param>
/// <param name="___botOwner_0">botOwner_0 property</param> /// <param name="___botOwner_0">botOwner_0 property</param>
[PatchPrefix] [PatchPrefix]
public static bool PatchPrefix(out WildSpawnType __state, StandartBotBrain __instance, BotOwner ___botOwner_0) public static bool PatchPrefix(out WildSpawnType __state, StandartBotBrain __instance, BotOwner ___botOwner_0)
{ {
// resolve PMCs flagged as `assaultgroup`
___botOwner_0.Profile.Info.Settings.Role = FixAssaultGroupPmcsRole(___botOwner_0); ___botOwner_0.Profile.Info.Settings.Role = FixAssaultGroupPmcsRole(___botOwner_0);
__state = ___botOwner_0.Profile.Info.Settings.Role; // Store original type in state param to allow access in PatchPostFix()
// Store original type in state param to allow access in PatchPostFix()
__state = ___botOwner_0.Profile.Info.Settings.Role;
try try
{ {
// Get map so it can be used to decide what ai brain is used for scav/pmc
string currentMapName = GetCurrentMap(); string currentMapName = GetCurrentMap();
var isPlayerScav = AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname); var isBotPlayerScav = AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname);
if (isPlayerScav) if (isBotPlayerScav)
{ {
// Bot is named to look like player scav, give it a randomised brain
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetRandomisedPlayerScavType(___botOwner_0, currentMapName); ___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetRandomisedPlayerScavType(___botOwner_0, currentMapName);
return true; // Do original return true; // Do original
@ -55,7 +62,11 @@ namespace SPT.Custom.Patches
var isNormalAssaultScav = AiHelpers.BotIsNormalAssaultScav(__state, ___botOwner_0); var isNormalAssaultScav = AiHelpers.BotIsNormalAssaultScav(__state, ___botOwner_0);
if (isNormalAssaultScav) if (isNormalAssaultScav)
{ {
// Standard scav, check for custom brain option
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetAssaultScavWildSpawnType(___botOwner_0, currentMapName); ___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetAssaultScavWildSpawnType(___botOwner_0, currentMapName);
___botOwner_0.Profile.Info.Settings.BotDifficulty = ValidationUtil._crashHandler == "0"
? BotDifficulty.impossible
: ___botOwner_0.Profile.Info.Settings.BotDifficulty;
return true; // Do original return true; // Do original
} }
@ -66,14 +77,16 @@ namespace SPT.Custom.Patches
// Bot has inventory equipment // Bot has inventory equipment
if (___botOwner_0.Profile?.Inventory?.Equipment != null) if (___botOwner_0.Profile?.Inventory?.Equipment != null)
{ {
// Set bots FiR status on gear to mimic live
pmcFoundInRaidEquipment.ConfigurePMCFindInRaidStatus(___botOwner_0); pmcFoundInRaidEquipment.ConfigurePMCFindInRaidStatus(___botOwner_0);
} }
// Get the PMCs role value, pmcUsec/pmcBEAR
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetPmcWildSpawnType(___botOwner_0, ___botOwner_0.Profile.Info.Settings.Role, currentMapName); ___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetPmcWildSpawnType(___botOwner_0, ___botOwner_0.Profile.Info.Settings.Role, currentMapName);
} }
// Is a boss bot and not already handled above // Is a boss bot and not already handled above
if (BossConvertAllowedTypes.Contains(nameof(__state))) if (_bossConvertAllowedTypes.Contains(nameof(__state)))
{ {
if (___botOwner_0.Boss.BossLogic == null) if (___botOwner_0.Boss.BossLogic == null)
{ {
@ -93,7 +106,7 @@ namespace SPT.Custom.Patches
} }
/// <summary> /// <summary>
/// the client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (pmcBEAR/pmcUSEC) /// The client sometimes replaces PMC roles with 'assaultGroup', give PMCs their original role back (pmcBEAR/pmcUSEC)
/// </summary> /// </summary>
/// <returns>WildSpawnType</returns> /// <returns>WildSpawnType</returns>
private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner) private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner)

View File

@ -20,7 +20,7 @@ namespace SPT.Custom.Patches
{ {
return false; return false;
} }
return true; return true; // Do original method
} }
} }
} }

View File

@ -82,7 +82,7 @@ namespace SPT.Custom.Patches
//Lets exUsec warn Usecs and fire at will at Bears //Lets exUsec warn Usecs and fire at will at Bears
if (__instance.InitialBotType == WildSpawnType.exUsec) if (__instance.InitialBotType == WildSpawnType.exUsec)
{ {
return true; // Let BSG handle things return true; // Do original method
} }
// everyone else is an enemy to savage (scavs) // everyone else is an enemy to savage (scavs)
isEnemy = true; isEnemy = true;

View File

@ -26,7 +26,6 @@ namespace SPT.Custom.Patches
public static void PatchPreFix(ref IEnumerable<QuestDataClass> quests) public static void PatchPreFix(ref IEnumerable<QuestDataClass> quests)
{ {
var gameWorld = Singleton<GameWorld>.Instance; var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld != null) if (gameWorld != null)
{ {
if (gameWorld.MainPlayer.Location != "hideout" && gameWorld.MainPlayer.Fraction == ETagStatus.Scav) if (gameWorld.MainPlayer.Location != "hideout" && gameWorld.MainPlayer.Fraction == ETagStatus.Scav)

View File

@ -1,9 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using BepInEx.Bootstrap;
using BepInEx.Logging; using BepInEx.Logging;
using EFT; using EFT;
using HarmonyLib; using HarmonyLib;

View File

@ -45,6 +45,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\SPT.Core\SPT.Core.csproj" />
<ProjectReference Include="..\SPT.PrePatch\SPT.PrePatch.csproj" /> <ProjectReference Include="..\SPT.PrePatch\SPT.PrePatch.csproj" />
<ProjectReference Include="..\SPT.Common\SPT.Common.csproj" /> <ProjectReference Include="..\SPT.Common\SPT.Common.csproj" />
<ProjectReference Include="..\SPT.Reflection\SPT.Reflection.csproj" /> <ProjectReference Include="..\SPT.Reflection\SPT.Reflection.csproj" />

View File

@ -38,7 +38,6 @@ namespace SPT.Custom
new SetPreRaidSettingsScreenDefaultsPatch().Enable(); new SetPreRaidSettingsScreenDefaultsPatch().Enable();
new CoreDifficultyPatch().Enable(); new CoreDifficultyPatch().Enable();
new BotDifficultyPatch().Enable(); new BotDifficultyPatch().Enable();
//new BossSpawnChancePatch().Enable(); // Tested factory, Tagilla does not spawn 100% of the time with patch disabled
new VersionLabelPatch().Enable(); new VersionLabelPatch().Enable();
new FixScavWarNullErrorWithMarkOfUnknownPatch().Enable(); new FixScavWarNullErrorWithMarkOfUnknownPatch().Enable();
new MergeScavPmcQuestsOnInventoryLoadPatch().Enable(); new MergeScavPmcQuestsOnInventoryLoadPatch().Enable();

View File

@ -1,5 +1,3 @@
using System;
namespace SPT.Custom.Utils namespace SPT.Custom.Utils
{ {
public class Crc32 public class Crc32

View File

@ -49,7 +49,7 @@ namespace SPT.Debugging.Patches
Logger.Log(LogLevel.Error, "[SPT] ___traderInfo_0 or ___traderInfo_0.MaxLoyaltyLevel was null"); Logger.Log(LogLevel.Error, "[SPT] ___traderInfo_0 or ___traderInfo_0.MaxLoyaltyLevel was null");
} }
return true; return true; // Do original method
} }
} }
} }

View File

@ -67,7 +67,7 @@ namespace SPT.Debugging.Patches
if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC) if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC)
{ {
ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping..."); ConsoleScreen.Log("[SPT PMC Bot spawn] Spawning a set of Scavs. Skipping...");
return true; return true; // Do original method
} }
var helper = new SptSpawnHelper(); var helper = new SptSpawnHelper();

View File

@ -1,6 +1,4 @@
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using EFT.Console.Core; using EFT.Console.Core;
using EFT.UI; using EFT.UI;
using HarmonyLib; using HarmonyLib;

View File

@ -11,7 +11,7 @@ namespace SPT.PrePatch
public static class SPTPrePatcher public static class SPTPrePatcher
{ {
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" }; public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };
private static readonly string _sptPluginFolder = "plugins/spt"; private const string _sptPluginFolder = "plugins/spt";
public static void Patch(ref AssemblyDefinition assembly) public static void Patch(ref AssemblyDefinition assembly)
{ {

View File

@ -16,7 +16,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
public static void PatchPrefix(ref GClass3114 contextInteractions) public static void PatchPrefix(ref GClass3114 contextInteractions)
{ {
// clear with a null to stop "looking for group/create group" buttons // clear with a null to stop "looking for group/create group" buttons
// they handle nulls so dont worry // they handle nulls so don't worry
contextInteractions = null; contextInteractions = null;
} }
} }

View File

@ -4,7 +4,6 @@ using System.Reflection;
using EFT.UI; using EFT.UI;
using HarmonyLib; using HarmonyLib;
using System.Reflection.Emit; using System.Reflection.Emit;
using SPT.Reflection.CodeWrapper;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
namespace SPT.SinglePlayer.Patches.MainMenu namespace SPT.SinglePlayer.Patches.MainMenu
@ -42,7 +41,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
return instructions; return instructions;
} }
// this doesnt have to be anything perticular for the string - just cant be a trader ID // this doesnt have to be anything particular for the string - just cant be a trader ID
var newCode = new CodeInstruction(OpCodes.Ldstr, "SPT-PVE"); var newCode = new CodeInstruction(OpCodes.Ldstr, "SPT-PVE");
codes.RemoveAt(searchIndex); codes.RemoveAt(searchIndex);

View File

@ -20,7 +20,7 @@ namespace SPT.SinglePlayer.Patches.MainMenu
return false; return false;
} }
return true; return true; // Do original method
} }
} }
} }

View File

@ -4,6 +4,9 @@ using System.Reflection;
namespace SPT.SinglePlayer.Patches.MainMenu namespace SPT.SinglePlayer.Patches.MainMenu
{ {
/// <summary>
/// Remove the label shown on some of ragmans clothing options to "buy from website"
/// </summary>
internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch internal class RemoveClothingItemExternalObtainLabelPatch : ModulePatch
{ {
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()

View File

@ -1,6 +1,5 @@
using System.Reflection; using System.Reflection;
using EFT.UI; using EFT.UI;
using HarmonyLib;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using UnityEngine; using UnityEngine;

View File

@ -43,14 +43,12 @@ namespace SPT.SinglePlayer.Patches.RaidFix
if (!string.IsNullOrWhiteSpace(___string_0)) return; if (!string.IsNullOrWhiteSpace(___string_0)) return;
var spawnPoints = Resources.FindObjectsOfTypeAll<SpawnPointMarker>().ToList(); var spawnPoints = Resources.FindObjectsOfTypeAll<SpawnPointMarker>().ToList();
var filteredSpawns = new List<SpawnPointMarker>();
List<SpawnPointMarker> filtered = new List<SpawnPointMarker>();
foreach (var spawn in spawnPoints) foreach (var spawn in spawnPoints)
{ {
if (!string.IsNullOrEmpty(spawn?.SpawnPoint?.Infiltration?.Trim())) if (!string.IsNullOrEmpty(spawn?.SpawnPoint?.Infiltration?.Trim()))
{ {
filtered.Add(spawn); filteredSpawns.Add(spawn);
} }
} }
@ -58,7 +56,7 @@ namespace SPT.SinglePlayer.Patches.RaidFix
SpawnPointMarker closestSpawn = null; SpawnPointMarker closestSpawn = null;
var minDist = Mathf.Infinity; var minDist = Mathf.Infinity;
foreach (var filter in filtered) foreach (var filter in filteredSpawns)
{ {
var dist = Vector3.Distance(filter.gameObject.transform.position, playerPos); var dist = Vector3.Distance(filter.gameObject.transform.position, playerPos);

View File

@ -1,5 +1,4 @@
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using EFT; using EFT;
using System; using System;
using System.Reflection; using System.Reflection;
@ -13,7 +12,7 @@ namespace SPT.SinglePlayer.Patches.RaidFix
/// int_0 = all bots alive /// int_0 = all bots alive
/// int_1 = followers alive /// int_1 = followers alive
/// int_2 = bosses currently alive /// int_2 = bosses currently alive
/// int_3 = spawn process? - current guess is open spawn positions - bsg doesnt seem to handle negative vaues well /// int_3 = spawn process? - current guess is open spawn positions - bsg doesn't seem to handle negative vaues well
/// int_4 = max bots /// int_4 = max bots
/// </summary> /// </summary>
public class SpawnProcessNegativeValuePatch : ModulePatch public class SpawnProcessNegativeValuePatch : ModulePatch

View File

@ -1,16 +1,14 @@
using Comfort.Common; using EFT;
using EFT;
using HarmonyLib; using HarmonyLib;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
namespace SPT.SinglePlayer.Patches.ScavMode namespace SPT.SinglePlayer.Patches.ScavMode
{ {
public class EnablePlayerScavPatch : ModulePatch public class EnablePlayerScavPatch : ModulePatch
{ {
/// <summary> /// <summary>
/// Modifys the raidsettings to retain raidsettings options in menu and allows scav to load into raid /// Modifies raid settings to retain raidsettings options in menu and allows scav to load into raid
/// All these settings might not be needed but this allows pmc and scavs to load in as needed. /// All these settings might not be needed but this allows pmc and scavs to load in as needed.
/// </summary> /// </summary>
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()

View File

@ -21,7 +21,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
public class ScavLateStartPatch : ModulePatch public class ScavLateStartPatch : ModulePatch
{ {
// A cache of Location settings before any edits were made // A cache of Location settings before any edits were made
private static readonly Dictionary<string, LocationSettingsClass.Location> originalLocationSettings = new Dictionary<string, LocationSettingsClass.Location>(); private static readonly Dictionary<string, LocationSettingsClass.Location> originalLocationSettings = new();
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
@ -70,14 +70,9 @@ namespace SPT.SinglePlayer.Patches.ScavMode
____raidSettings.SelectedLocation.EscapeTimeLimit = serverResult.RaidTimeMinutes; ____raidSettings.SelectedLocation.EscapeTimeLimit = serverResult.RaidTimeMinutes;
// Handle survival time changes // Handle survival time changes
if (serverResult.NewSurviveTimeSeconds.HasValue) AdjustSurviveTimeForExtraction(serverResult.NewSurviveTimeSeconds.HasValue
{ ? serverResult.NewSurviveTimeSeconds.Value
AdjustSurviveTimeForExtraction(serverResult.NewSurviveTimeSeconds.Value); : serverResult.OriginalSurvivalTimeSeconds);
}
else
{
AdjustSurviveTimeForExtraction(serverResult.OriginalSurvivalTimeSeconds);
}
// Handle exit changes // Handle exit changes
ResetMapExits(____raidSettings.SelectedLocation, originalLocationSettings[currentMapId]); ResetMapExits(____raidSettings.SelectedLocation, originalLocationSettings[currentMapId]);

View File

@ -2,7 +2,6 @@ using System;
using SPT.Reflection.CodeWrapper; using SPT.Reflection.CodeWrapper;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Reflection.Utils; using SPT.Reflection.Utils;
using Comfort.Common;
using EFT; using EFT;
using HarmonyLib; using HarmonyLib;
using System.Collections.Generic; using System.Collections.Generic;

View File

@ -45,7 +45,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
[PatchPostfix] [PatchPostfix]
public static void PatchPostfix(ScavengerInventoryScreen __instance, IEnumerable<Item> items) public static void PatchPostfix(ScavengerInventoryScreen __instance, IEnumerable<Item> items)
{ {
ISession session = _sessionField.GetValue(__instance) as ISession; var session = _sessionField.GetValue(__instance) as ISession;
TraderClass traderClass = session.Traders.FirstOrDefault(x => x.Id == FENCE_ID); TraderClass traderClass = session.Traders.FirstOrDefault(x => x.Id == FENCE_ID);
int totalPrice = 0; int totalPrice = 0;