feat: actually fail in Framework if tier load fails, remove DALAMUD_NOT_HAVE_INTERFACE

This commit is contained in:
goaaats 2021-11-07 16:39:40 +01:00
parent d06a7efff8
commit c06a29a2d4
No known key found for this signature in database
GPG key ID: F18F057873895461
3 changed files with 35 additions and 53 deletions

View file

@ -7,11 +7,6 @@ namespace Dalamud.Configuration.Internal
/// </summary>
internal class EnvironmentConfiguration
{
/// <summary>
/// Gets a value indicating whether the DALAMUD_NOT_HAVE_INTERFACE setting has been enabled.
/// </summary>
public static bool DalamudNoInterface { get; } = GetEnvironmentVariable("DALAMUD_NOT_HAVE_INTERFACE");
/// <summary>
/// Gets a value indicating whether the XL_WINEONLINUX setting has been enabled.
/// </summary>

View file

@ -78,16 +78,6 @@ namespace Dalamud
/// </summary>
internal LoggingLevelSwitch LogLevelSwitch { get; private set; }
/// <summary>
/// Gets a value indicating whether Dalamud was successfully loaded.
/// </summary>
internal bool IsReady { get; private set; }
/// <summary>
/// Gets a value indicating whether the plugin system is loaded.
/// </summary>
internal bool IsLoadedPluginSystem => Service<PluginManager>.GetNullable() != null;
/// <summary>
/// Gets location of stored assets.
/// </summary>
@ -137,7 +127,8 @@ namespace Dalamud
/// <summary>
/// Runs tier 2 of the Dalamud initialization process.
/// </summary>
public void LoadTier2()
/// <returns>Whether or not the load succeeded.</returns>
public bool LoadTier2()
{
try
{
@ -153,6 +144,7 @@ namespace Dalamud
antiDebug.Enable();
#endif
}
Log.Information("[T2] AntiDebug OK!");
Service<WinSockHandlers>.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<InterfaceManager>.Set().Enable();
// This is enabled in ImGuiScene setup
Service<DalamudIME>.Set();
Log.Information("[T2] IME OK!");
Log.Information("[T2] IM OK!");
}
catch (Exception e)
{
Log.Information(e, "Could not init interface.");
}
}
try
{
Service<DalamudIME>.Set();
Log.Information("[T2] IME OK!");
}
catch (Exception e)
{
Log.Information(e, "Could not init IME.");
}
Service<InterfaceManager>.Set().Enable();
Log.Information("[T2] IM OK!");
#pragma warning disable CS0618 // Type or member is obsolete
Service<SeStringManager>.Set();
@ -235,20 +210,23 @@ namespace Dalamud
Service<DalamudAtkTweaks>.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;
}
/// <summary>
/// Runs tier 3 of the Dalamud initialization process.
/// </summary>
public void LoadTier3()
/// <returns>Whether or not the load succeeded.</returns>
public bool LoadTier3()
{
try
{
@ -287,7 +265,11 @@ namespace Dalamud
{
Log.Error(ex, "Tier 3 load failed.");
this.Unload();
return false;
}
return true;
}
/// <summary>

View file

@ -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<OnUpdateDetour> updateHook;
private Hook<OnDestroyDetour> 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<Dalamud>.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<InterfaceManager>.GetNullable()?.IsReady == true)
if (!this.tier3Initialized && Service<InterfaceManager>.GetNullable()?.IsReady == true)
{
dalamud.LoadTier3();
this.tier3Initialized = dalamud.LoadTier3();
if (!this.tier3Initialized)
this.tierInitError = true;
goto original;
}