From a346778db9213101636d482515ff818319f71817 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Fri, 20 Mar 2026 15:08:02 +0800 Subject: [PATCH] fix possible crash --- CheatEnabler/Patches/FactoryPatch.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CheatEnabler/Patches/FactoryPatch.cs b/CheatEnabler/Patches/FactoryPatch.cs index 9982805..7db4a07 100644 --- a/CheatEnabler/Patches/FactoryPatch.cs +++ b/CheatEnabler/Patches/FactoryPatch.cs @@ -307,7 +307,7 @@ public class FactoryPatch : PatchImpl private static void PlanetData_NotifyFactoryLoaded_Postfix(PlanetData __instance) { var main = GameMain.instance; - if (main != null && main._running) + if (main != null && main._running && __instance.factory?.planet?.data != null) { ArrivePlanet(__instance.factory); } @@ -317,7 +317,7 @@ public class FactoryPatch : PatchImpl { if (DSPGame.IsMenuDemo) return; var factory = GameMain.mainPlayer?.factory; - if (factory != null) + if (factory?.planet?.data != null) { ArrivePlanet(factory); } @@ -399,7 +399,7 @@ public class FactoryPatch : PatchImpl protected override void OnEnable() { var factory = GameMain.mainPlayer?.factory; - if (factory != null) + if (factory?.planet?.data != null) { ArrivePlanet(factory); } @@ -562,7 +562,7 @@ public class FactoryPatch : PatchImpl private static void UXAssist_PlanetFunctions_BuildOrbitalCollectors_Postfix() { var factory = GameMain.mainPlayer?.factory; - if (factory != null) + if (factory?.planet?.data != null) { ArrivePlanet(factory); } @@ -576,7 +576,7 @@ public class FactoryPatch : PatchImpl protected override void OnEnable() { var factory = GameMain.mainPlayer?.factory; - if (factory != null) + if (factory?.planet?.data != null) { ArrivePlanet(factory); }