diff --git a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs index 641cd5c2b..8a2a61b4f 100644 --- a/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs +++ b/Dalamud/Configuration/Internal/EnvironmentConfiguration.cs @@ -7,11 +7,6 @@ namespace Dalamud.Configuration.Internal /// internal class EnvironmentConfiguration { - /// - /// Gets a value indicating whether the DALAMUD_NOT_HAVE_INTERFACE setting has been enabled. - /// - public static bool DalamudNoInterface { get; } = GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE"); - /// /// Gets a value indicating whether the XL_WINEONLINUX setting has been enabled. /// diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 78bbeeccb..f5460af2f 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -78,16 +78,6 @@ namespace Dalamud /// internal LoggingLevelSwitch LogLevelSwitch { get; private set; } - /// - /// Gets a value indicating whether Dalamud was successfully loaded. - /// - internal bool IsReady { get; private set; } - - /// - /// Gets a value indicating whether the plugin system is loaded. - /// - internal bool IsLoadedPluginSystem => Service.GetNullable() != null; - /// /// Gets location of stored assets. /// @@ -137,7 +127,8 @@ namespace Dalamud /// /// Runs tier 2 of the Dalamud initialization process. /// - public void LoadTier2() + /// Whether or not the load succeeded. + public bool LoadTier2() { try { @@ -153,6 +144,7 @@ namespace Dalamud antiDebug.Enable(); #endif } + Log.Information("[T2] AntiDebug OK!"); Service.Set(); @@ -169,7 +161,7 @@ namespace Dalamud { Log.Error(e, "Could not initialize DataManager."); this.Unload(); - return; + return false; } Log.Information("[T2] Data OK!"); @@ -189,29 +181,12 @@ namespace Dalamud Log.Information("[T2] LOC OK!"); - if (!EnvironmentConfiguration.DalamudNoInterface) - { - try - { - Service.Set().Enable(); + // This is enabled in ImGuiScene setup + Service.Set(); + Log.Information("[T2] IME OK!"); - Log.Information("[T2] IM OK!"); - } - catch (Exception e) - { - Log.Information(e, "Could not init interface."); - } - } - - try - { - Service.Set(); - Log.Information("[T2] IME OK!"); - } - catch (Exception e) - { - Log.Information(e, "Could not init IME."); - } + Service.Set().Enable(); + Log.Information("[T2] IM OK!"); #pragma warning disable CS0618 // Type or member is obsolete Service.Set(); @@ -235,20 +210,23 @@ namespace Dalamud Service.Set().Enable(); - this.IsReady = true; Log.Information("[T2] Load complete!"); } catch (Exception ex) { Log.Error(ex, "Tier 2 load failed."); this.Unload(); + return false; } + + return true; } /// /// Runs tier 3 of the Dalamud initialization process. /// - public void LoadTier3() + /// Whether or not the load succeeded. + public bool LoadTier3() { try { @@ -287,7 +265,11 @@ namespace Dalamud { Log.Error(ex, "Tier 3 load failed."); this.Unload(); + + return false; } + + return true; } /// diff --git a/Dalamud/Game/Framework.cs b/Dalamud/Game/Framework.cs index 988a08693..38a978e1f 100644 --- a/Dalamud/Game/Framework.cs +++ b/Dalamud/Game/Framework.cs @@ -28,7 +28,9 @@ namespace Dalamud.Game private static Stopwatch statsStopwatch = new(); private Stopwatch updateStopwatch = new(); - private DateTime tier2LoadTime; + private bool tier2Initialized = false; + private bool tier3Initialized = false; + private bool tierInitError = false; private Hook updateHook; private Hook destroyHook; @@ -173,26 +175,29 @@ namespace Dalamud.Game private bool HandleFrameworkUpdate(IntPtr framework) { + // If any of the tier loads failed, just go to the original code. + if (this.tierInitError) + goto original; + var dalamud = Service.Get(); // If this is the first time we are running this loop, we need to init Dalamud subsystems synchronously - if (!dalamud.IsReady) + if (!this.tier2Initialized) { - dalamud.LoadTier2(); - this.tier2LoadTime = DateTime.Now; + this.tier2Initialized = dalamud.LoadTier2(); + if (!this.tier2Initialized) + this.tierInitError = true; + goto original; } - if (!dalamud.IsLoadedPluginSystem && (DateTime.Now - this.tier2LoadTime).TotalSeconds > 30) - { - Log.Error("Did not detect tier 3 load!!! {Seconds}", (DateTime.Now - this.tier2LoadTime).TotalSeconds); - // Util.Fatal("The Dalamud plugin system could not initialize important subsystems.\nThis error may be caused by outdated ReShade or GShade installations.\n\nIf this error persists, please contact us.", "XIVLauncher Error"); - } - // Plugins expect the interface to be available and ready, so we need to wait with plugins until we have init'd ImGui - if (!dalamud.IsLoadedPluginSystem && Service.GetNullable()?.IsReady == true) + if (!this.tier3Initialized && Service.GetNullable()?.IsReady == true) { - dalamud.LoadTier3(); + this.tier3Initialized = dalamud.LoadTier3(); + if (!this.tier3Initialized) + this.tierInitError = true; + goto original; }