0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 08:30:45 -05:00
modules/project/SPT.Custom/Patches/FixAirdropCrashPatch.cs
Archangel 5a58e03854 Add FixAirdropCrashPatch (!175)
This fixes the current issue of having an airdrop in the game causing a CTD after an extract.

There's still two caveats to this that I'm looking into:
- On the very next raid, the sky will still have the chaff from the flares in the sky, however these will have pink textures and take a few seconds to dissipate.
- On the very next raid, calling in an airplane with a red flare will cause the notification manager to spam messages about the airspace being currently in use even at the start of the raid.

Reviewed-on: SPT/Modules#175
Co-authored-by: Archangel <jesse@archangel.wtf>
Co-committed-by: Archangel <jesse@archangel.wtf>
2024-11-18 20:50:55 +00:00

43 lines
1.2 KiB
C#

using EFT.SynchronizableObjects;
using EFT;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Collections.Generic;
using System.Reflection;
using Comfort.Common;
namespace SPT.Custom.Patches
{
/// <summary>
/// This patch prevents the crashing that was caused by the airdrop since the mortar event, it fully unloads whatever synchronized objects
/// Are still loaded before unused resources are cleaned up (Which causes this crash)
/// </summary>
public class FixAirdropCrashPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(TarkovApplication).GetMethod(nameof(TarkovApplication.method_48));
}
[PatchPrefix]
public static void Prefix()
{
if (Singleton<GameWorld>.Instantiated)
{
GameWorld gameWorld = Singleton<GameWorld>.Instance;
List<SynchronizableObject> synchronizableObjectList = Traverse.Create(gameWorld.SynchronizableObjectLogicProcessor).Field<List<SynchronizableObject>>("list_0").Value;
foreach (SynchronizableObject obj in synchronizableObjectList)
{
obj.Logic.ReturnToPool();
obj.ReturnToPool();
}
gameWorld.SynchronizableObjectLogicProcessor.Dispose();
}
}
}
}