From 9b574697073c8d4be066b78e1d8e892720045bb2 Mon Sep 17 00:00:00 2001 From: Lacyway Date: Mon, 16 Sep 2024 18:18:52 +0000 Subject: [PATCH] Add FixLocalRaidPatch (!167) This patch ensures that the game mode is _always_ Local and PvE if the player skips the raid settings window. This way an online `GameWorld` will not be incorrectly instantiated. **NOTE**: This might make EnablePlayerScavPatch redundant or at least parts of it. Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT/Modules/pulls/167 Co-authored-by: Lacyway Co-committed-by: Lacyway --- .../Patches/MainMenu/FixLocalRaidPatch.cs | 26 +++++++++++++++++++ .../SPT.SinglePlayer/SPTSingleplayerPlugin.cs | 1 + 2 files changed, 27 insertions(+) create mode 100644 project/SPT.SinglePlayer/Patches/MainMenu/FixLocalRaidPatch.cs diff --git a/project/SPT.SinglePlayer/Patches/MainMenu/FixLocalRaidPatch.cs b/project/SPT.SinglePlayer/Patches/MainMenu/FixLocalRaidPatch.cs new file mode 100644 index 0000000..01268cb --- /dev/null +++ b/project/SPT.SinglePlayer/Patches/MainMenu/FixLocalRaidPatch.cs @@ -0,0 +1,26 @@ +using EFT; +using HarmonyLib; +using SPT.Reflection.Patching; +using System.Reflection; + +namespace SPT.SinglePlayer.Patches.MainMenu +{ + /// + /// This patch ensures that the gamemode is always and that IsPveOffline is always true when starting a game
+ /// This prevents a bug where the gameworld is instantiated as an online world + ///
+ public class FixLocalRaidPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(TarkovApplication), nameof(TarkovApplication.method_41)); + } + + [PatchPrefix] + public static void Prefix(ref RaidSettings ____raidSettings) + { + ____raidSettings.RaidMode = ERaidMode.Local; + ____raidSettings.IsPveOffline = true; + } + } +} diff --git a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs index 5a39310..8d79316 100644 --- a/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs +++ b/project/SPT.SinglePlayer/SPTSingleplayerPlugin.cs @@ -59,6 +59,7 @@ namespace SPT.SinglePlayer //new InsuranceScreenPatch().Enable(); new RemoveStashUpgradeLabelPatch().Enable(); new RemoveClothingItemExternalObtainLabelPatch().Enable(); + new FixLocalRaidPatch().Enable(); } catch (Exception ex) {