mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-12 14:50:43 -05:00
Various code cleanups and warning fixes
This commit is contained in:
parent
51aa599a4e
commit
e2af9e8a4a
@ -10,8 +10,8 @@ namespace SPT.Core.Patches
|
||||
{
|
||||
private const string PluginName = "SPT.Core";
|
||||
private const string ErrorMessage = "Validation failed";
|
||||
private static BepInEx.Logging.ManualLogSource _logger = null;
|
||||
private static bool _hasRun = false;
|
||||
private static BepInEx.Logging.ManualLogSource _logger;
|
||||
private static bool _hasRun;
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ namespace SPT.Custom.CustomAI
|
||||
ResetCacheDate();
|
||||
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 doesn't contain data");
|
||||
}
|
||||
@ -57,7 +57,7 @@ namespace SPT.Custom.CustomAI
|
||||
ResetCacheDate();
|
||||
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");
|
||||
}
|
||||
@ -85,7 +85,7 @@ namespace SPT.Custom.CustomAI
|
||||
ResetCacheDate();
|
||||
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}");
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ namespace SPT.Custom.Patches
|
||||
Path = filepath,
|
||||
KeyWithoutExtension = Path.GetFileNameWithoutExtension(key),
|
||||
DependencyKeys = dependencies,
|
||||
LoadState = new BindableState<ELoadState>(ELoadState.Unloaded, null),
|
||||
LoadState = new BindableState<ELoadState>(ELoadState.Unloaded),
|
||||
BundleLock = bundleLock
|
||||
};
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace SPT.Custom.Utils
|
||||
{
|
||||
public static string sptVersion;
|
||||
public static string commitHash;
|
||||
internal static HashSet<string> whitelistedPlugins = new HashSet<string>
|
||||
internal static HashSet<string> whitelistedPlugins = new()
|
||||
{
|
||||
"com.SPT.core",
|
||||
"com.SPT.custom",
|
||||
@ -36,12 +36,12 @@ namespace SPT.Custom.Utils
|
||||
|
||||
public static string[] disallowedPlugins;
|
||||
internal static ReleaseResponse release;
|
||||
private bool _isBetaDisclaimerOpen = false;
|
||||
private ManualLogSource Logger;
|
||||
private bool _isBetaDisclaimerOpen;
|
||||
private ManualLogSource _logger;
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Logger = BepInEx.Logging.Logger.CreateLogSource(nameof(MenuNotificationManager));
|
||||
_logger = BepInEx.Logging.Logger.CreateLogSource(nameof(MenuNotificationManager));
|
||||
|
||||
var versionJson = RequestHandler.GetJson("/singleplayer/settings/version");
|
||||
sptVersion = Json.Deserialize<VersionResponse>(versionJson).Version;
|
||||
@ -72,7 +72,7 @@ namespace SPT.Custom.Utils
|
||||
|
||||
if (release.isBeta && PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 1)
|
||||
{
|
||||
Logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
_logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
ServerLog.Info("SPT.Custom", release.betaDisclaimerAcceptText);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ namespace SPT.Custom.Utils
|
||||
// User accepted the terms, allow to continue.
|
||||
private void OnMessageAccepted()
|
||||
{
|
||||
Logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
_logger.LogInfo(release.betaDisclaimerAcceptText);
|
||||
PlayerPrefs.SetInt("SPT_AcceptedBETerms", 1);
|
||||
_isBetaDisclaimerOpen = false;
|
||||
}
|
||||
@ -158,13 +158,13 @@ namespace SPT.Custom.Utils
|
||||
// Should we show the message, only show if first run or if build has changed
|
||||
private bool ShouldShowBetaMessage()
|
||||
{
|
||||
return PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 0 && release.isBeta && !_isBetaDisclaimerOpen ? true : false;
|
||||
return PlayerPrefs.GetInt("SPT_AcceptedBETerms") == 0 && release.isBeta && !_isBetaDisclaimerOpen;
|
||||
}
|
||||
|
||||
// Should we show the release notes, only show on first run or if build has changed
|
||||
private bool ShouldShowReleaseNotes()
|
||||
{
|
||||
return PlayerPrefs.GetInt("SPT_ShownReleaseNotes") == 0 && !_isBetaDisclaimerOpen && release.releaseSummaryText != string.Empty ? true : false;
|
||||
return PlayerPrefs.GetInt("SPT_ShownReleaseNotes") == 0 && !_isBetaDisclaimerOpen && release.releaseSummaryText != string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ namespace SPT.PrePatch
|
||||
string errorMessage = (!launcherUsed) ? launcherError : pluginErrorMessage;
|
||||
MessageBoxHelper.Show(errorMessage, $"[SPT] {errorTitle}", MessageBoxHelper.MessageBoxType.OK);
|
||||
Environment.Exit(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,23 +8,23 @@ namespace SPT.SinglePlayer.Models.RaidFix
|
||||
{
|
||||
public struct BundleLoader
|
||||
{
|
||||
Profile Profile;
|
||||
private Profile _profile;
|
||||
TaskScheduler TaskScheduler { get; }
|
||||
|
||||
public BundleLoader(TaskScheduler taskScheduler)
|
||||
{
|
||||
Profile = null;
|
||||
_profile = null;
|
||||
TaskScheduler = taskScheduler;
|
||||
}
|
||||
|
||||
public Task<Profile> LoadBundles(Task<Profile> task)
|
||||
{
|
||||
Profile = task.Result;
|
||||
_profile = task.Result;
|
||||
|
||||
var loadTask = Singleton<PoolManager>.Instance.LoadBundlesAndCreatePools(
|
||||
PoolManager.PoolsCategory.Raid,
|
||||
PoolManager.AssemblyType.Local,
|
||||
Profile.GetAllPrefabPaths(false).Where(x => !x.IsNullOrEmpty()).ToArray(),
|
||||
_profile.GetAllPrefabPaths(false).Where(x => !x.IsNullOrEmpty()).ToArray(),
|
||||
JobPriority.General,
|
||||
null,
|
||||
default(CancellationToken));
|
||||
@ -34,7 +34,7 @@ namespace SPT.SinglePlayer.Models.RaidFix
|
||||
|
||||
private Profile GetProfile(Task task)
|
||||
{
|
||||
return Profile;
|
||||
return _profile;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using EFT;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
namespace SPT.SinglePlayer.Models.ScavMode
|
||||
{
|
||||
public class RaidTimeRequest
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
namespace SPT.SinglePlayer.Models.ScavMode
|
||||
{
|
||||
public class RaidTimeResponse
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
var matchmakerPlayersController = menuController.GetType()
|
||||
.GetFields(AccessTools.all)
|
||||
.Single(field => field.FieldType == typeof(MatchmakerPlayerControllerClass))
|
||||
?.GetValue(menuController) as MatchmakerPlayerControllerClass;
|
||||
.GetValue(menuController) as MatchmakerPlayerControllerClass;
|
||||
|
||||
var gclass = new MatchmakerOfflineRaidScreen.CreateRaidSettingsForProfileClass(profile?.Info, ref raidSettings, ref offlineRaidSettings, matchmakerPlayersController, ESessionMode.Pve);
|
||||
|
||||
|
@ -9,6 +9,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using SPT.SinglePlayer.Models.ScavMode;
|
||||
|
||||
namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
{
|
||||
@ -28,7 +29,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
var desiredType = typeof(TarkovApplication);
|
||||
var desiredMethod = Array.Find(desiredType.GetMethods(PatchConstants.PublicDeclaredFlags), IsTargetMethod);
|
||||
|
||||
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
|
||||
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType.Name}");
|
||||
Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}");
|
||||
|
||||
return desiredMethod;
|
||||
@ -39,11 +40,11 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
// method_46 as of 32128
|
||||
var parameters = arg.GetParameters();
|
||||
return parameters.Length == 5
|
||||
&& parameters[0]?.Name == "gameWorld"
|
||||
&& parameters[1]?.Name == "timeAndWeather"
|
||||
&& parameters[2]?.Name == "timeHasComeScreenController"
|
||||
&& parameters[3]?.Name == "metricsEvents"
|
||||
&& parameters[4]?.Name == "metricsConfig"
|
||||
&& parameters[0].Name == "gameWorld"
|
||||
&& parameters[1].Name == "timeAndWeather"
|
||||
&& parameters[2].Name == "timeHasComeScreenController"
|
||||
&& parameters[3].Name == "metricsEvents"
|
||||
&& parameters[4].Name == "metricsConfig"
|
||||
&& arg.ReturnType == typeof(Task);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,6 @@ namespace SPT.SinglePlayer.Patches.ScavMode
|
||||
public class ScavSellAllRequestPatch : ModulePatch
|
||||
{
|
||||
private static MethodInfo _sendOperationMethod;
|
||||
private string TargetMethodName = "SellAllFromSavage";
|
||||
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
using SPT.SinglePlayer.Patches.ScavMode;
|
||||
using EFT;
|
||||
using System;
|
||||
using SPT.SinglePlayer.Models.ScavMode;
|
||||
|
||||
namespace SPT.SinglePlayer.Utils.InRaid
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user